@nathanstephenson/flow 0.1.10-beta.1 → 0.1.10-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -22
- package/build/backend-worker-chunks/{chunk-CYE5L6Z5.mjs → chunk-3KDHJA5P.mjs} +41 -10
- package/build/backend-worker-chunks/{chunk-UQDH2COY.mjs → chunk-K774KOGL.mjs} +2 -7
- package/build/backend-worker-chunks/chunk-LAEUXDNH.mjs +130 -0
- package/build/backend-worker-chunks/{chunk-MLOUI3ZM.mjs → chunk-NZZME2I3.mjs} +6 -1
- package/build/backend-worker-chunks/claude-JG2FXYBQ.mjs +35859 -0
- package/build/backend-worker-chunks/{pi-UKRC4DDM.mjs → pi-KJSP23AO.mjs} +2091 -92
- package/build/backend-worker.mjs +69 -122
- package/build/workflow-runtime.cjs +12 -12
- package/dist/backend/claude/background-calls.js +7 -3
- package/dist/backend/claude/import.js +415 -0
- package/dist/backend/claude/index.js +188 -25
- package/dist/backend/claude/subagents.js +41 -9
- package/dist/backend/claude/todo-list.js +114 -0
- package/dist/backend/claude/workflow-parent.js +1 -1
- package/dist/backend/diff-excerpt-instructions.js +8 -0
- package/dist/backend/fake/index.js +54 -6
- package/dist/backend/mcp.js +4 -1
- package/dist/backend/pi/agent-permissions.js +1 -1
- package/dist/backend/pi/cache-warming.js +8 -0
- package/dist/backend/pi/canonical-json.js +120 -0
- package/dist/backend/pi/compaction-model.js +3 -2
- package/dist/backend/pi/host-auth.js +258 -0
- package/dist/backend/pi/import.js +269 -0
- package/dist/backend/pi/index.js +118 -20
- package/dist/backend/pi/model-auth.js +159 -0
- package/dist/backend/pi/model-catalog.js +120 -0
- package/dist/backend/pi/model-config.js +5 -0
- package/dist/backend/pi/model-selection.js +32 -0
- package/dist/backend/pi/plan-limits.js +41 -0
- package/dist/backend/pi/state.js +19 -1
- package/dist/backend/pi/subagents.js +7 -3
- package/dist/backend/pi/todo-list.js +23 -0
- package/dist/backend/pi/work.js +9 -1
- package/dist/backend/pi/workflow-parent.js +1 -1
- package/dist/backend/pi/workflow-subagent.js +4 -3
- package/dist/backend/plan-limits.js +17 -0
- package/dist/backend/session-tools.js +1 -1
- package/dist/backend/worker/claude-state.js +48 -0
- package/dist/backend/worker/entry.js +42 -8
- package/dist/backend/worker/index.js +131 -15
- package/dist/backend/worker/launcher.js +11 -4
- package/dist/backend/worker/protocol.js +2 -1
- package/dist/backend/worker/rpc.js +13 -0
- package/dist/backend/worker/sandbox-mcp.js +18 -7
- package/dist/backend/workflow-tools.js +9 -7
- package/dist/build-id +1 -1
- package/dist/cli/application.js +48 -42
- package/dist/cli/bootstrap.js +2 -2
- package/dist/cli/host-control.js +1 -1
- package/dist/cli/install-guard.js +2 -2
- package/dist/cli/main.js +4 -4
- package/dist/cli/systemd-update.js +3 -3
- package/dist/cli/update.js +6 -6
- package/dist/cli/web-update.js +6 -6
- package/dist/client/connection.js +46 -0
- package/dist/client/context-usage.js +3 -4
- package/dist/client/diff.js +40 -0
- package/dist/client/enquiry.js +0 -6
- package/dist/client/markdown.js +3 -2
- package/dist/client/model-choices.js +1 -1
- package/dist/client/permission.js +1 -2
- package/dist/client/project-name.js +3 -1
- package/dist/client/reduce.js +77 -3
- package/dist/client/relative-time.js +1 -1
- package/dist/client/scope-kind.js +6 -3
- package/dist/client/search.js +1 -1
- package/dist/client/status.js +1 -1
- package/dist/client/subagent-tree.js +49 -0
- package/dist/client/tool-chains.js +1 -1
- package/dist/client/tool-summary.js +28 -18
- package/dist/daemon/changes.js +128 -0
- package/dist/daemon/commit.js +84 -0
- package/dist/daemon/config-store.js +8 -3
- package/dist/daemon/config.js +105 -4
- package/dist/daemon/diff-excerpts.js +52 -0
- package/dist/daemon/git-state.js +197 -0
- package/dist/daemon/git.js +53 -10
- package/dist/daemon/github-image.js +18 -0
- package/dist/daemon/github.js +54 -0
- package/dist/daemon/host-control-routes.js +1 -1
- package/dist/daemon/host.js +940 -119
- package/dist/daemon/http.js +4 -1
- package/dist/daemon/log.js +3 -0
- package/dist/daemon/mcp-auth.js +1 -1
- package/dist/daemon/models.js +2 -2
- package/dist/daemon/pi-model-cache.js +44 -0
- package/dist/daemon/pull-request.js +223 -138
- package/dist/daemon/push.js +43 -0
- package/dist/daemon/repository.js +123 -0
- package/dist/daemon/runtime.js +103 -22
- package/dist/daemon/secret-store.js +1 -1
- package/dist/daemon/server.js +111 -14
- package/dist/daemon/skills.js +24 -0
- package/dist/daemon/spend-ledger.js +118 -0
- package/dist/daemon/stack-metadata.js +12 -5
- package/dist/daemon/stack.js +162 -657
- package/dist/daemon/store.js +2 -0
- package/dist/daemon/summariser.js +30 -12
- package/dist/daemon/tour.js +56 -0
- package/dist/daemon/whisper.js +144 -0
- package/dist/daemon/workflow-authoring-scope-checks.js +1 -1
- package/dist/daemon/workflow-authoring-scope.js +1 -1
- package/dist/daemon/workflow-builder-files.js +2 -2
- package/dist/daemon/workflow-builder-guidance.js +1 -1
- package/dist/daemon/workflow-builder-routes.js +2 -2
- package/dist/daemon/workflow-builder.js +44 -17
- package/dist/daemon/workflow-environment.js +193 -0
- package/dist/daemon/workflow-execution-launch.js +77 -0
- package/dist/daemon/workflow-execution-resources.js +76 -0
- package/dist/daemon/workflow-execution-routes.js +12 -9
- package/dist/daemon/workflow-execution-values.js +128 -0
- package/dist/daemon/workflow-executions.js +400 -311
- package/dist/daemon/workflow-mcp-authoring-routes.js +2 -2
- package/dist/daemon/workflow-mcp-authoring.js +4 -4
- package/dist/daemon/workflow-mcp.js +1 -1
- package/dist/daemon/workflow-routes.js +60 -2
- package/dist/daemon/workflow-schedule-driver.js +251 -0
- package/dist/daemon/workflow-schedule-routes.js +137 -0
- package/dist/daemon/workflow-schedules.js +342 -0
- package/dist/isolation/filesystem.js +6 -2
- package/dist/isolation/sandbox.js +61 -18
- package/dist/isolation/shared-sandbox.js +3 -3
- package/dist/isolation/toolchain-assets.js +1 -1
- package/dist/protocol/events.js +3 -0
- package/dist/protocol/plan-limits.js +1 -0
- package/dist/protocol/settings.js +1 -0
- package/dist/protocol/spend.js +2 -0
- package/dist/protocol/stack.js +12 -39
- package/dist/protocol/workflow-schedules.js +1 -0
- package/dist/workflows/calls.js +53 -0
- package/dist/workflows/errors.js +2 -0
- package/dist/workflows/executors.js +6 -5
- package/dist/workflows/graph.js +83 -9
- package/dist/workflows/invocations.js +23 -0
- package/dist/workflows/mcp.js +1 -1
- package/dist/workflows/owner.js +45 -0
- package/dist/workflows/records.js +127 -11
- package/dist/workflows/recovery.js +38 -2
- package/dist/workflows/runtime-settings.js +16 -16
- package/dist/workflows/runtime.js +2 -2
- package/dist/workflows/schedule-errors.js +2 -0
- package/dist/workflows/schedule-store.js +385 -0
- package/dist/workflows/scheduler.js +367 -96
- package/dist/workflows/schedules.js +130 -0
- package/dist/workflows/schema.js +3 -1
- package/dist/workflows/store.js +126 -13
- package/package.json +10 -6
- package/web/dist/assets/index-C76t-z4w.css +2 -0
- package/web/dist/assets/{index-DRfeO6GJ.js → index-WPfbYVQ4.js} +39 -23
- package/web/dist/assets/{switch-DIogWclb.js → select-C5Ly2OpB.js} +1 -1
- package/web/dist/assets/{settings-mcp-Clp_jMWW.js → settings-mcp-BF-yqpeQ.js} +1 -1
- package/web/dist/assets/{settings-secrets-BIO_hXZ1.js → settings-secrets-WLarr2QP.js} +1 -1
- package/web/dist/assets/settings-workflows-DdcdRWFD.js +23 -0
- package/web/dist/assets/workflow-api-GjAmHc22.js +6 -0
- package/web/dist/assets/workflows-BhY3Uibo.js +149 -0
- package/web/dist/assets/workflows-pane-DElCcEpN.js +1 -0
- package/web/dist/index.html +6 -5
- package/build/backend-worker-chunks/claude-UXZDJKZQ.mjs +0 -30816
- package/dist/daemon/publish.js +0 -289
- package/dist/tui/app.js +0 -612
- package/dist/tui/keys.js +0 -90
- package/dist/tui/render.js +0 -411
- package/web/dist/assets/index-DgQFpKbn.css +0 -2
- package/web/dist/assets/settings-workflows-H-6eCff3.js +0 -23
- package/web/dist/assets/workflow-api-BfExddae.js +0 -6
- package/web/dist/assets/workflow-editors-CsbVx4WJ.js +0 -139
- package/web/dist/assets/workflows-Bv0sj7d0.js +0 -7
- package/web/dist/assets/workflows-pane-DHm44w7P.js +0 -1
- /package/dist/protocol/{publish.js → imports.js} +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-B0Z9INg1.js";import{$n as a,$t as o,A as s,An as c,Bn as l,C as u,E as d,En as f,Er as p,Gn as m,Hn as h,In as g,J as _,Jn as v,K as y,Kn as b,Kt as x,Mn as S,N as C,Nn as w,O as T,Or as E,P as D,Pn as O,Q as k,Qn as A,Rn as j,S as M,T as N,Tn as P,U as F,Un as I,Vn as L,Wn as R,Xn as ee,Y as z,Yn as B,Z as te,Zn as V,_ as ne,an as re,bn as ie,cr as ae,ct as oe,dr as se,et as ce,fr as le,ft as ue,g as de,gn as fe,gt as pe,ht as me,i as he,in as ge,j as _e,jn as ve,kn as ye,kr as be,l as xe,mn as Se,mt as Ce,nt as we,on as Te,ot as Ee,q as De,rn as Oe,rt as ke,sn as Ae,sr as je,st as Me,tn as Ne,tt as Pe,ur as Fe,v as Ie,wn as Le,wr as Re,x as ze,xn as Be,y as Ve,yn as He,yr as Ue,z as We}from"./workflow-api-GjAmHc22.js";import{$ as Ge,A as Ke,At as qe,Ct as Je,D as Ye,Dt as Xe,E as Ze,Et as Qe,J as $e,K as et,M as tt,N as nt,Nt as rt,O as it,Ot as at,Q as ot,R as st,St as ct,T as lt,Tt as ut,U as dt,X as ft,Y as pt,Z as mt,at as ht,bt as gt,ct as _t,dt as vt,et as yt,ft as bt,gt as xt,ht as St,i as Ct,it as wt,j as Tt,k as Et,kt as Dt,lt as Ot,mt as kt,n as At,o as jt,ot as Mt,pt as Nt,q as Pt,rt as Ft,s as It,st as Lt,t as Rt,tt as zt,ut as Bt,vt as Vt,wt as Ht,xt as Ut,yt as Wt}from"./select-C5Ly2OpB.js";function Gt(e){if(!e)return;let{used:t,window:n}=e;return n>0?`context ${Math.round(t/n*100)}%`:`${t} tokens`}function Kt(e){if(!e||e.window<=0)return;let{used:t,window:n,spend:r}=e,i=[{label:`Context`,value:`${Math.round(t/n*100)}% · ${Jt(t)}/${Jt(n)} tokens`}];if(!r)return i;if(i.push({label:`Spent`,value:`${Jt(r.tokens)} tokens · ${qt(r.costUSD)}`}),i.push({label:`Cache reads`,value:`${Jt(r.cached)} of ${Jt(r.tokens)}`}),r.models.length>1)for(let e of r.models)i.push({label:e.id,value:`${Jt(e.tokens)} · ${qt(e.costUSD)}`,model:!0});return i}function qt(e){return e>=.01?`$${e.toFixed(2)}`:e===0?`$0.00`:`$${e.toFixed(4)}`}function Jt(e){return e>=1e6?`${Math.round(e/1e5)/10}M`:e>=1e3?`${Math.round(e/1e3)}k`:`${e}`}function Yt(e){return e.lifecycle===`live`?e.awaiting?`awaiting`:e.turnInFlight?`running`:`idle`:e.lifecycle}function Xt(e){return e===`running`||e===`awaiting`}function Zt(e){return e.status===`settled`||e.status===`ended`?`filed-away`:e.attention?.group===`needs-input`?`needs-input`:e.attention?.group===`unread`?`unread`:e.status===`running`||e.status===`awaiting`||$t(e)?`working`:e.status===`idle`?`idle`:`dormant`}function Qt(e){switch(e){case`needs-input`:return`Needs input`;case`unread`:return`Unread`;case`working`:return`Working`;case`idle`:return`Idle`;case`dormant`:return`Dormant`;case`filed-away`:return`Filed away`}}function $t(e){return e.status===`idle`&&e.activeSubagents+e.activeBackgroundCalls+(e.activeWorkflows??0)>0}function en(e){return e!==`settled`&&e!==`ended`}function tn(e){return e===`dormant`||e===`settled`}function nn(e){let t={tokens:0,cached:0,costUSD:0,models:[]};for(let n of e){t.tokens+=n.tokens,t.cached+=n.cached,t.costUSD+=n.costUSD;for(let e of n.models){let n=t.models.find(t=>t.id===e.id);n?(n.tokens+=e.tokens,n.cached+=e.cached,n.costUSD+=e.costUSD):t.models.push({...e})}}return t}function rn(){return{status:`idle`,lifecycle:`live`,turnInFlight:!1,entries:[],queue:[],activeSubagents:0,activeBackgroundCalls:0,lastSeq:0}}function an(e){return e===`running`||e===`waiting`}function on(e,t=rn()){let n=t;for(let t of e)n=cn(n,t);return n}function sn(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.kind===`user`&&r.producer===void 0)return e;if(r.kind===`assistant`&&r.producer===void 0){if(r.endedAt===t)return e;let i=e.slice();return i[n]={...r,endedAt:t},i}}return e}function cn(e,t){let n=ln(e,t.event,t.at);return n===void 0?{...e,lastSeq:t.seq}:n===e?e:{...n,status:Yt({lifecycle:n.lifecycle,turnInFlight:n.turnInFlight,awaiting:n.asking!==void 0&&n.asking.producer===void 0||n.authorising!==void 0&&n.authorising.producer===void 0}),lastSeq:t.seq}}function ln(e,t,n){switch(t.type){case`session_started`:return{...e,backend:t.backend,scope:t.scope,capabilities:t.capabilities,...t.permissionMode?{permissionMode:t.permissionMode}:{},...t.worktree===void 0?{}:{worktree:t.worktree}};case`capabilities_changed`:return{...e,capabilities:t.capabilities};case`user_message`:return{...e,spoken:!0,...e.todoList?.every(e=>e.status===`completed`)?{todoList:void 0}:{},entries:_n(e.entries,{kind:`user`,id:t.id,...t.fromSessionId===void 0?{text:t.text}:{text:t.text.slice(t.text.indexOf(`
|
|
2
|
+
`)+1),fromSessionId:t.fromSessionId},...t.note===void 0?{}:{note:t.note},...t.attachments===void 0?{}:{attachments:t.attachments},at:n})};case`subagent_instruction`:return{...e,entries:_n(e.entries,{kind:`user`,id:t.id,text:t.text,producer:t.producer,at:n})};case`turn_started`:return{...e,turnInFlight:!0};case`message`:return{...e,entries:_n(e.entries,{kind:`assistant`,id:t.id,text:t.text,final:t.final,...gn(t)})};case`diff_excerpts`:return{...e,entries:e.entries.map(e=>e.kind===`assistant`&&e.id===t.messageId?{...e,excerpts:t.excerpts}:e)};case`thinking`:return{...e,entries:_n(e.entries,{kind:`thinking`,id:t.id,text:t.text,final:t.final,...gn(t)})};case`tool_started`:return{...e,entries:_n(e.entries,{kind:`tool`,id:t.callId,name:t.name,input:t.input,status:`running`,...gn(t)})};case`tool_updated`:return{...e,entries:vn(e.entries,t.callId,e=>({...e,update:t.update}))};case`tool_ended`:return{...e,entries:vn(e.entries,t.callId,e=>({...e,result:t.result,status:t.isError?`error`:`complete`}))};case`subagent`:{let r=e.entries.find(e=>e.kind===`subagent`&&e.id===t.subagentId),i=r!==void 0&&an(r.status),a=an(t.state),o=a?void 0:r?.endedAt??n;return{...e,activeSubagents:e.activeSubagents+ +!!a-+!!i,entries:_n(e.entries,{kind:`subagent`,id:t.subagentId,name:t.name,...t.description===void 0?{}:{description:t.description},...t.model===void 0?{}:{model:t.model},...t.effort===void 0?{}:{effort:t.effort},...t.producer===void 0?{}:{producer:t.producer},status:t.state,...t.state===`waiting`?{waitingOn:t.on}:{},startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`background_call`:{let r=e.entries.find(e=>e.kind===`background_call`&&e.id===t.callId),i=r?.status===`running`,a=t.state===`running`,o=a?void 0:r?.endedAt??n;return{...e,activeBackgroundCalls:e.activeBackgroundCalls+ +!!a-+!!i,entries:_n(e.entries,{kind:`background_call`,id:t.callId,tool:t.tool,status:t.state,...gn(t),startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`enquiry`:{let n=t.state===`asked`,r=n&&e.asking?.askId===t.askId?e.asking:n?{askId:t.askId,questions:t.questions,...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}}:e.asking?.askId===t.askId?void 0:e.asking;return{...e,...r===void 0?{asking:void 0}:{asking:r},entries:_n(e.entries,{kind:`enquiry`,id:t.askId,questions:t.questions,status:t.state,...t.state===`answered`?{answers:t.answers}:{},...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}})}}case`permission`:{let n=t.state===`asked`?e.authorising??{callId:t.callId,tool:t.tool,...t.context===void 0?{}:{context:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope},...t.producer===void 0?{}:{producer:t.producer}}:e.authorising?.callId===t.callId?pn(e.entries,t.callId):e.authorising;return{...e,...n===void 0?{authorising:void 0}:{authorising:n},entries:vn(e.entries,t.callId,e=>({...e,authorisation:fn(t),...t.context===void 0?{}:{permissionContext:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope}}))}}case`plan`:{let n=t.entries.length===0?void 0:e.todoList!==void 0&&mn(e.todoList,t.entries)?e.todoList:t.entries,r=t.callId,i=r===void 0?void 0:e.entries.find(e=>e.kind===`tool`&&e.id===r),a=i?.kind===`tool`&&!(i.todos!==void 0&&mn(i.todos,t.entries))&&r!==void 0?vn(e.entries,r,e=>({...e,todos:n??[]})):e.entries;return n===e.todoList&&a===e.entries?e:{...e,todoList:n,entries:a}}case`turn_ended`:return{...e,entries:sn(e.entries,n),turnInFlight:!1,asking:e.asking?.producer===void 0?void 0:e.asking,authorising:e.authorising?.producer===void 0?void 0:e.authorising};case`queue_changed`:return{...e,queue:[...t.pending],queuedMessages:e.queuedMessages?.length===t.pending.length&&e.queuedMessages.every((e,n)=>e.text===t.pending[n]&&e.id===t.ids?.[n]&&(e.attachments?.length??0)===(t.attachments?.[n]?.length??0)&&(e.attachments??[]).every((e,r)=>e===t.attachments?.[n]?.[r]))?e.queuedMessages:t.pending.map((e,n)=>({id:t.ids?.[n],text:e,...t.attachments?.[n]?.length?{attachments:t.attachments[n]}:{}}))};case`workflow_spend`:{let n={...e.workflowSpend,[t.executionId]:t.spend},r=nn([...e.parentSpend?[e.parentSpend]:[],...Object.values(n)]);return{...e,workflowSpend:n,spend:r,...e.contextUsage?{contextUsage:{...e.contextUsage,spend:r}}:{}}}case`context_usage`:{let n=t.spend||e.workflowSpend?nn([...t.spend?[t.spend]:[],...Object.values(e.workflowSpend??{})]):void 0;return{...e,...t.spend?{parentSpend:t.spend}:{},...n?{spend:n}:{},contextUsage:{used:t.used,window:t.window,...n===void 0?{}:{spend:n}}}}case`model_changed`:return{...e,model:t.model};case`permission_mode_changed`:return{...e,permissionMode:t.mode};case`effort_changed`:return{...e,effort:t.effort};case`branch_changed`:return{...e,branch:t.branch};case`notice`:return{...e,entries:[...e.entries,{kind:`notice`,id:`notice-${e.entries.length}`,level:t.level,text:t.text,...t.sessionId===void 0?{}:{sessionId:t.sessionId}}]};case`compacting`:return t.active?{...e,compacting:!0}:un(e);case`compacted`:return{...un(e),entries:[...e.entries,{kind:`marker`,id:`compacted-${e.entries.length}`,marker:`compacted`,text:dn(t.trigger,t.before,t.after)}]};case`session_dormant`:return{...e,lifecycle:`dormant`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`dormant-${e.entries.length}`,marker:`dormant`,text:`Dormant: ${t.reason}`}]};case`session_settled`:return{...e,lifecycle:`settled`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`settled-${e.entries.length}`,marker:`settled`,text:`Settled`}]};case`rewound`:{let n=e.entries.findIndex(e=>e.kind===`user`&&e.id===t.userMessageId),r=t.restore===`files`?`Files rewound`:t.restore===`both`?`Rewound conversation and files`:`Rewound conversation`,i=n>=0&&t.restore!==`files`,a=i?e.entries.map((e,t)=>t<n||e.rewound?e:{...e,rewound:!0}):e.entries;return{...e,...i?{todoList:hn(a,e.todoList)}:{},entries:[...a,{kind:`marker`,id:`rewound-${e.entries.length}`,marker:`rewound`,text:r}]}}case`forked`:return{...e,entries:[...e.entries,{kind:`marker`,id:`forked-${e.entries.length}`,marker:`forked`,text:`Forked`,fromSessionId:t.fromSessionId}]};case`revived`:return{...e,...t.scope===void 0?{}:{scope:t.scope},lifecycle:`live`,turnInFlight:!1,entries:[...e.entries,{kind:`marker`,id:`revived-${t.fromSeq}`,marker:`revived`,text:`Revived from seq ${t.fromSeq}`}]};case`session_ended`:return{...e,lifecycle:`ended`,turnInFlight:!1,endedReason:t.reason,asking:void 0,authorising:void 0}}}function un(e){if(!e.compacting)return e;let{compacting:t,...n}=e;return n}function dn(e,t,n){let r=e===`auto`?`Compacted automatically`:`Compacted`;return n===void 0?`${r}, from ${Jt(t)} tokens`:`${r}, ${Jt(t)} → ${Jt(n)} tokens`}function fn(e){return e.state===`asked`?`asked`:e.state===`aborted`||e.decision===`deny`?`denied`:e.decision===`always`?`always`:`allowed`}function pn(e,t){let n=e.find(e=>e.kind===`tool`&&e.id!==t&&e.authorisation===`asked`);return n?.kind===`tool`?{callId:n.id,tool:n.name,...n.permissionContext===void 0?{}:{context:n.permissionContext},...n.allowAlways===void 0?{}:{allowAlways:n.allowAlways},...n.authorizationScope===void 0?{}:{authorizationScope:n.authorizationScope},...n.producer===void 0?{}:{producer:n.producer}}:void 0}function mn(e,t){return e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.content===r.content&&e.status===r.status&&e.priority===r.priority})}function hn(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(!(r.kind!==`tool`||r.rewound||r.todos===void 0))return r.todos.length===0?void 0:t!==void 0&&mn(t,r.todos)?t:r.todos}}function gn(e){return e.producer===void 0?{}:{producer:e.producer}}function _n(e,t){let n=e.findIndex(e=>e.kind===t.kind&&e.id===t.id);if(n<0)return[...e,t];let r=[...e];return r[n]=t,r}function vn(e,t,n){let r=e.findIndex(e=>e.kind===`tool`&&e.id===t);if(r<0)return e;let i=e[r];if(!i||i.kind!==`tool`)return e;let a=[...e];return a[r]=n(i),a}var H=e(be(),1),yn=e(E(),1);function bn(e){return`${e.kind}:${e.id}`}var U=Re();function xn(e,t){let n=/\/worktrees\/([^/]+)\/[^/]+$/.exec(e)?.[1];return n===void 0?void 0:t.find(e=>e.name===n)?.path}var Sn=rt(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Cn=rt(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),wn=rt(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Tn=rt(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),En=rt(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]]),Dn=rt(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),On=rt(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),kn=rt(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),An=rt(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),jn=rt(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Mn=rt(`folder-search`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),Nn=rt(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Pn=rt(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Fn=rt(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),In=rt(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ln=rt(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Rn=rt(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),zn=rt(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Bn=rt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Vn=rt(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Hn=rt(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Un=rt(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Wn=rt(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Gn(e){let t=e.trim();return t.startsWith(`/`)||t.startsWith(`~`)?`completion`:`search`}function Kn(e){return e.trim()!==``}function qn(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.group===n.group){e.items.push(n);continue}t.push({group:n.group,items:[n]})}return t}function Jn(e,t){if(t===void 0||t===``)return e;let n=t.endsWith(`/`)?t:`${t}/`;if(!e.startsWith(n))return e;let r=e.slice(n.length);return r===``?e:r}function Yn(e,t){return t!=null&&!x(t)?0:typeof e==`function`?e():e}function Xn(e,t,n){let r=Yn(e,n);return typeof r==`number`?r:r?.[t]}function Zn(e){return typeof e==`function`?e():e}function Qn(e,t){return t||e===`click`||e===`mousedown`}function $n(e){return e?.includes(`mouse`)&&e!==`mousedown`}var er=H.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new ie,currentIdRef:{current:null},currentContextRef:{current:null}});function tr(e,t){e.current=t.current}function nr(e){let{children:t,delay:n,timeoutMs:r=0}=e,i=H.useRef(n),a=H.useRef(n),o=H.useRef(null),s=H.useRef(null),c=Be();return V(()=>{if(a.current=n,!o.current){i.current=n;return}i.current={open:Xn(i.current,`open`),close:Xn(n,`close`)}},[n,o,i,a]),(0,U.jsx)(er.Provider,{value:H.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:a,currentIdRef:o,timeoutMs:r,currentContextRef:s,timeout:c}),[r,c]),children:t})}function rr(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:l,hasProvider:u,timeout:f}=H.useContext(er),[p,m]=H.useState(!1),h=H.useRef(n);return V(()=>{h.current=n},[n]),V(()=>{function e(){l.current?.setIsInstantPhase(!1),a.current=null,l.current=null,o.current=c.current,f.clear()}if(a.current&&!n&&a.current===i){if(m(!1),s){let t=i;return f.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(h.current||a.current!==t)&&f.clear()}}e()}},[n,i,a,o,s,c,l,f,r]),V(()=>{if(!n)return;let e=l.current,t=a.current;f.clear(),l.current={onOpenChange:r.setOpen,setIsInstantPhase:m},a.current=i,o.current={open:0,close:Xn(c.current,`close`)},t!==null&&t!==i?(m(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,d(F))):(m(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,l,f]),V(()=>()=>{if(a.current===i){if(l.current=null,!h.current)return;a.current=null,tr(o,c),f.clear()}},[l,a,o,i,c,f]),H.useMemo(()=>({hasProvider:u,delayRef:o,isInstantPhase:p}),[u,o,p])}function ir(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function ar(e){return e!=null&&e.clientX!=null}function or(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,l=H.useRef(!1),u=H.useRef(null),[d,f]=H.useState(),[p,m]=H.useState([]),h=A(e=>{i.set(`positionReference`,e)}),g=A((e,t,n)=>{l.current||c.current.openEvent&&!ar(c.current.openEvent)||i.set(`positionReference`,ir(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:d}))}),_=A(e=>{a?u.current||(g(e.clientX,e.clientY,e.currentTarget),m([])):g(e.clientX,e.clientY,e.currentTarget)}),v=x(d)?o:a;H.useEffect(()=>{if(!n){h(s);return}if(!v)return;function e(){u.current?.(),u.current=null}let t=ae(o);function r(t){let n=Ae(t);Te(o,n)?e():g(t.clientX,t.clientY)}return!c.current.openEvent||ar(c.current.openEvent)?u.current=Le(t,`mousemove`,r):h(s),e},[v,n,o,c,s,i,g,h,p]),H.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),H.useEffect(()=>{n&&!o&&(l.current=!1)},[n,o]),H.useEffect(()=>{!n&&a&&(l.current=!0)},[n,a]);let y=H.useMemo(()=>{function e(e){f(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:_,onMouseEnter:_}},[_]);return H.useMemo(()=>n?{reference:y,trigger:y}:{},[n,y])}function sr(){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Ft,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function cr(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:sr(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:L,inactiveTriggerProps:L,popupProps:L}}function lr(e,t,n=!1){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0})}var ur=e=>e.triggerIdProp??e.activeTriggerId,dr=e=>e.openProp??e.open,fr=e=>(e.popupElement?.id??e.floatingId)||void 0;function pr(e,t){return t!==void 0&&dr(e)&&ur(e)===t}function mr(e,t){return pr(e,t)?!0:t!==void 0&&dr(e)&&ur(e)==null&&e.triggerCount===1}var hr={open:dr,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ur,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:fr,isTriggerActive:(e,t)=>t!==void 0&&ur(e)===t,isOpenedByTrigger:(e,t)=>pr(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ur(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>mr(e,t)?fr(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},gr=S();function _r(e){let t=H.useCallback(t=>e===void 0?h:e.subscribeStore(t),[e]),n=H.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,gr.useSyncExternalStore)(t,n,()=>e?.serverStore)}var vr=He&&fe;function yr(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=H.useRef(!1),c=H.useRef(null),l=H.useRef(!0),u=Be();H.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=ae(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&se(e)&&e===re(b(e))&&(s.current=!0)}function a(){l.current=!0}function o(){l.current=!1}return P(Le(t,`blur`,r),vr&&Le(t,`keydown`,a,!0),vr&&Le(t,`pointerdown`,o,!0))},[i,n]),H.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);Fe(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let f=H.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=Ae(t.nativeEvent);if(Fe(a)){if(vr&&!t.relatedTarget){if(!l.current&&!Oe(a))return}else if(!ge(a))return}let o=Ne(t.relatedTarget,i.context.triggerElements),{nativeEvent:f,currentTarget:p}=t,m=typeof r==`function`?r():r;if(i.select(`open`)&&o||m===0||m===void 0){i.setOpen(!0,d(De,f,p));return}u.start(m,()=>{s.current||i.setOpen(!0,d(De,f,p))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=Fe(n)&&n.hasAttribute(N(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=re(b(e));!n&&t===e||Te(o.current.floatingContext?.refs.floating.current,t)||Te(e,t)||a||Ne(n??t,i.context.triggerElements)||i.setOpen(!1,d(De,r))})}}},[o,r,i,u]);return H.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}var br=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ie,this.restTimeout=new ie,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},xr=new WeakMap;function Sr(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&xr.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),xr.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Cr(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=xr.get(n);a&&a!==e&&Sr(a),Sr(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,xr.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function wr(e){let t=e.context.dataRef.current,n=a(()=>t.hoverInteractionState??br.create()).current;return t.hoverInteractionState||=n,w(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function Tr(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,s=a.useState(`open`),c=a.useState(`floatingElement`),l=a.useState(`domReferenceElement`),{dataRef:u}=a.context,f=Xe(),p=Qe(),m=wr(a),h=Be(),g=A(()=>Qn(u.current.openEvent?.type,m.interactedInside)),v=A(()=>$n(u.current.openEvent?.type)),y=A(()=>{Sr(m)});V(()=>{s||(m.pointerType=void 0,m.restTimeoutPending=!1,m.interactedInside=!1,y())},[s,m,y]),H.useEffect(()=>y,[y]),V(()=>{if(n&&s&&m.handleCloseOptions?.blockPointerEvents&&v()&&Fe(l)&&c){let e=l,t=c,n=b(c),r=f?.nodesRef.current.find(e=>e.id===p)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=m.pointerEventsScopeElement===t?null:m.pointerEventsScopeElement,a=r===t?null:r,o=m.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return Cr(m,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{y()}}},[n,s,l,c,m,v,f,p,y]),H.useEffect(()=>{if(!n)return;function e(){return!!(f&&p&&qe(f.nodesRef.current,p).length>0)}function t(e){let t=Xn(r,`close`,m.pointerType),n=()=>{a.setOpen(!1,d(_,e)),f?.events.emit(`floating.closed`,e)};t?m.openChangeTimeout.start(t,n):(m.openChangeTimeout.clear(),n())}function s(e){let t=Ae(e);if(!o(t)){m.interactedInside=!1;return}m.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function l(){m.openChangeTimeout.clear(),h.clear(),f?.events.off(`floating.closed`,x),y()}function b(n){if(e()&&f){f.events.on(`floating.closed`,x);return}if(Ne(n.relatedTarget,a.context.triggerElements))return;let r=u.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(f&&r&&Fe(o)&&qe(f.nodesRef.current,r,!1).some(e=>Te(e.context?.elements.floating,o)))){if(m.handler){m.handler(n);return}y(),v()&&!g()&&t(n)}}function x(t){!f||!p||e()||h.start(0,()=>{f.events.off(`floating.closed`,x),a.setOpen(!1,d(_,t)),f.events.emit(`floating.closed`,t)})}let S=c;return P(S&&Le(S,`mouseenter`,l),S&&Le(S,`mouseleave`,b),S&&Le(S,`pointerdown`,s,!0),()=>{f?.events.off(`floating.closed`,x)})},[n,c,a,u,r,i,v,g,y,m,f,p,h])}var Er={current:null};function Dr(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=Er,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:f,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,g=`rootStore`in e?e.rootStore:e,{dataRef:v,events:y}=g.context,S=Xe(l),C=wr(g),w=H.useRef(!1),T=Dt(i),E=Dt(r),D=Dt(o),O=Dt(n),k=Dt(m),j=Dt(p),M=A(()=>Qn(v.current.openEvent?.type,C.interactedInside)),N=A(()=>k.current?.()!==!1),F=A((e,t,n)=>{let r=g.context.triggerElements;if(r.hasElement(t))return!e||!Te(e,t);if(!Fe(n))return!1;let i=n;return r.hasMatchingElement(e=>Te(e,i))&&(!e||!Te(e,i))}),I=A(()=>{C.handler&&=(b(g.select(`domReferenceElement`)).removeEventListener(`mousemove`,C.handler),void 0)}),L=A(()=>{Sr(C)});return u&&(C.handleCloseOptions=T.current?.__options),H.useEffect(()=>I,[I]),H.useEffect(()=>{if(!n)return;function e(e){e.open?w.current=!1:(w.current=e.reason===_,I(),C.openChangeTimeout.clear(),C.restTimeout.clear(),C.blockMouseMove=!0,C.restTimeoutPending=!1)}return y.on(`openchange`,e),()=>{y.off(`openchange`,e)}},[n,y,C,I]),H.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=Xn(E.current,`close`,C.pointerType);n?C.openChangeTimeout.start(n,()=>{g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e)}):t&&(C.openChangeTimeout.clear(),g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e))}let t=c.current??(u?g.select(`domReferenceElement`):null);if(!Fe(t))return;function r(e){if(C.openChangeTimeout.clear(),C.blockMouseMove=!1,a&&!x(C.pointerType))return;let t=Zn(D.current),n=Xn(E.current,`open`,C.pointerType),r=Ae(e),i=e.currentTarget??null,o=g.select(`domReferenceElement`),s=i;if(Fe(r)&&!g.context.triggerElements.hasElement(r)){for(let e of g.context.triggerElements.elements())if(Te(e,r)){s=e;break}}Fe(i)&&Fe(o)&&!g.context.triggerElements.hasElement(i)&&Te(i,o)&&(s=o);let c=s!=null&&F(o,s,r),l=g.select(`open`),u=j.current?.()??g.select(`transitionStatus`)===`ending`,f=!l&&u&&w.current,p=!c&&Fe(s)&&Fe(o)&&Te(o,s)&&f,m=t>0&&!n,h=c&&(l||f)||p,v=!l||c;if(h){N()&&g.setOpen(!0,d(_,e,s));return}m||(n?C.openChangeTimeout.start(n,()=>{v&&N()&&g.setOpen(!0,d(_,e,s))}):v&&N()&&g.setOpen(!0,d(_,e,s)))}function i(t){if(M()){L();return}I();let n=g.select(`domReferenceElement`),r=b(n);C.restTimeout.clear(),C.restTimeoutPending=!1;let i=v.current.floatingContext??f?.();if(!Ne(t.relatedTarget,g.context.triggerElements)){if(T.current&&i){g.select(`open`)||C.openChangeTimeout.clear();let n=c.current;C.handler=T.current({...i,tree:S,x:t.clientX,y:t.clientY,onClose(){L(),I(),O.current&&!M()&&n===g.select(`domReferenceElement`)&&e(t,!0)}}),r.addEventListener(`mousemove`,C.handler),C.handler(t);return}(C.pointerType!==`touch`||!Te(g.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Te(t,e.relatedTarget)||(C.openChangeTimeout.clear(),C.restTimeout.clear(),C.restTimeoutPending=!1)}let l=h?Le(t,`mouseout`,o):void 0;return s?P(Le(t,`mousemove`,r,{once:!0}),Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l):P(Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l)},[I,L,v,E,g,n,T,C,u,F,M,a,s,D,c,S,O,f,j,N,h]),H.useMemo(()=>{if(!n)return;function e(e){C.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=g.select(`domReferenceElement`),i=g.select(`open`),o=F(r,n,e.target);if(a&&!x(C.pointerType))return;if(i&&o&&C.handleCloseOptions?.blockPointerEvents){let e=g.select(`floatingElement`);if(e){let t=C.handleCloseOptions?.getScope?.()??n.ownerDocument.body;Cr(C,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=Zn(D.current);if(i&&!o||s===0||!o&&C.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;C.restTimeout.clear();function c(){if(C.restTimeoutPending=!1,M())return;let e=g.select(`open`);!C.blockMouseMove&&(!e||o)&&N()&&g.setOpen(!0,d(_,t,n))}C.pointerType===`touch`?yn.flushSync(()=>{c()}):o&&i?c():(C.restTimeoutPending=!0,C.restTimeout.start(s,c))}}},[n,C,M,F,a,g,D,N])}var Or=.1,kr=Or*Or,Ar=.5;function jr(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Mr(e,t,n,r,i,a,o,s,c,l){let u=!1;return jr(e,t,n,r,i,a)&&(u=!u),jr(e,t,i,a,o,s)&&(u=!u),jr(e,t,o,s,c,l)&&(u=!u),jr(e,t,c,l,n,r)&&(u=!u),u}function Nr(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Pr(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function Fr(e={}){let{blockPointerEvents:t=!1}=e,n=new ie,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*kr;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Ae(r),g=r.type===`mouseleave`,_=Te(u,h),v=Te(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Fe(r.relatedTarget)&&Te(u,r.relatedTarget))return;function y(){return!!(s&&qe(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=Pr(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Pr(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Pr(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Pr(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Nr(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Ar/2:Ar*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Ar+1,o=C||T?S.bottom-Ar:S.top,s=C?T?S.bottom-Ar:S.top:S.bottom-Ar;M=Mr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Ar/2:Ar*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Ar,o=C||T?S.top+Ar:S.bottom,s=C?T?S.top+Ar:S.bottom:S.top+Ar;M=Mr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Ar/2:Ar*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Ar+1,o=w||E?S.right-Ar:S.left,s=w?E?S.right-Ar:S.left:S.right-Ar;M=Mr(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Ar/2:Ar*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Ar,o=w||E?S.left+Ar:S.right,s=w?E?S.left+Ar:S.right:S.left+Ar;M=Mr(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function Ir(){let{config:e,refresh:t}=Ue(),{save:n,saving:r}=Ve(),i=e.projectList??[],a=e.projectCandidates??[],o=e.projects?.root??``,s=e.projects?.include??[],c=(0,H.useCallback)((e,r)=>{(async()=>{await n({projects:{include:e}},r)&&await t()})()},[n,t]),l=t=>{let n=Jn(t,e.projects?.root===void 0?void 0:e.scope);s.includes(n)||c([...s,n],`Project added.`)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Lr,{included:i,onRemove:e=>c(s.filter((t,n)=>n!==e),`Project removed.`)}),(0,U.jsx)(Rr,{candidates:a,hasRoot:e.projects?.root!==void 0,onAdd:l}),(0,U.jsx)(Br,{onAdd:l}),(0,U.jsx)(Vr,{current:o,saving:r,onSave:n,onSaved:t}),(0,U.jsxs)(Ie,{title:`Worktrees`,description:`Machine-wide.`,children:[(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Always start new Agent Sessions in a Worktree`}),(0,U.jsx)(dt,{checked:e.worktrees?.always===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{always:e}},e?`New Agent Sessions start in a Worktree.`:`New Agent Sessions start in the Project.`)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Update the Source Branch before cutting a Worktree`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Fast-forwards the branch from its upstream in the Project. If this fails, the Worktree is cut from the local branch and a warning is shown.`})]}),(0,U.jsx)(dt,{checked:e.worktrees?.updateSource===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{updateSource:e}},e?`Source Branches are updated before a Worktree is cut.`:`Worktrees are cut from the local branch.`)})]})]})]})}function Lr({included:e,onRemove:t}){return(0,U.jsx)(Ie,{title:`Projects · ${e.length}`,description:e.length===0?`Nothing yet. A Project is one you have opted into — add one below, and it becomes an option in the New Agent Session view.`:`What the New Agent Session view offers, in this order.`,children:e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,n)=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.group===void 0?e.name:`${e.group}/${e.name}`}),e.missing?(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`directory is gone`}):null]}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.path}),(0,U.jsx)(O,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.name}`,onClick:()=>t(n),children:(0,U.jsx)(Wn,{"aria-hidden":!0})})]})]},e.path))})})}function Rr({candidates:e,hasRoot:t,onAdd:n}){return t?(0,U.jsx)(Ie,{title:`Found beneath the Project Root · ${e.length}`,description:`Repositories Flow can see but is not offering. Add the ones you work in.`,children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing left to add. Either everything found is already a Project, or the Project Root holds no git repositories within three levels.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:qn(e).map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.group===void 0?null:(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.group}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.items.map(e=>(0,U.jsxs)(O,{variant:`outline`,size:`sm`,className:`font-mono text-xs font-normal`,onClick:()=>n(e.path),children:[(0,U.jsx)(zn,{"aria-hidden":!0}),e.name]},e.path))})]},e.group??``))})}):null}function zr(e){let[t,n]=(0,H.useState)(void 0),r=(0,H.useRef)(``);return(0,H.useEffect)(()=>{if(r.current=e,!Kn(e)){n(void 0);return}let t=new AbortController,i=setTimeout(()=>{(async()=>{try{let i=await p(`/api/directories?q=${encodeURIComponent(e)}`,{signal:t.signal});if(!i.ok)return;let a=await i.json();a.query===r.current&&n(a)}catch{}})()},150);return()=>{t.abort(),clearTimeout(i)}},[e]),t}function Br({onAdd:e}){let[t,n]=(0,H.useState)(``),r=zr(t),i=Gn(t);return(0,U.jsxs)(Ie,{title:`Add any directory`,description:(0,U.jsxs)(U.Fragment,{children:[`Type a name to search beneath the Project Root — repositories included, so`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`packages/api`}),` inside a monorepo is reachable. Start with `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`/`}),` or`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),` to complete a path anywhere on this machine instead.`]}),children:[(0,U.jsx)(he,{className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`api, or /home/you/elsewhere`,spellCheck:!1}),r===void 0?null:r.paths.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i===`completion`?`No directory there.`:`Nothing beneath the Project Root matches.`}):(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsxs)(`span`,{className:`pb-1 text-xs text-muted-foreground`,children:[i===`completion`?`Directories here`:`Found beneath the Project Root`,r.truncated?` — showing the first few, keep typing`:null]}),r.paths.map(t=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b py-1 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t}),(0,U.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>{e(t),n(``)},children:[(0,U.jsx)(zn,{"aria-hidden":!0}),`Add`]})]},t))]})]})}function Vr({current:e,saving:t,onSave:n,onSaved:r}){let[i,a]=(0,H.useState)(e);return(0,H.useEffect)(()=>a(e),[e]),(0,U.jsxs)(Ie,{title:`Project Root`,description:(0,U.jsxs)(U.Fragment,{children:[`The directory Flow looks beneath for candidates, and the one it reports as its default Scope. Absolute, or starting with`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),`. A Project outside it can still be added by path.`]}),children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Where your repositories live`}),(0,U.jsx)(he,{className:`font-mono`,value:i,onChange:e=>a(e.target.value),placeholder:`~/workspace`,spellCheck:!1})]}),(0,U.jsx)(de,{dirty:i.trim()!==e,saving:t,onSave:()=>{(async()=>{let e=i.trim()===``?`Project Root cleared.`:`Project Root saved.`;await n({projects:{root:i.trim()}},e)&&await r()})()},onReset:()=>a(e)})]})}var Hr=H.createContext(void 0);function Ur(e){let t=H.useContext(Hr);if(!e&&t===void 0)throw Error(B(27));return t}var Wr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Ur(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`),d={open:c,transitionStatus:s.useState(`transitionStatus`)};return j(`div`,e,{state:d,ref:[s.context.backdropRef,t],stateAttributesMapping:pt,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),Gr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...c}=e,l=Ur(),u=l.useState(`open`),{getButtonProps:f,buttonRef:p}=R({disabled:a,native:o}),m={disabled:a};function h(e){u&&l.setOpen(!1,d(s,e.nativeEvent))}return j(`button`,e,{state:m,ref:[t,p],props:[{onClick:h},c,f]})}),Kr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Ur(),c=xe(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),j(`p`,e,{ref:t,props:[{id:c},o]})}),qr=H.createContext(void 0);function Jr(){let e=H.useContext(qr);if(e===void 0)throw Error(B(26));return e}var Yr={...$e,...Ee,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},Xr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=Ur(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);Jr(),we({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?_t(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=j(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...wt,hidden:!m,onKeyDown(e){st.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Yr});return(0,U.jsx)(ct,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),Zr=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Ur(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,U.jsx)(qr.Provider,{value:n,children:(0,U.jsxs)(u,{ref:t,...r,children:[a&&o===!0&&(0,U.jsx)(nt,{ref:i.context.internalBackdropRef,inert:Me(!s)}),e.children]})}):null});function Qr({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=H.useState(0),[u,d]=H.useState(0),f=c===0,p=gt(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Ae(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Te(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return tt(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),V(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),bt(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var $r={...hr,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},ei=class extends f{constructor(e,t,n){let r=new Ft,i=ti(e,r,t,n);super(i,ni(r),$r)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e};Ot(n,e,t.trigger),this.update(n)}};function ti(e,t,n,r=!1){let i={...cr(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e};return i.floatingRootContext=lr(t,n,r),i}function ni(e){return{popupRef:H.createRef(),backdropRef:H.createRef(),internalBackdropRef:H.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function ri(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:f,defaultTriggerId:p=null}=t,m=e===`drawer`,h=e===`alert-dialog`,g=h?!0:c,_=h||s,v=h?`alertdialog`:`dialog`,y=Ur(!0),b={modal:g,disablePointerDismissal:_,nested:y!=null,role:v},x=Nt((e,t)=>new ei({open:i,openProp:r,activeTriggerId:p,triggerIdProp:f,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,f),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);kt(x,S),Bt(x);let{forceUnmount:T}=vt(S,x);H.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,d(D))}),[T,x]);let E=S||C;return(0,U.jsxs)(Hr.Provider,{value:x,children:[u&&(0,U.jsx)(ht,{handle:u,store:x}),E&&(0,U.jsx)(Qr,{store:x,parentContext:y?.context,isDrawer:m}),typeof n==`function`?n({payload:w}):n]})}function ii(e){return ri(`dialog`,e)}var ai=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Ur(),c=xe(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),j(`h2`,e,{ref:t,props:[{id:c},o]})}),oi=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=Ur(!0),f=_r(l)??d;if(!f)throw Error(B(79));let p=xe(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=H.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=St(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=R({disabled:a,native:o}),S=Ut(m),C=Tt(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return j(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[k]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:mt})});function si({...e}){return(0,U.jsx)(ii,{"data-slot":`dialog`,...e})}function ci({...e}){return(0,U.jsx)(oi,{"data-slot":`dialog-trigger`,...e})}function li({...e}){return(0,U.jsx)(Zr,{"data-slot":`dialog-portal`,...e})}function ui({className:e,...t}){return(0,U.jsx)(Wr,{"data-slot":`dialog-overlay`,className:g(`fixed inset-0 isolate z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function di({className:e,children:t,showCloseButton:n=!0,...r}){return(0,U.jsxs)(li,{children:[(0,U.jsx)(ui,{}),(0,U.jsxs)(Xr,{"data-slot":`dialog-content`,className:g(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-[min(var(--radius-4xl),calc(24px*var(--radius-scale)))] bg-popover p-6 text-sm text-popover-foreground shadow-xl ring-1 ring-foreground/5 duration-100 outline-none sm:max-w-md dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,U.jsxs)(Gr,{"data-slot":`dialog-close`,render:(0,U.jsx)(O,{variant:`ghost`,className:`absolute top-4 right-4 bg-secondary`,size:`icon-sm`}),children:[(0,U.jsx)(Wn,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function fi({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`dialog-header`,className:g(`flex flex-col gap-1.5`,e),...t})}function pi({className:e,showCloseButton:t=!1,children:n,...r}){return(0,U.jsxs)(`div`,{"data-slot":`dialog-footer`,className:g(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,U.jsx)(Gr,{render:(0,U.jsx)(O,{variant:`outline`}),children:`Close`})]})}function mi({className:e,...t}){return(0,U.jsx)(ai,{"data-slot":`dialog-title`,className:g(`font-heading text-base leading-none font-medium`,e),...t})}function hi({className:e,...t}){return(0,U.jsx)(Kr,{"data-slot":`dialog-description`,className:g(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function gi({session:e,onClose:t}){let{connection:n,config:r}=Ue(),[i,a]=(0,H.useState)(e.suggestedScope??``),[o,s]=(0,H.useState)(()=>xn(e.scope,r.projectList??[])??``),[c,l]=(0,H.useState)(void 0),[u,d]=(0,H.useState)(!1),f=i.trim()!==``&&(!e.worktree||o.trim()!==``),p=async()=>{d(!0),l(void 0);try{await n.command({type:`relocate`,sessionId:e.id,scope:i.trim(),...e.worktree?{repo:o.trim()}:{}}),await n.command({type:`revive`,sessionId:e.id}),t()}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,U.jsx)(si,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,U.jsxs)(di,{className:`sm:max-w-lg`,children:[(0,U.jsxs)(fi,{children:[(0,U.jsx)(mi,{children:`Relocate Agent Session`}),(0,U.jsx)(hi,{children:`Its Scope no longer exists. Choose where its files are now.`})]}),(0,U.jsx)(ne,{label:`Old Scope`,children:e.scope}),(0,U.jsx)(_i,{label:`Scope`,value:i,onChange:a}),e.worktree?(0,U.jsx)(_i,{label:`Repository`,value:o,onChange:s}):null,c===void 0?null:(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:c}),(0,U.jsxs)(pi,{children:[(0,U.jsx)(O,{variant:`outline`,onClick:t,children:`Cancel`}),(0,U.jsx)(O,{disabled:!f||u,onClick:()=>void p(),children:`Relocate and revive`})]})]})})}function _i({label:e,value:t,onChange:n}){let r=zr(t),i=(0,H.useId)();return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:e}),(0,U.jsx)(he,{id:i,className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`/path/to/folder`,spellCheck:!1}),r?.paths.filter(e=>e!==t).slice(0,5).map(e=>(0,U.jsx)(O,{variant:`ghost`,size:`sm`,className:`justify-start font-mono text-xs`,onClick:()=>n(e),children:e},e))]})}var vi=new Map;function yi(e,t){vi.set(e,structuredClone(t))}function bi(e){let t=vi.get(e);return t&&structuredClone(t)}function xi(e){vi.delete(e)}function Si(e){for(let t of vi.keys())e.has(t)||vi.delete(t)}var Ci=2e3,wi=3e4,Ti=(0,H.createContext)(void 0);function Ei(){let e=(0,H.useContext)(Ti);if(!e)throw Error(`useAgentSessions outside SessionsProvider`);return e}function Di({children:e}){let{connection:t}=Ue(),[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(void 0),c=(0,H.useRef)(()=>{});(0,H.useEffect)(()=>{let e=!1,n,i,o=0,s=0,l=0,u=e=>{n&&clearTimeout(n),n=setTimeout(()=>void d(),e)},d=async()=>{if(e||document.hidden)return;i?.abort(),i=new AbortController;let n=++o;try{let i=await t.listSessions();if(e||n<=s)return;s=n,l=0,Si(new Set(i.map(e=>e.id))),r(i),a(!0),u(Ci)}catch{if(e)return;a(!0),l+=1,u(Math.min(wi,Ci*2**l))}},f=()=>{document.hidden||d()};return c.current=()=>void d(),d(),document.addEventListener(`visibilitychange`,f),()=>{e=!0,c.current=()=>{},n&&clearTimeout(n),i?.abort(),document.removeEventListener(`visibilitychange`,f)}},[t]);let l=(0,H.useCallback)(()=>c.current(),[]),u=n.find(e=>e.id===o);return(0,U.jsxs)(Ti.Provider,{value:{sessions:n,loaded:i,nudge:l,relocate:s},children:[e,u?(0,U.jsx)(gi,{session:u,onClose:()=>{s(void 0),l()}}):null]})}function Oi(){let{connection:e}=Ue(),{nudge:t,relocate:n}=Ei();return(0,H.useCallback)(async r=>{try{let n=await e.command(r);return t(),n}catch(e){if(e.code===`scope_missing`&&`sessionId`in r&&r.sessionId!==void 0){n(r.sessionId),t();return}ze.error(`${r.type} failed`,e instanceof Error?e.message:String(e)),t();return}},[e,t,n])}var ki=[`general`,`projects`,`permissions`,`providers`,`appearance`,`keyboard`,`workflows`,`secrets`,`mcp`],Ai={sessionId:void 0};function ji(e){let[t=``,n=``]=e.replace(/^#\/?/,``).split(`?`,2),r=t.split(`/`).filter(e=>e!==``);if(r[0]===`settings`)return{sessionId:void 0,settings:Pi(r[1])};let i=Mi(r),a=new URLSearchParams(n).get(`settings`);return a===null?i:{...i,settings:Pi(a)}}function Mi(e){if(e[0]===`spend`)return{sessionId:void 0,spend:!0};if(e[0]===`pull-requests`){let t=Fi(e[1]??``),n=Number(e[2]);return t?Number.isSafeInteger(n)&&n>0?{sessionId:void 0,pullRequests:!0,project:t,pullRequest:n}:{sessionId:void 0,pullRequests:!0,project:t}:{sessionId:void 0,pullRequests:!0}}if(e[0]===`schedules`){let t={sessionId:void 0,schedules:!0};if(e[1]===`occurrences`){let n=Fi(e[2]??``);return n?{...t,occurrenceId:n}:t}let n=Fi(e[1]??``);return n?{...t,scheduleId:n}:t}if(e[0]===`new`&&e[1])return{sessionId:void 0,backend:Fi(e[1])};if(e[0]!==`s`||e[1]===void 0)return Ai;let t=Fi(e[1]);return{sessionId:t===``?void 0:t}}function Ni(e){let t=e.spend?`#/spend`:e.pullRequests?`#/pull-requests${e.project?`/${encodeURIComponent(e.project)}${e.pullRequest?`/${e.pullRequest}`:``}`:``}`:e.schedules?`#/schedules${e.occurrenceId?`/occurrences/${encodeURIComponent(e.occurrenceId)}`:e.scheduleId?`/${encodeURIComponent(e.scheduleId)}`:``}`:e.sessionId===void 0?e.backend?`#/new/${encodeURIComponent(e.backend)}`:``:`#/s/${encodeURIComponent(e.sessionId)}`;return e.settings===void 0?t:`${t||`#/`}?settings=${e.settings}`}function Pi(e){return ki.find(t=>t===Fi(e??``))??ki[0]}function Fi(e){try{return decodeURIComponent(e)}catch{return``}}function Ii(e){return e.title||e.id}var Li=60,Ri=[{key:`description`,shape:`text`},{key:`command`,shape:`text`},{key:`questions`,shape:`questions`},{key:`file_path`,shape:`path`},{key:`notebook_path`,shape:`path`},{key:`pattern`,shape:`text`},{key:`url`,shape:`text`},{key:`query`,shape:`text`},{key:`path`,shape:`path`},{key:`prompt`,shape:`text`}],zi=Ri.filter(({key:e})=>e!==`description`);function Bi(e){return Hi(e,Li)}function Vi(e){return Hi(e,1/0,zi)}function Hi(e,t,n=Ri){if(!e||typeof e!=`object`)return;let r=e;for(let e of n){let n=r[e.key];if(e.shape===`questions`){let e=Ui(n,t);if(e!==void 0)return e;continue}if(typeof n==`string`&&n.trim()!==``)return e.shape===`path`?Gi(n.trim(),t):Wi(n,t)}let i=Object.values(r).filter(e=>typeof e==`string`),a=i.length===1?i[0]:void 0;return a&&a.trim()!==``?Wi(a,t):void 0}function Ui(e,t){if(!Array.isArray(e)||e.length===0)return;let n=e[0];if(!n||typeof n!=`object`)return;let r=n.question;if(typeof r!=`string`||r.trim()===``)return;let i=e.length-1;return Wi(i>0?`${r} (+${i} more)`:r,t)}function Wi(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Gi(e,t){return e.length<=t?e:`…${e.slice(-(t-1))}`}var Ki=H.createContext(void 0);function qi(e){let t=H.useContext(Ki);if(t===void 0&&!e)throw Error(B(72));return t}var Ji={...hr,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Yi=class extends f{constructor(e,t,n){let r=new Ft;super(Xi(e,r,t,n),Zi(r),Ji)}setOpen=(e,t)=>{Mt(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,d(z,e))}};function Xi(e,t,n,r=!1){let i={...cr(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e};return i.floatingRootContext=lr(t,n,r),i}function Zi(e){return{popupRef:H.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var Qi=ye(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:f=null,children:p}=e,m=Nt((e,t)=>new Yi({open:n,openProp:r,activeTriggerId:f,triggerIdProp:u},e,t));m.useControlledProp(`openProp`,r),m.useControlledProp(`triggerIdProp`,u),m.useContextCallback(`onOpenChange`,s),m.useContextCallback(`onOpenChangeComplete`,c);let h=m.useState(`open`),g=!t&&h,_=m.useState(`activeTriggerId`),v=m.useState(`mounted`),y=m.useState(`payload`);m.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Bt(m,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=vt(g,m),S=m.useState(`isInstantPhase`),C=m.useState(`instantType`),w=m.useState(`lastOpenChangeReason`),T=H.useRef(null);V(()=>{h&&t&&m.setOpen(!1,d(_e))},[h,t,m]),V(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),m.set(`instantType`,`delay`)):T.current!==null&&(m.set(`instantType`,T.current),T.current=null)},[x,S,w,C,m]),V(()=>{g&&(_??m.set(`payload`,void 0))},[m,_,g]),H.useImperativeHandle(o,()=>({unmount:b,close:()=>m.setOpen(!1,d(D))}),[b,m]);let E=g||v||!t&&a!==`none`;return(0,U.jsxs)(Ki.Provider,{value:m,children:[l&&(0,U.jsx)(ht,{handle:l,store:m}),E&&(0,U.jsx)($i,{store:m,disabled:t,trackCursorAxis:a}),typeof p==`function`?p({payload:y}):p]})});function $i({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=gt(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=or(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=H.useMemo(()=>ee(a.reference,i.reference),[a.reference,i.reference]);return bt(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??L}),null}var ea=H.createContext(void 0);function ta(){return H.useContext(ea)}var na=`data-base-ui-tooltip-trigger`;function ra(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(Fe(n))return n}}let t=e.target;return Fe(t)?t:null}function ia(e){let t=e;for(;t;){let e=t.closest(`[${na}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&Fe(n.host)?n.host:null}return null}var aa=c(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:f,...p}=e,m=qi(!0),h=_r(a)??m;if(!h)throw Error(B(82));let g=xe(f),v=h.useState(`isTriggerActive`,g),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`floatingRootContext`),S=H.useRef(null),C=c??600,w=u??0,{registerTrigger:T,isMountedByThisTrigger:E}=St(g,S,h,{payload:o,closeOnClick:l,closeDelay:w}),D=ta(),{delayRef:O,isInstantPhase:k,hasProvider:A}=rr(b,{open:y}),M=wr(b);h.useSyncedValue(`isInstantPhase`,k);let N=h.useState(`disabled`),P=s??N,F=Dt(P),I=h.useState(`trackCursorAxis`),L=h.useState(`disableHoverablePopup`),R=H.useRef(!1),ee=Be(),z=H.useRef(void 0);function te(){return A?Xn(O.current,`open`)===0?0:c??D??600:C}function V(e){let t=S.current;if(!t||!e)return!1;let n=ia(e);return n!==null&&n!==t&&Te(t,n)}function ne(e){let t=V(e);return R.current=t,t&&(M.openChangeTimeout.clear(),M.restTimeout.clear(),M.restTimeoutPending=!1,ee.clear()),t}let re=Dr(b,{enabled:!P,mouseOnly:!0,move:!1,handleClose:!L&&I!==`both`?Fr():null,restMs:te,delay(){return u==null&&A?{close:Xn(O.current,`close`)}:{close:w}},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>h.select(`transitionStatus`)===`ending`,shouldOpen(){return!R.current}}),ie=yr(b,{enabled:!P}).reference,ae=e=>{let t=R.current,n=ra(e),r=ne(n),i=S.current,a=i&&n&&Te(i,n);if(r&&h.select(`open`)&&h.select(`lastOpenChangeReason`)===`trigger-hover`){h.setOpen(!1,d(_,e));return}if(t&&!r&&a&&!F.current&&!h.select(`open`)&&i&&x(z.current)){let t=()=>{!R.current&&!F.current&&!h.select(`open`)&&h.setOpen(!0,d(_,e,i))},n=te();n===0?(ee.clear(),t()):ee.start(n,t)}},oe=h.useState(`triggerProps`,E);return j(`button`,e,{state:{open:y},ref:[t,T,S],props:[re,ie,E||I!==`none`?oe:void 0,{onMouseOver(e){ae(e.nativeEvent)},onFocus(e){V(ra(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){R.current=!1,ee.clear(),z.current=void 0},onPointerEnter(e){z.current=e.pointerType},onPointerDown(e){z.current=e.pointerType,h.set(`closeOnClick`,l),l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},id:g,"data-trigger-disabled":P?``:void 0,[na]:P?void 0:``},p],stateAttributesMapping:mt})}),oa=H.createContext(void 0);function sa(){let e=H.useContext(oa);if(e===void 0)throw Error(B(70));return e}var ca=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return qi().useState(`mounted`)||n?(0,U.jsx)(oa.Provider,{value:n,children:(0,U.jsx)(M,{ref:t,...r})}):null}),la=H.createContext(void 0);function ua(){let e=H.useContext(la);if(e===void 0)throw Error(B(71));return e}var da=H.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Pe,style:g,..._}=e,v=qi(),y=sa(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=v.useState(`adaptiveOrigin`),O=ot({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:D}),k=H.useMemo(()=>({open:b,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,O.side,O.align,O.anchorHidden,S,T]),A=et(e,k,{styles:O.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,U.jsx)(la.Provider,{value:O,children:A})}),fa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=qi(),{side:s,align:c}=ua(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);we({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Tr(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return j(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[wt,f,Pt(d),a],stateAttributesMapping:pt})}),pa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=qi(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=ua(),f={open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)};return j(`div`,e,{state:f,ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:$e})}),ma=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=H.useMemo(()=>({open:t,close:n}),[t,n]);return(0,U.jsx)(ea.Provider,{value:t,children:(0,U.jsx)(nr,{delay:i,timeoutMs:r,children:e.children})})};function ha({delay:e=0,...t}){return(0,U.jsx)(ma,{"data-slot":`tooltip-provider`,delay:e,...t})}function ga({...e}){return(0,U.jsx)(Qi,{"data-slot":`tooltip`,...e})}function _a({...e}){return(0,U.jsx)(aa,{"data-slot":`tooltip-trigger`,...e})}function va({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){return(0,U.jsx)(ca,{children:(0,U.jsx)(da,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,U.jsxs)(fa,{"data-slot":`tooltip-content`,className:g(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-xl bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o,children:[a,(0,U.jsx)(pa,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:translate-x-[1.5px] data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:translate-x-[-1.5px] data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:translate-x-[-1.5px] data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:translate-x-[1.5px] data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}var ya=H.createContext(void 0);function ba(e){let t=H.useContext(ya);if(t===void 0&&!e)throw Error(B(33));return t}var xa=H.createContext(void 0);function Sa(e){let t=H.useContext(xa);if(t===void 0&&!e)throw Error(B(36));return t}var Ca=H.createContext(void 0);function wa(e=!0){let t=H.useContext(Ca);if(t===void 0&&!e)throw Error(B(25));return t}function Ta(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=wa(!0),f=d!==void 0;return H.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:We})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!He&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&m(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var Ea={type:`regular-item`};function Da(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=H.useRef(null),{getButtonProps:d,buttonRef:f}=R({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Ta({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=H.useCallback(e=>ee(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=I(u,f);return H.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Oa=H.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=Et({guess:!0,label:a}),f=ba(!0),p=xe(i),{store:m}=Sa(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Da({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:Ea});return j(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),ka=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=Sa(),{side:c,align:l}=ba(),u=it(!0)!=null,f=s.useState(`open`),p=s.useState(`transitionStatus`),m=s.useState(`popupProps`),h=s.useState(`mounted`),g=s.useState(`instantType`),_=s.useState(`activeTriggerElement`),v=s.useState(`parent`),y=s.useState(`lastOpenChangeReason`),b=s.useState(`rootId`),x=s.useState(`floatingRootContext`),S=s.useState(`floatingTreeRoot`),C=s.useState(`closeDelay`),w=s.useState(`hoverEnabled`),T=s.useState(`disabled`),E=s.useState(`openMethod`),D=v.type===`context-menu`;we({open:f,ref:s.context.popupRef,onComplete(){f&&s.context.onOpenChangeComplete?.(!0)}}),H.useEffect(()=>{function e(e){s.setOpen(!1,d(e.reason,e.domEvent))}return S.events.on(`close`,e),()=>{S.events.off(`close`,e)}},[S.events,s]),Tr(x,{enabled:w&&!T&&!D&&v.type!==`menubar`,closeDelay:C});let O=s.useStateSetter(`popupElement`),k={transitionStatus:p,side:c,align:l,open:f,nested:v.type===`menu`,instant:g},A=j(`div`,e,{state:k,ref:[t,s.context.popupRef,O],stateAttributesMapping:pt,props:[m,{onKeyDown(e){u&&st.has(e.key)&&e.stopPropagation()}},Pt(p),o,{"data-rootownerid":b}]}),M=v.type===void 0||D;return(_||v.type===`menubar`&&y!==`outside-press`)&&(M=!0),(0,U.jsx)(ct,{context:x,openInteractionType:E,modal:D,disabled:!h,returnFocus:a===void 0?M:a,initialFocus:v.type!==`menu`,restoreFocus:!0,externalTree:v.type===`menubar`?void 0:S,previousFocusableElement:_,nextFocusableElement:v.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:v.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:A})}),Aa=H.createContext(void 0);function ja(){let e=H.useContext(Aa);if(e===void 0)throw Error(B(32));return e}var Ma=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=Sa();return i.useState(`mounted`)||n?(0,U.jsx)(Aa.Provider,{value:n,children:(0,U.jsx)(u,{ref:t,...r})}):null}),Na=H.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=ce,style:_,...v}=e,{store:b}=Sa(),x=ja(),S=wa(!0),C=b.useState(`parent`),w=b.useState(`floatingRootContext`),T=b.useState(`floatingTreeRoot`),E=b.useState(`mounted`),D=b.useState(`open`),O=b.useState(`modal`),k=b.useState(`openMethod`),A=b.useState(`activeTriggerElement`),j=b.useState(`transitionStatus`),M=b.useState(`positionerElement`),N=b.useState(`instantType`),P=b.useState(`adaptiveOrigin`),F=b.useState(`lastOpenChangeReason`),I=b.useState(`floatingNodeId`),L=b.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=H.useRef(null),z=ke(M),B=n,te=c,ne=l,re=s,ie=g;C.type===`context-menu`&&(B=n??C.context?.anchor,re??=`start`,!o&&re!==`center`&&(ne=e.alignOffset??2,te=e.sideOffset??-5));let ae=o,oe=re;C.type===`menu`?(ae??=`inline-end`,oe??=`start`,ie=e.collisionAvoidance??Pe):C.type===`menubar`&&(ae??=C.context.orientation===`vertical`?`inline-end`:`bottom`,oe??=`start`);let se=C.type===`context-menu`,le=ot({anchor:B,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ae,sideOffset:te,align:oe,alignOffset:ne,arrowPadding:se?0:p,collisionBoundary:u,collisionPadding:f,sticky:m,nodeId:I,keepMounted:x,disableAnchorTracking:h,collisionAvoidance:ie,shift:se?{crossAxis:!(`side`in ie&&ie.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P});H.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&b.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===b.select(`floatingParentNodeId`)&&b.setOpen(!1,d(y)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[b,T.events,I]),H.useEffect(()=>{if(b.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==b.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;b.setOpen(!1,d(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,b]);let ue=Be();H.useEffect(()=>{D||ue.clear()},[D,ue]),H.useEffect(()=>{function e(e){if(!(!D||e.nodeId!==b.select(`floatingParentNodeId`))){if(e.target&&A&&A!==e.target){let e=b.select(`closeDelay`);e>0?ue.isStarted()||ue.start(e,()=>{b.setOpen(!1,d(y))}):b.setOpen(!1,d(y))}else ue.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,b,ue]),H.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:b.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,b,I,L]),V(()=>{let e=R,t=ee.current;if(e&&(ee.current=e),t&&e&&e!==t){b.set(`instantType`,void 0);let e=new AbortController;return z(()=>{b.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[R,z,b]);let de={open:D,side:le.side,align:le.align,anchorHidden:le.anchorHidden,nested:C.type===`menu`,instant:N},fe=C.type===`menubar`&&C.context.modal;Ze(D&&(fe||O&&F!==`trigger-hover`),k===`touch`,M,A);let pe=et(e,de,{styles:le.positionerStyles,transitionStatus:j,props:v,refs:[t,b.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),me=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),he=null;return C.type===`menubar`?he=C.context.contentElement:C.type===void 0&&(he=A),(0,U.jsxs)(ya.Provider,{value:le,children:[me&&(0,U.jsx)(nt,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Me(!D),cutout:he}),(0,U.jsx)(Je,{id:I,children:(0,U.jsx)(Ye,{elementsRef:b.context.itemDomElements,labelsRef:b.context.itemLabels,children:pe})})]})}),Pa=H.createContext(null);function Fa(e){let t=H.useContext(Pa);if(t===null&&!e)throw Error(B(5));return t}var Ia={...hr,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},La=class extends f{constructor(e){super({...za(),...e},Ra(),Ia),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function Ra(){return{positionerRef:H.createRef(),popupRef:H.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:H.createRef(),beforeContentFocusGuardRef:H.createRef(),onOpenChangeComplete:void 0,triggerElements:new Ft}}function za(){return{...cr(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new at,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:L,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0}}var Ba=H.createContext(void 0);function Va(){return H.useContext(Ba)}var Ha=ye(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:u=`vertical`,actionsRef:f,closeParentOnEsc:p=!1,handle:m,triggerId:h,defaultTriggerId:g=null,highlightItemOnHover:_=!0}=e,v=wa(!0),y=Sa(!0),b=Fa(!0),x=Va(),S=H.useMemo(()=>x&&y?{type:`menu`,store:y.store}:b?{type:`menubar`,context:b}:v&&!y?{type:`context-menu`,context:v}:{type:void 0},[v,y,b,x]),C=Ua({open:a,openProp:n,activeTriggerId:g,triggerIdProp:h,parent:S});C.useControlledProp(`openProp`,n),C.useControlledProp(`triggerIdProp`,h),C.useContextCallback(`onOpenChangeComplete`,i);let w=te(),T=te(),E=C.useState(`floatingTreeRoot`),O=ut(E),k=Qe(),j=C.useState(`open`),M=C.useState(`activeTriggerElement`),N=C.useState(`positionerElement`),P=C.useState(`hoverEnabled`),F=C.useState(`disabled`),I=C.useState(`lastOpenChangeReason`),R=C.useState(`parent`),z=C.useState(`activeIndex`),B=C.useState(`payload`),ne=C.useState(`floatingParentNodeId`),re=H.useRef(null),ie=H.useRef(R.type!==`context-menu`),ae=Be(),oe=H.useRef(!0),se=Be(),ce=ne!=null,{openMethod:le,triggerProps:ue}=Ke(j);C.useSyncedValues({disabled:o,highlightItemOnHover:_,modal:R.type===void 0?s:void 0,openMethod:le,rootId:w}),Bt(C);let{forceUnmount:de}=vt(j,C,()=>{C.set(`allowMouseEnter`,!1)});V(()=>{v&&!y?C.update({parent:{type:`context-menu`,context:v},floatingNodeId:O,floatingParentNodeId:k}):y&&C.update({floatingNodeId:O,floatingParentNodeId:k})},[v,y,O,k,C]),H.useEffect(()=>{if(j||(re.current=null),R.type===`context-menu`){if(!j){ae.clear(),ie.current=!1;return}ae.start(500,()=>{ie.current=!0})}},[ae,j,R.type]),V(()=>{!j&&!P&&C.set(`hoverEnabled`,!0)},[j,P,C]);let fe=A((e,t)=>{let n=t.reason;if(!e&&!C.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=Lt(t);if(!e&&t.trigger==null&&(t.trigger=M??void 0),r?.(e,t),t.isCanceled)return;C.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!oe.current)return;e&&n===`trigger-focus`?(oe.current=!1,se.start(300,()=>{oe.current=!0})):(oe.current=!0,se.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null),c={open:e,openChangeReason:n};re.current=t.event,Ot(c,e,t.trigger,i()),C.update(c),R.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?C.set(`instantType`,`group`):o||s?C.set(`instantType`,o?`click`:`dismiss`):C.set(`instantType`,void 0)}),pe=Vt({popupStore:C,floatingId:T,nested:k!=null,onOpenChange:fe}),me=pe.context.events;V(()=>{let e=({open:e,eventDetails:t})=>fe(e,t);return me.on(`setOpen`,e),()=>{me?.off(`setOpen`,e)}},[me,fe]);let he=H.useCallback(()=>{C.setOpen(!1,d(D))},[C]);H.useImperativeHandle(f,()=>({unmount:de,close:he}),[de,he]);let ge;R.type===`context-menu`&&(ge=R.context),H.useImperativeHandle(ge?.positionerRef,()=>N,[N]),H.useImperativeHandle(ge?.actionsRef,()=>({setOpen:fe}),[fe]);let _e=gt(pe,{enabled:!F,bubbles:{escapeKey:p&&R.type===`menu`},outsidePress(){return R.type!==`context-menu`||re.current?.type===`contextmenu`||ie.current},externalTree:ce?E:void 0}),ve=Ge(),ye=H.useCallback(e=>{C.select(`activeIndex`)!==e&&C.set(`activeIndex`,e)},[C]),be=zt(pe,{enabled:!F,listRef:C.context.itemDomElements,activeIndex:z,nested:R.type!==void 0,loopFocus:c,orientation:u,parentOrientation:R.type===`menubar`?R.context.orientation:void 0,rtl:ve===`rtl`,disabledIndices:l,onNavigate:ye,openOnArrowKeyDown:R.type!==`context-menu`,externalTree:ce?E:void 0,focusItemOnHover:_}),xe=H.useCallback(e=>{C.context.typingRef.current=e},[C]),Se=yt(pe,{enabled:!F,listRef:C.context.itemLabels,elementsRef:C.context.itemDomElements,activeIndex:z,resetMs:500,onMatch:e=>{j&&e!==z&&C.set(`activeIndex`,e)},onTyping:xe}),Ce=H.useMemo(()=>{let e=ee(Se.reference,be.reference,_e.reference,{onMouseMove(){C.set(`allowMouseEnter`,!0)}},ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[C,Se.reference,be.reference,_e.reference,ue,j]),we=H.useMemo(()=>{let e=ee(be.trigger,_e.trigger,ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[be.trigger,_e.trigger,ue]),Te=H.useMemo(()=>ee(wt,{id:T,role:`menu`,"aria-labelledby":M?.id,onMouseMove(){C.set(`allowMouseEnter`,!0),R.type===`menu`&&C.set(`hoverEnabled`,!1)},onClick(){C.select(`hoverEnabled`)&&C.set(`hoverEnabled`,!1)},onKeyDown(e){let t=C.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Se.floating,be.floating,_e.floating),[M,T,R.type,C,Se.floating,be.floating,_e.floating]),Ee=be.item??L;bt(C,{floatingRootContext:pe,activeTriggerProps:Ce,inactiveTriggerProps:we,popupProps:Te,itemProps:Ee});let De=H.useMemo(()=>({store:C,parent:S}),[C,S]),Oe=(0,U.jsxs)(xa.Provider,{value:De,children:[m&&(0,U.jsx)(ht,{handle:m,store:C}),typeof t==`function`?t({payload:B}):t]});return R.type===void 0||R.type===`context-menu`?(0,U.jsx)(Ht,{externalTree:E,children:Oe}):Oe});function Ua(e){return a(()=>new La(e)).current}function Wa(e){let t=Sa().store,n=H.useMemo(()=>({parentMenu:t}),[t]);return(0,U.jsx)(Ba.Provider,{value:n,children:(0,U.jsx)(Ha,{...e})})}function Ga(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=v(),{ref:i,index:a}=Et(e),o=n===a,s=H.useRef(null),c=I(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function Ka(e){let{render:t,className:n,style:r,state:i=L,props:a=l,refs:o=l,metadata:s,stateAttributesMapping:c,tag:u=`div`,...d}=e,{compositeProps:f,compositeRef:p}=Ga({metadata:s});return j(u,e,{state:i,ref:[p,...o],props:[f,...a,d],stateAttributesMapping:c})}function qa(e){if(se(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!le(e))return qa(je(e))}function Ja(e,t){let n=H.useRef(null);function r(t){yn.flushSync(()=>{e.setOpen(!1,d(C,t.nativeEvent,t.currentTarget))}),me(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&pe(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{yn.flushSync(()=>{e.setOpen(!1,d(C,n.nativeEvent,n.currentTarget))});let i=Ce(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Te(r,i);){let e=i;if(i=ue(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Ya(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=H.useRef(!1);return H.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,b(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:L,[t,n,r])}var Xa=c(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Sa(!0),h=_r(d)??m?.store;if(!h)throw Error(B(85));let g=xe(s),_=h.useState(`isTriggerActive`,g),y=h.useState(`floatingRootContext`),x=h.useState(`isOpenedByTrigger`,g),S=h.useState(`triggerPopupId`,g),C=H.useRef(null),w=Qa(),E=v(!0),D=Xe(),O=H.useMemo(()=>D??new at,[D]),k=ut(O),M=Qe(),{registerTrigger:N,isMountedByThisTrigger:P}=St(g,C,h,{payload:f,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:k,floatingParentNodeId:M,keyboardEventRelay:E?.relayKeyboardEvent}),F=w.type===`menubar`,I=h.useState(`disabled`),z=a||I||F&&w.context.disabled,{getButtonProps:te,buttonRef:V}=R({disabled:z,native:o});H.useEffect(()=>{!x&&w.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,x,w.type]);let ne=H.useRef(null),re=Be(),ie=A(e=>{if(!ne.current)return;re.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Te(ne.current,t)||Te(h.select(`positionerElement`),t)||t===ne.current||(t==null||qa(t)!==h.select(`rootId`))&&(lt(e,ne.current)||O.events.emit(`close`,{domEvent:e,reason:T}))});H.useEffect(()=>{x&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&b(ne.current).addEventListener(`mouseup`,ie,{once:!0})},[x,ie,h]);let ae=F&&w.context.hasSubmenuOpen,se=Dr(y,{enabled:(c??ae)&&!z&&(!F||ae&&!P),handleClose:Fr({blockPointerEvents:!F}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),ce=Za(x,h.select(`lastOpenChangeReason`)),le=Ut(y,{enabled:!z,event:x&&F?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&ce}),ue=yr(y,{enabled:!z&&ae}),de=Ya({open:x,enabled:F,mouseDownAction:`open`}),fe=H.useMemo(()=>ee(ue.reference,le.reference),[ue.reference,le.reference]),pe=h.useState(`triggerProps`,P),{preFocusGuardRef:me,handlePreFocusGuardFocus:he,handleFocusTargetFocus:ge}=Ja(h,C),_e={disabled:z,open:x},ve=[ne,t,V,N,C],ye=[fe,se??L,pe,{"aria-haspopup":`menu`,"aria-controls":S,id:g,onMouseDown:e=>{h.select(`open`)||(re.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),b(e.currentTarget).addEventListener(`mouseup`,ie,{once:!0}))}},F?{role:`menuitem`}:{},de,p,te],be=j(`button`,e,{enabled:!F,stateAttributesMapping:ft,state:_e,ref:ve,props:ye});return F?(0,U.jsx)(Ka,{tag:`button`,render:n,className:r,style:i,state:_e,refs:ve,props:ye,stateAttributesMapping:ft}):x?(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(oe,{ref:me,onFocus:he},`${g}-pre-focus-guard`),(0,U.jsx)(H.Fragment,{children:be},g),(0,U.jsx)(oe,{ref:h.context.triggerFocusTargetRef,onFocus:ge},`${g}-post-focus-guard`)]}):(0,U.jsx)(H.Fragment,{children:be},g)});function Za(e,t){let n=Be(),[r,i]=H.useState(!1);return V(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function Qa(){let e=Fa(!0);return H.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var $a=H.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return j(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),eo={"aria-expanded":void 0},to=H.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=Va();if(!p?.parentMenu)throw Error(B(37));let m=Et({guess:!0,label:a}),h=ba(),{store:g}=Sa(),_=xe(o),v=g.useState(`open`),y=g.useState(`floatingRootContext`),b=g.useState(`floatingTreeRoot`),x=g.useState(`triggerPopupId`,_),S=xt(_,g),C=H.useCallback(e=>{let t=S(e);return e!==null&&g.select(`open`)&&g.select(`activeTriggerId`)==null&&g.update({activeTriggerId:_,activeTriggerElement:e,closeDelay:u}),t},[S,u,g,_]),w=H.useRef(null),T=H.useCallback(e=>{w.current=e,g.set(`activeTriggerElement`,e)},[g]);g.useSyncedValue(`closeDelay`,u);let E=p.parentMenu,D=g.useState(`disabled`),O=E.useState(`disabled`),k=d||D||O,A=E.useState(`itemProps`),M=E.useState(`isActive`,m.index),N=H.useMemo(()=>({type:`submenu-trigger`,setActive(){E.select(`highlightItemOnHover`)&&E.set(`activeIndex`,m.index)}}),[E,m.index]),{getItemProps:P,itemRef:F}=Da({closeOnClick:!1,disabled:k,highlighted:M,id:_,store:g,typingRef:E.context.typingRef,nativeButton:s,itemMetadata:N,nodeId:h?.context.nodeId}),I=Dr(y,{enabled:g.useState(`hoverEnabled`)&&c&&!k,handleClose:Fr({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>E.select(`allowMouseEnter`):void 0,triggerElementRef:w,externalTree:b,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),R=Ut(y,{enabled:!k,event:`mousedown`,toggle:!c,ignoreMouse:c,stickIfOpen:!1}).reference??L,ee=g.useState(`triggerProps`,!0);delete ee.id;let z={disabled:k,highlighted:M,open:v},te=g.useState(`openMethod`),V=g.useState(`lastOpenChangeReason`)===`list-navigation`||te===`keyboard`;return j(`div`,e,{state:z,stateAttributesMapping:mt,props:[R,I,ee,A,v&&V&&Se?eo:void 0,{"aria-controls":x,tabIndex:v||M?0:-1,onBlur(){M&&E.set(`activeIndex`,null)}},f,P],ref:[t,m.ref,F,C,T]})});function no({...e}){return(0,U.jsx)(Ha,{"data-slot":`dropdown-menu`,...e})}function ro({className:e,...t}){return(0,U.jsx)(Xa,{"data-slot":`dropdown-menu-trigger`,className:e,...t})}function io({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,U.jsx)(Ma,{children:(0,U.jsx)(Na,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,U.jsx)(ka,{"data-slot":`dropdown-menu-content`,className:g(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function ao({className:e,inset:t,variant:n=`default`,...r}){return(0,U.jsx)(Oa,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:g(`group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function oo({...e}){return(0,U.jsx)(Wa,{"data-slot":`dropdown-menu-sub`,...e})}function so({className:e,inset:t,children:n,...r}){return(0,U.jsxs)(to,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:g(`relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,U.jsx)(Tn,{className:`ml-auto`})]})}function co({align:e=`start`,alignOffset:t=-3,side:n=`right`,sideOffset:r=0,className:i,...a}){return(0,U.jsx)(io,{"data-slot":`dropdown-menu-sub-content`,className:g(`w-auto min-w-[96px] rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function lo({className:e,...t}){return(0,U.jsx)($a,{"data-slot":`dropdown-menu-separator`,className:g(`-mx-1 my-1 h-px bg-border/50`,e),...t})}var uo=6e4,fo=60*uo,po=24*fo;function mo(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,t-n);return r<uo?`just now`:r<fo?`${Math.floor(r/uo)}m`:r<po?`${Math.floor(r/fo)}h`:new Date(n).toISOString().slice(0,10)}function ho(e){if(!e||typeof e!=`object`)return;let t=e,n=typeof t.old_string==`string`?t.old_string:void 0,r=typeof t.new_string==`string`?t.new_string:typeof t.content==`string`?t.content:void 0;if(n!==void 0||r!==void 0)return{...typeof t.file_path==`string`?{path:t.file_path}:{},removed:yo(n),added:yo(r)}}function go(e,t){let n=!!t?.trim();if(!n){let t=/^--- [^\n]*\n\+\+\+ [^\n]*\n/m.test(e),n=/^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/m.test(e);if(!t||!n)return}let r=0,i=0;return(e.match(/[^\n]*\n|[^\n]+$/g)??[]).map(e=>{let t=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(e);if(t)return r=Number(t[1]??1),i=Number(t[2]??1),{text:e,kind:`context`};let a=r>0||i>0,o=`context`;return(a||n)&&(e.startsWith(`-`)&&(a||!e.startsWith(`--- `))&&(o=`removed`),e.startsWith(`+`)&&(a||!e.startsWith(`+++ `))&&(o=`added`)),a&&((o===`removed`||e.startsWith(` `))&&(r=Math.max(0,r-1)),(o===`added`||e.startsWith(` `))&&(i=Math.max(0,i-1))),{text:e,kind:o}})}function _o(e){let t=[],n,r=0,i=0;for(let a of e.split(`
|
|
3
|
+
`)){let e=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(a);if(e)n={oldStart:Number(e[1]),oldCount:Number(e[2]??1),newStart:Number(e[3]),newCount:Number(e[4]??1),lines:[{kind:`context`,text:a}]},t.push(n),r=n.oldStart,i=n.newStart;else if(n)a.startsWith(`-`)?n.lines.push({kind:`removed`,text:a,old:r++}):a.startsWith(`+`)?n.lines.push({kind:`added`,text:a,new:i++}):a.startsWith(` `)?n.lines.push({kind:`context`,text:a,old:r++,new:i++}):a.startsWith(`\\`)&&n.lines.push({kind:`context`,text:a});else continue}return{deleted:/^\+\+\+ \/dev\/null$/m.test(e),hunks:t}}function vo(e,t){let n=e=>e.lines.map(e=>e.text).join(`
|
|
4
|
+
`),r=new Set(t.map(n));return e.every(e=>r.has(n(e)))}function yo(e){if(!e)return[];let t=e.split(`
|
|
5
|
+
`);for(;t.length>0&&t[t.length-1]===``;)t.pop();return t}var bo=[[/^mcp__/,`mcp`],[/^(bash|shell|exec|run_?command)$/,`shell`],[/^(read|read_?file|view|notebookread)$/,`read`],[/^(write|write_?file|create_?file|notebookedit)$/,`write`],[/^(edit|multi_?edit|str_replace(_based_edit_tool|_editor)?|apply_?patch)$/,`edit`],[/^(grep|search|ripgrep)$/,`search`],[/^(glob|ls|list|find|list_?directory)$/,`list`],[/^(web_?fetch|web_?search|fetch)$/,`web`],[/^(task|agent)$/,`agent`],[/^(todo_?write|task_?(create|update|list))$/,`todo`]];function xo(e){let t=e.toLowerCase();return bo.find(([e])=>e.test(t))?.[1]??`other`}function So(e){if(typeof e==`string`)return e;let t=Array.isArray(e)?e:typeof e==`object`&&e&&Array.isArray(e.content)?e.content:void 0;if(!t)return;let n=t.flatMap(e=>typeof e==`object`&&e&&typeof e.text==`string`?[e.text]:[]);return n.length>0?n.join(`
|
|
6
|
+
`):void 0}function Co(e){if(e!==void 0)return e.split(`
|
|
7
|
+
`).filter(e=>e.trim()!==``).length}function wo(e,t){return`${e} ${t}${e===1?``:`s`}`}function To(e){if(e.status===`error`)return`failed`;if(e.status!==`complete`)return;let t=ho(e.input);if(t)return`+${t.added.length} −${t.removed.length}`;let n=Co(So(e.result));if(n!==void 0)switch(xo(e.name)){case`read`:return wo(n,`line`);case`list`:return wo(n,`file`);case`search`:return wo(n,`result`);default:return}}var Eo={shell:Vn,read:jn,write:An,edit:kn,search:Bn,list:Mn,web:Pn,agent:Cn,todo:Fn,mcp:Rn,other:Un};function Do({name:e,className:t}){let n=Eo[xo(e)];return(0,U.jsx)(n,{"aria-hidden":!0,className:g(`size-3.5 shrink-0`,t)})}var Oo={scale:1,x:0,y:0};function ko(e,t,n){let r=Math.min(8,Math.max(1,e.scale));return{scale:r,x:Math.min(0,Math.max(t-t*r,e.x)),y:Math.min(0,Math.max(n-n*r,e.y))}}function Ao(e,t,n,r,i,a){let o=Math.min(8,Math.max(1,e.scale*t)),s=o/e.scale;return ko({scale:o,x:n-(n-e.x)*s,y:r-(r-e.y)*s},i,a)}function jo(e,t,n,r,i){return ko({...e,x:e.x+t,y:e.y+n},r,i)}function Mo({src:e,alt:t,className:n,referrerPolicy:r,onError:i}){return(0,U.jsxs)(si,{children:[(0,U.jsx)(ci,{render:(0,U.jsx)(`button`,{type:`button`,"aria-label":t?`Open ${t}`:`Open image`,className:`cursor-zoom-in rounded-md outline-none focus-visible:ring-3 focus-visible:ring-ring/30`}),children:(0,U.jsx)(`img`,{src:e,alt:t,loading:`lazy`,decoding:`async`,referrerPolicy:r,onError:i,className:g(`block`,n)})}),(0,U.jsxs)(di,{className:`w-max max-w-[80vw] gap-0 p-2 sm:max-w-[80vw]`,children:[(0,U.jsx)(mi,{className:`sr-only`,children:t||`Image`}),(0,U.jsx)(No,{src:e,alt:t,referrerPolicy:r})]})]})}function No({src:e,alt:t,referrerPolicy:n}){let r=(0,H.useRef)(null),i=(0,H.useRef)(void 0),[a,o]=(0,H.useState)(Oo);(0,H.useEffect)(()=>{let e=r.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect(),r=t.deltaMode===WheelEvent.DOM_DELTA_LINE?16:1,i=t.deltaX*r,a=t.deltaY*r;o(e=>t.ctrlKey?Ao(e,Math.exp(-Math.max(-50,Math.min(50,a))*.01),t.clientX-n.left,t.clientY-n.top,n.width,n.height):jo(e,-i,-a,n.width,n.height))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]);let s=()=>r.current.getBoundingClientRect(),c=()=>{i.current=void 0};return(0,U.jsx)(`div`,{ref:r,className:g(`relative touch-none overflow-hidden rounded-md select-none`,a.scale>1?`cursor-grab active:cursor-grabbing`:`cursor-zoom-in`),onPointerDown:e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),i.current={x:e.clientX,y:e.clientY})},onPointerMove:e=>{let t=i.current;if(!t)return;let{width:n,height:r}=s(),a=e.clientX-t.x,c=e.clientY-t.y;i.current={x:e.clientX,y:e.clientY},o(e=>jo(e,a,c,n,r))},onPointerUp:c,onPointerCancel:c,onDoubleClick:e=>{let{left:t,top:n,width:r,height:i}=s(),a=e.clientX-t,c=e.clientY-n;o(e=>e.scale>1?Oo:Ao(e,2,a,c,r,i))},children:(0,U.jsx)(`img`,{src:e,alt:t,referrerPolicy:n,draggable:!1,className:`block max-h-[calc(80dvh-1rem)] max-w-[calc(80vw-1rem)] origin-top-left will-change-transform`,style:{transform:`translate(${a.x}px, ${a.y}px) scale(${a.scale})`}})})}function Po(e){if(!e.startsWith(`/`))return;let t=/^\/([A-Za-z0-9][\w-]*(?::(?:[A-Za-z0-9][\w-]*)?)?)?/.exec(e)?.[1]??``;return{name:t,to:t.length+1}}function Fo(e){let t=Po(e);if(!t||t.name===``||t.name.endsWith(`:`))return;let n=e[t.to];if(n===void 0||n===` `||n===`
|
|
8
|
+
`)return{...t,rest:e.slice(t.to)}}function Io(e,t){let n=(t??[]).filter(t=>e.startsWith(`mcp__${t.id}__`)).sort((e,t)=>t.id.length-e.id.length)[0];return n&&{connection:n.name,tool:e.slice(`mcp__${n.id}__`.length)}}function Lo({name:e}){let t=Io(e,Ue().config.mcp);return t?(0,U.jsxs)(ga,{children:[(0,U.jsxs)(_a,{render:(0,U.jsx)(`span`,{}),children:[t.connection,` › `,t.tool]}),(0,U.jsx)(va,{children:e})]}):e}var Ro=[{decision:`allow`,label:`Allow once`,description:`Run it this time, and ask again next time.`},{decision:`deny`,label:`Deny`,description:`Refuse it, and stop asking for the rest of this turn.`},{decision:`always`,label:`Always allow on this machine`,description:`Run it, and never ask again in any Agent Session. Revocable in Settings.`}],zo=Ro.slice(0,2);function Bo(e){return e===!1?zo:Ro}function Vo(e){switch(e){case void 0:return;case`asked`:return`waiting to be authorised`;case`allowed`:return`authorised`;case`always`:return`always authorised on this machine`;case`denied`:return`refused`}}function Ho({className:e,...t}){return(0,U.jsx)(`textarea`,{"data-slot":`textarea`,className:g(`flex field-sizing-content min-h-16 w-full resize-none rounded-2xl border border-transparent bg-input/50 px-2.5 py-2 text-base transition-[color,box-shadow] duration-200 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function Uo(e){if(e.kind===`subagent`)return[e.name,e.description].filter(e=>e!==void 0&&e!==``).join(`
|
|
9
|
+
`);if(e.kind===`enquiry`)return e.questions.flatMap((t,n)=>[t.header,t.question,...t.options.map(e=>e.label),...e.answers?.[n]??[]]).filter(e=>e!==``).join(`
|
|
10
|
+
`);if(e.kind===`background_call`)return e.tool;if(e.kind!==`tool`)return e.text;let t=ho(e.input);return[e.name,Ko(e.input),Ko(e.result),t?.path].filter(e=>e!==void 0&&e!==``).join(`
|
|
11
|
+
`)}function Wo(e,t){if(e===``)return[];if(t===``)return[{text:e,match:!1}];let n=e.toLowerCase();if(n.length!==e.length)return[{text:e,match:!1}];let r=[],i=0;for(let a=n.indexOf(t);a!==-1;a=n.indexOf(t,i)){a>i&&r.push({text:e.slice(i,a),match:!1}),i=a+t.length;let n=r[r.length-1];n?.match?n.text+=e.slice(a,i):r.push({text:e.slice(a,i),match:!0})}return i<e.length&&r.push({text:e.slice(i),match:!1}),r}function Go(){let e=new WeakMap;return{matches(t,n){if(n===``)return!0;let r=e.get(t);return r===void 0&&(r=Uo(t).toLowerCase(),e.set(t,r)),r.includes(n)}}}function Ko(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)??``}catch{return``}}function qo({text:e,query:t}){return t===``?(0,U.jsx)(U.Fragment,{children:e}):(0,U.jsx)(U.Fragment,{children:Wo(e,t).map((e,t)=>e.match?(0,U.jsx)(`mark`,{className:`rounded-sm bg-chart-4/30 text-foreground`,children:e.text},t):(0,U.jsx)(`span`,{children:e.text},t))})}function Jo(e){let t=e.filter(e=>e.status===`completed`).length;return{done:t,total:e.length,current:e.find(e=>e.status===`in_progress`)??e.find(e=>e.status===`pending`),finished:e.length>0&&t===e.length}}function Yo(e){let{done:t,total:n}=Jo(e);return`${t}/${n}`}function Xo(e){return e.length===0?`Cleared todos`:`Updated todos · ${Yo(e)}`}var Zo={pending:`pending`,in_progress:`in progress`,completed:`completed`};function Qo({status:e}){return(0,U.jsx)(e===`completed`?En:e===`in_progress`?Dn:On,{"aria-hidden":!0,className:g(`my-px size-3.5 shrink-0`,e===`in_progress`?`text-foreground`:`text-muted-foreground`)})}function $o({items:e,query:t=``,className:n}){return(0,U.jsx)(`ul`,{"aria-label":`Todo List`,className:g(`space-y-1 text-xs leading-4`,n),children:e.map((e,n)=>(0,U.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,U.jsx)(Qo,{status:e.status}),(0,U.jsxs)(`span`,{className:`sr-only`,children:[Zo[e.status],`: `]}),(0,U.jsx)(`span`,{className:g(`min-w-0 [overflow-wrap:anywhere]`,e.status===`completed`?`text-muted-foreground line-through decoration-muted-foreground/60`:e.status===`in_progress`?`text-foreground`:`text-muted-foreground`),children:(0,U.jsx)(qo,{text:e.content,query:t})})]},`${n}:${e.content}`))})}function es({items:e}){let[t,n]=(0,H.useState)(!1),{current:r,finished:i}=Jo(e);return(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-t-xl border border-b-0 bg-card text-xs leading-4 text-muted-foreground shadow-sm`,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-label":t?`Hide Todo List`:`Show Todo List`,onClick:()=>n(e=>!e),className:g(`group/todo flex w-full items-center gap-2 px-3 pt-1.5 pb-4.5 text-left outline-none hover:text-foreground`,`focus-visible:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:ring-inset`),children:[(0,U.jsx)(Fn,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`shrink-0 font-mono text-foreground/80`,children:Yo(e)}),(0,U.jsx)(`span`,{className:g(`min-w-0 truncate`,!i&&r?.status===`in_progress`&&`text-foreground`),children:i?`All done`:r?.content??``}),(0,U.jsx)(Tn,{"aria-hidden":!0,className:g(`ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,t&&`-rotate-90`)})]}),t?(0,U.jsx)($o,{items:e,className:`-mt-3 max-h-48 overflow-y-auto px-3 pb-4.5`}):null]})}function ts(e){if(e===`removed`)return`bg-destructive/10 text-destructive`;if(e===`added`)return`bg-diff-added/10 text-diff-added`}function ns({text:e,lang:t,query:n,trailing:r}){let i=go(e,t);return i?(0,U.jsxs)(`span`,{className:`inline-block min-w-full align-top`,children:[i.map((e,t)=>{let a=e.text.endsWith(`\r
|
|
12
|
+
`)?`\r
|
|
13
|
+
`:e.text.endsWith(`
|
|
14
|
+
`)?`
|
|
15
|
+
`:``,o=t===i.length-1?r:void 0;return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsxs)(`span`,{className:g(`inline-block min-w-full min-h-[1lh] align-top`,ts(e.kind)),children:[(0,U.jsx)(qo,{text:a?e.text.slice(0,-a.length):e.text,query:n}),a?void 0:o]}),a||void 0,a?o:void 0]},t)}),i.length===0?r:void 0]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(qo,{text:e,query:n}),r]})}function rs({hunks:e,deleted:t}){return(0,U.jsx)(`span`,{className:`inline-block min-w-full align-top`,children:e.flatMap(e=>e.lines).map((e,n)=>(0,U.jsxs)(H.Fragment,{children:[(0,U.jsxs)(`span`,{"data-line":t?e.old:e.new,className:g(`inline-block min-w-full`,ts(e.kind)),children:[(0,U.jsx)(`span`,{className:`inline-block w-10 select-none pr-2 text-right tabular-nums text-muted-foreground`,children:e.old}),(0,U.jsx)(`span`,{className:`inline-block w-10 select-none pr-2 text-right tabular-nums text-muted-foreground`,children:e.new}),e.text]}),`
|
|
16
|
+
`]},n))})}function is(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var as=is();function os(e){as=e}var ss={exec:()=>null};function cs(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function W(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(us.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ls=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),us={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:cs(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:cs(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:cs(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:cs(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:cs(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:cs(e=>RegExp(`^ {0,${e}}>`))},ds=/^(?:[ \t]*(?:\n|$))+/,fs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ps=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ms=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,hs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,gs=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,_s=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,vs=W(_s).replace(/bull/g,gs).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ys=W(_s).replace(/bull/g,gs).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),bs=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,xs=/^[^\n]+/,Ss=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Cs=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Ss).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ws=W(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,gs).getRegex(),Ts=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Es=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ds=W(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Es).replace(`tag`,Ts).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Os=e=>W(bs).replace(`hr`,ms).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Ts).getRegex(),ks=Os(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),As=Os(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),js={blockquote:W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,As).getRegex(),code:fs,def:Cs,fences:ps,heading:hs,hr:ms,html:Ds,lheading:vs,list:ws,newline:ds,paragraph:ks,table:ss,text:xs},Ms=W(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,ms).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Ts).getRegex(),Ns={...js,lheading:ys,table:Ms,paragraph:W(bs).replace(`hr`,ms).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Ms).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Ts).getRegex()},Ps={...js,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Es).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ss,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(bs).replace(`hr`,ms).replace(`heading`,` *#{1,6} *[^
|
|
17
|
+
]`).replace(`lheading`,vs).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Fs=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Is=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ls=/^( {2,}|\\)\n(?!\s*$)/,Rs=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,zs=/[\p{P}\p{S}]/u,Bs=/[\s\p{P}\p{S}]/u,Vs=/[^\s\p{P}\p{S}]/u,Hs=W(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Bs).getRegex(),Us=/[\p{Pi}\p{Ps}"']/u,Ws=/(?!~)[\p{P}\p{S}]/u,Gs=/(?!~)[\s\p{P}\p{S}]/u,Ks=/(?:[^\s\p{P}\p{S}]|~)/u,qs=W(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,ls?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Js=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ys=W(Js,`u`).replace(/punct/g,zs).getRegex(),Xs=W(Js,`u`).replace(/punct/g,Ws).getRegex(),Zs=W(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Us).replace(/punct/g,zs).getRegex(),Qs=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,$s=W(Qs,`gu`).replace(/notPunctSpace/g,Vs).replace(/punctSpace/g,Bs).replace(/punct/g,zs).getRegex(),ec=W(Qs,`gu`).replace(/notPunctSpace/g,Ks).replace(/punctSpace/g,Gs).replace(/punct/g,Ws).getRegex(),tc=W(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Vs).replace(/punctSpace/g,Bs).replace(/punct/g,zs).getRegex(),nc=W(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Vs).replace(/punctSpace/g,Bs).replace(/punct/g,zs).getRegex(),rc=W(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Vs).replace(/punctSpace/g,Bs).replace(/punct/g,zs).getRegex(),ic=W(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,zs).getRegex(),ac=W(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Vs).replace(/punctSpace/g,Bs).replace(/punct/g,zs).getRegex(),oc=W(/\\(punct)/,`gu`).replace(/punct/g,zs).getRegex(),sc=W(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),cc=W(Es).replace(`(?:-->|$)`,`-->`).getRegex(),lc=W(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,cc).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),uc=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,dc=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,uc).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),fc=W(/^!?\[(label)\]\[(ref)\]/).replace(`label`,uc).replace(`ref`,Ss).getRegex(),pc=W(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Ss).getRegex(),mc=W(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,fc).replace(`nolink`,pc).getRegex(),hc=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,gc={_backpedal:ss,anyPunctuation:oc,autolink:sc,blockSkip:qs,br:Ls,code:Is,del:ss,delLDelim:ss,delRDelim:ss,emStrongLDelim:Ys,emStrongRDelimAst:$s,emStrongRDelimUnd:nc,escape:Fs,link:dc,nolink:pc,punctuation:Hs,reflink:fc,reflinkSearch:mc,tag:lc,text:Rs,url:ss},_c={...gc,emStrongLDelim:Zs,emStrongRDelimAst:tc,emStrongRDelimUnd:rc,link:W(/^!?\[(label)\]\((.*?)\)/).replace(`label`,uc).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,uc).getRegex()},vc={...gc,emStrongRDelimAst:ec,emStrongLDelim:Xs,delLDelim:ic,delRDelim:ac,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,hc).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:W(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,hc).getRegex()},yc={...vc,br:W(Ls).replace(`{2,}`,`*`).getRegex(),text:W(vc.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},bc={normal:js,gfm:Ns,pedantic:Ps},xc={normal:gc,gfm:vc,breaks:yc,pedantic:_c},Sc={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Cc=e=>Sc[e];function wc(e,t){if(t){if(us.escapeTest.test(e))return e.replace(us.escapeReplace,Cc)}else if(us.escapeTestNoEncode.test(e))return e.replace(us.escapeReplaceNoEncode,Cc);return e}function Tc(e){try{e=encodeURI(e).replace(us.percentDecode,`%`)}catch{return null}return e}function Ec(e,t){let n=e.replace(us.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(us.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(us.slashPipe,`|`);return n}function Dc(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Oc(e){let t=e.split(`
|
|
18
|
+
`),n=t.length-1;for(;n>=0&&us.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
19
|
+
`)}function kc(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Ac(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function jc(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`;r.state.inLink=!0;let l=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),f=r.state.linkEmitted;if(r.state.linkEmitted=l,r.state.inLink=!1,!c){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:d}}function Mc(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
20
|
+
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
21
|
+
`)}var Nc=class{options;rules;lexer;constructor(e){this.options=e||as}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Oc(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Mc(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Dc(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Dc(t[0],`
|
|
22
|
+
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Dc(t[0],`
|
|
23
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Dc(t[0],`
|
|
24
|
+
`).split(`
|
|
25
|
+
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
26
|
+
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
27
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
28
|
+
${s}`:s,r=r?`${r}
|
|
29
|
+
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
|
|
30
|
+
`),o=t.raw+`
|
|
31
|
+
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s,n=`${n}
|
|
32
|
+
${a}`,r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
33
|
+
`+e.join(`
|
|
34
|
+
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
35
|
+
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=Ac(t[2].split(`
|
|
36
|
+
`,1)[0],t[1].length),l=e.split(`
|
|
37
|
+
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
38
|
+
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
|
|
39
|
+
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
40
|
+
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
41
|
+
`+l}u=!l.trim(),r+=p+`
|
|
42
|
+
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Oc(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:Dc(t[0],`
|
|
43
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ec(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
44
|
+
`):[],a={type:`table`,raw:Dc(t[0],`
|
|
45
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Ec(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:Dc(t[0],`
|
|
46
|
+
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
47
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Dc(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=kc(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),jc(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return jc(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Pc=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||as,this.options.tokenizer=this.options.tokenizer||new Nc,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let t={other:us,block:bc.normal,inline:xc.normal};this.options.pedantic?(t.block=bc.pedantic,t.inline=xc.pedantic):this.options.gfm&&(t.block=bc.gfm,t.inline=this.options.breaks?xc.breaks:xc.gfm),this.tokenizer.rules=t}static get rules(){return{block:bc,inline:xc}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(us.carriageReturn,`
|
|
48
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(us.tabCharGlobal,` `).replace(us.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
49
|
+
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
50
|
+
`)?``:`
|
|
51
|
+
`)+i.raw,n.text+=`
|
|
52
|
+
`+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
53
|
+
`)?``:`
|
|
54
|
+
`)+i.raw,n.text+=`
|
|
55
|
+
`+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
56
|
+
`)?``:`
|
|
57
|
+
`)+i.raw,r.text+=`
|
|
58
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
59
|
+
`)?``:`
|
|
60
|
+
`)+i.raw,n.text+=`
|
|
61
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(!(e.charAt(0)===`!`||!Object.hasOwn(this.tokens.links,e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,n.slice(r+1,-1)))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,e=>`+`.repeat(e.length)),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},Fc=class{options;parser;constructor(e){this.options=e||as}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(us.notSpaceStart)?.[0],i=e.replace(us.endingNewline,``)+`
|
|
62
|
+
`;return r?`<pre><code class="language-`+wc(r)+`">`+(n?i:wc(i,!0))+`</code></pre>
|
|
63
|
+
`:`<pre><code>`+(n?i:wc(i,!0))+`</code></pre>
|
|
64
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
65
|
+
${this.parser.parse(e)}</blockquote>
|
|
66
|
+
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
67
|
+
`}hr(e){return`<hr>
|
|
68
|
+
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
69
|
+
`+r+`</`+i+`>
|
|
70
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
71
|
+
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
72
|
+
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
73
|
+
<thead>
|
|
74
|
+
`+t+`</thead>
|
|
75
|
+
`+r+`</table>
|
|
76
|
+
`}tablerow({text:e}){return`<tr>
|
|
77
|
+
${e}</tr>
|
|
78
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
79
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${wc(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Tc(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+wc(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Tc(e);if(i===null)return wc(n);e=i;let a=`<img src="${e}" alt="${wc(n)}"`;return t&&(a+=` title="${wc(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:wc(e.text)}},Ic=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Lc=class e{options;renderer;textRenderer;constructor(e){this.options=e||as,this.options.renderer=this.options.renderer||new Fc,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ic}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Rc=class{options;block;constructor(e){this.options=e||as}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Pc.lex:Pc.lexInline}provideParser(e=this.block){return e?Lc.parse:Lc.parseInline}},zc=new class{defaults=is();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Lc;Renderer=Fc;TextRenderer=Ic;Lexer=Pc;Tokenizer=Nc;Hooks=Rc;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Fc(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Nc(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Rc;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Rc.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Rc.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Pc.lex(e,t??this.defaults)}parser(e,t){return Lc.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Pc.lex:Pc.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Lc.parse:Lc.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Pc.lex:Pc.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Lc.parse:Lc.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
80
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+wc(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Bc(e,t){return zc.parse(e,t)}Bc.options=Bc.setOptions=function(e){return zc.setOptions(e),Bc.defaults=zc.defaults,os(Bc.defaults),Bc},Bc.getDefaults=is,Bc.defaults=as;function Vc(...e){return zc.use(...e),Bc.defaults=zc.defaults,os(Bc.defaults),Bc}Bc.use=Vc,Bc.walkTokens=function(e,t){return zc.walkTokens(e,t)},Bc.parseInline=zc.parseInline,Bc.Parser=Lc,Bc.parser=Lc.parse,Bc.Renderer=Fc,Bc.TextRenderer=Ic,Bc.Lexer=Pc,Bc.lexer=Pc.lex,Bc.Tokenizer=Nc,Bc.Hooks=Rc,Bc.parse=Bc,Bc.options,Bc.setOptions,Bc.walkTokens,Bc.parseInline,Lc.parse,Pc.lex;function Hc(e,t={}){if(e===``)return[];try{return Kc(Bc.lexer(e),t)}catch{return[{kind:`paragraph`,inlines:[{kind:`text`,text:e}]}]}}var Uc=new Set([`http:`,`https:`,`mailto:`]);function Wc(e){try{return Uc.has(new URL(e).protocol)?e:void 0}catch{return}}var Gc=[1,2,3,4,5,6];function Kc(e,t){return e.flatMap(e=>qc(e,t))}function qc(e,t){switch(e.type){case`space`:return[];case`heading`:return[{kind:`heading`,level:Gc[e.depth-1]??6,inlines:Zc(e.tokens,t)??[]}];case`paragraph`:return[{kind:`paragraph`,inlines:Zc(e.tokens,t)??[]}];case`text`:return[{kind:`paragraph`,inlines:Zc(e.tokens,t)??il(e)}];case`code`:return[{kind:`code`,text:e.text,...e.lang?{lang:e.lang}:{}}];case`blockquote`:return[{kind:`quote`,blocks:Kc(e.tokens??[],t)}];case`hr`:return[{kind:`rule`}];case`list`:return[Jc(e,t)];case`table`:return[Xc(e,t)];case`html`:return[{kind:`paragraph`,inlines:nl(e.raw,t)}];default:return[{kind:`paragraph`,inlines:il(e)}]}}function Jc(e,t){let n=e.ordered&&typeof e.start==`number`&&e.start!==1?e.start:void 0;return{kind:`list`,ordered:e.ordered,items:e.items.map(e=>Yc(e,t)),...n===void 0?{}:{start:n}}}function Yc(e,t){let n=Kc(e.tokens.filter(e=>e.type!==`checkbox`),t);if(!e.task)return n;let r={kind:`text`,text:e.checked?`[x] `:`[ ] `},[i,...a]=n;return i?.kind===`paragraph`?[{kind:`paragraph`,inlines:[r,...i.inlines]},...a]:[{kind:`paragraph`,inlines:[r]},...n]}function Xc(e,t){let n=e=>e.map(e=>Zc(e.tokens,t)??[]);return{kind:`table`,header:n(e.header),rows:e.rows.map(n),align:e.align.map(e=>e??void 0)}}function Zc(e,t){return e?.flatMap(e=>Qc(e,t))}function Qc(e,t){switch(e.type){case`text`:return Zc(e.tokens,t)??[{kind:`text`,text:e.text}];case`escape`:return[{kind:`text`,text:e.text}];case`strong`:case`em`:case`del`:return[{kind:e.type,inlines:Zc(e.tokens,t)??[]}];case`codespan`:return[{kind:`code`,text:e.text}];case`br`:return[{kind:`break`}];case`link`:return[$c(e,t)];case`image`:return[tl(e.href,e.text,e.raw,t)];case`html`:return nl(e.text,t);default:return il(e)}}function $c(e,t){let n=el(e.href,t.linkBase);return n===void 0?{kind:`text`,text:e.raw}:{kind:`link`,href:n,inlines:Zc(e.tokens,t)??[{kind:`text`,text:e.text}]}}function el(e,t){if(!t)return Wc(e);try{return Wc(new URL(e,t).href)}catch{return}}function tl(e,t,n,r){let i=r.images&&e.trim()?el(e,r.imageBase):void 0;if(!i||!/^https?:\/\//i.test(i))return{kind:`text`,text:n};let a=new URL(i),o=/^\/([^/]+)\/([^/]+)\/(?:blob|raw)\/(.+)$/.exec(a.pathname);a.hostname===`github.com`&&o&&(a.hostname=`raw.githubusercontent.com`,a.pathname=`/${o[1]}/${o[2]}/${o[3]}`);let s=a.hostname===`raw.githubusercontent.com`||a.hostname===`github.com`&&a.pathname.startsWith(`/user-attachments/assets/`);return{kind:`image`,src:r.imageProxy&&s?`${r.imageProxy}${encodeURIComponent(a.href)}`:a.href,alt:t}}function nl(e,t){let n=e.match(/<img\b(?:[^"'<>]|"[^"]*"|'[^']*')*\/?>/gi);return!t.images||!n||n.join(``).replace(/\s/g,``)!==e.replace(/\s/g,``)?[{kind:`text`,text:e}]:n.map(e=>{let n=new Map;for(let t of e.slice(4,-1).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let e=t[1].toLowerCase();n.has(e)||n.set(e,rl(t[2]??t[3]??t[4]??``))}return tl(n.get(`src`)??``,n.get(`alt`)??`Screenshot`,e,t)})}function rl(e){let t={amp:`&`,quot:`"`,apos:`'`,lt:`<`,gt:`>`};return e.replace(/&(#x[0-9a-f]+|#\d+|amp|quot|apos|lt|gt);/gi,(e,n)=>{if(!n.startsWith(`#`))return t[n.toLowerCase()]??e;let r=n[1]?.toLowerCase()===`x`?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return r>0&&r<=1114111?String.fromCodePoint(r):e})}function il(e){return[{kind:`text`,text:e.raw}]}var al=(0,H.createContext)(void 0),ol=al.Provider;function sl(){return(0,H.useContext)(al)}var cl=(0,H.createContext)(void 0),ll=cl.Provider;function ul(e){let t=(0,H.useContext)(cl),n=e?.startsWith(`flow-diff`)?t?.excerpts[e]:void 0;return n&&{excerpt:n,openDiff:t.openDiff}}function dl({excerpt:e,openDiff:t}){return(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-lg border bg-muted`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-3 py-1 font-mono text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`min-w-0 break-all`,children:e.path}),t?(0,U.jsx)(O,{size:`xs`,variant:`link`,className:`h-auto px-0`,onClick:()=>t(e),children:`Open in diff`}):null]}),(0,U.jsx)(`pre`,{className:`overflow-x-auto p-3`,children:(0,U.jsx)(`code`,{className:`font-mono text-sm`,children:(0,U.jsx)(rs,{hunks:e.hunks,deleted:e.deleted})})})]})}function fl(e){let t=hl(e);if(t===void 0)return;let[n,r,i,a]=t;return n?r?(i===`pull`||i===`issues`)&&a?`${n}/${r}#${a}`:i===`commit`&&a?`${n}/${r}@${a.slice(0,7)}`:t.join(`/`):n:`github.com`}function pl(e,t){let n=ml(e);return n!==void 0&&n===ml(t)}function ml(e){let[t,n,r,i]=hl(e)??[];return r===`pull`&&i?`${t}/${n}/${i}`.toLowerCase():void 0}function hl(e){let t;try{t=new URL(e)}catch{return}if(t.hostname===`github.com`||t.hostname===`www.github.com`)return t.pathname.split(`/`).filter(Boolean)}function gl({blocks:e,query:t,trailing:n}){return(0,U.jsx)(`div`,{className:`space-y-3 text-sm leading-relaxed`,children:(0,U.jsx)(_l,{blocks:e,query:t,trailing:n})})}function _l({blocks:e,query:t,trailing:n}){return(0,U.jsx)(U.Fragment,{children:e.map((r,i)=>(0,U.jsx)(yl,{block:r,query:t,trailing:i===e.length-1?n:void 0},i))})}var vl={1:`text-lg`,2:`text-base`};function yl({block:e,query:t,trailing:n}){switch(e.kind){case`paragraph`:return(0,U.jsxs)(`p`,{className:`m-0 [overflow-wrap:anywhere]`,children:[(0,U.jsx)(wl,{inlines:e.inlines,query:t}),n]});case`heading`:{let r=`h${e.level}`;return(0,U.jsxs)(r,{className:g(vl[e.level]??`text-sm`,`m-0 pt-1 font-heading font-semibold tracking-tight [overflow-wrap:anywhere]`),children:[(0,U.jsx)(wl,{inlines:e.inlines,query:t}),n]})}case`code`:return(0,U.jsx)(bl,{block:e,query:t,trailing:n});case`list`:{let r=e.ordered?`ol`:`ul`;return(0,U.jsx)(r,{className:g(`m-0 space-y-1 pl-5 marker:text-muted-foreground`,e.ordered?`list-decimal`:`list-disc`),...e.start===void 0?{}:{start:e.start},children:e.items.map((r,i)=>(0,U.jsx)(`li`,{className:`space-y-2 [overflow-wrap:anywhere]`,children:(0,U.jsx)(_l,{blocks:r,query:t,trailing:i===e.items.length-1?n:void 0})},i))})}case`quote`:return(0,U.jsx)(`blockquote`,{className:`space-y-2 border-l-2 border-border pl-3 text-muted-foreground`,children:(0,U.jsx)(_l,{blocks:e.blocks,query:t,trailing:n})});case`table`:return(0,U.jsx)(Cl,{block:e,query:t,trailing:n});case`rule`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`hr`,{className:`border-border`}),n]})}}function bl({block:e,query:t,trailing:n}){let r=ul(e.lang);return r&&`hunks`in r.excerpt?(0,U.jsx)(dl,{excerpt:r.excerpt,openDiff:r.openDiff}):(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-lg border bg-muted`,children:[e.lang===void 0?null:(0,U.jsx)(`div`,{className:`border-b px-3 py-1 font-mono text-xs text-muted-foreground`,children:e.lang}),(0,U.jsx)(`pre`,{className:`overflow-x-auto p-3`,children:(0,U.jsx)(`code`,{className:`font-mono text-sm`,children:(0,U.jsx)(ns,{text:e.text,lang:e.lang,query:t,trailing:n})})}),r&&`problem`in r.excerpt?(0,U.jsx)(`p`,{role:`status`,className:`border-t px-3 py-1 text-xs text-muted-foreground`,children:r.excerpt.problem}):null]})}var xl={left:`text-left`,center:`text-center`,right:`text-right`},Sl=e=>e===void 0?`text-left`:xl[e]??`text-left`;function Cl({block:e,query:t,trailing:n}){return(0,U.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,U.jsxs)(`table`,{className:`border-collapse text-sm tabular-nums`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsx)(`tr`,{children:e.header.map((n,r)=>(0,U.jsx)(`th`,{className:g(`border-b px-2 py-1 font-semibold`,Sl(e.align[r])),children:(0,U.jsx)(wl,{inlines:n,query:t})},r))})}),(0,U.jsx)(`tbody`,{children:e.rows.map((n,r)=>(0,U.jsx)(`tr`,{children:n.map((n,r)=>(0,U.jsx)(`td`,{className:g(`border-b border-border/50 px-2 py-1`,Sl(e.align[r])),children:(0,U.jsx)(wl,{inlines:n,query:t})},r))},r))})]}),n]})}function wl({inlines:e,query:t}){return(0,U.jsx)(U.Fragment,{children:e.map((e,n)=>(0,U.jsx)(Tl,{inline:e,query:t},n))})}function Tl({inline:e,query:t}){switch(e.kind){case`text`:return(0,U.jsx)(qo,{text:e.text,query:t});case`strong`:return(0,U.jsx)(`strong`,{className:`font-semibold`,children:(0,U.jsx)(wl,{inlines:e.inlines,query:t})});case`em`:return(0,U.jsx)(`em`,{children:(0,U.jsx)(wl,{inlines:e.inlines,query:t})});case`del`:return(0,U.jsx)(`del`,{className:`text-muted-foreground`,children:(0,U.jsx)(wl,{inlines:e.inlines,query:t})});case`code`:return(0,U.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] [overflow-wrap:anywhere]`,children:(0,U.jsx)(qo,{text:e.text,query:t})});case`link`:{let n=fl(e.href);return n===void 0?(0,U.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer noopener`,className:`underline decoration-muted-foreground underline-offset-2 hover:decoration-foreground`,children:(0,U.jsx)(wl,{inlines:e.inlines,query:t})}):(0,U.jsx)(El,{inline:e,label:n,query:t})}case`image`:return(0,U.jsx)(Ol,{src:e.src,alt:e.alt},e.src);case`break`:return(0,U.jsx)(`br`,{})}}function El({inline:e,label:t,query:n}){let[r,...i]=e.inlines,a=i.length===0&&r?.kind===`text`&&r.text===e.href,o=sl();return(0,U.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer noopener`,onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||o?.(e.href)&&t.preventDefault()},className:`inline-flex items-baseline gap-1 rounded-md bg-foreground/8 px-1 py-px align-baseline font-medium hover:bg-foreground/12 [overflow-wrap:anywhere]`,children:[(0,U.jsx)(Dl,{className:`size-3 shrink-0 self-center`}),(0,U.jsx)(`span`,{children:a?(0,U.jsx)(qo,{text:t,query:n}):(0,U.jsx)(wl,{inlines:e.inlines,query:n})})]})}function Dl({className:e}){return(0,U.jsx)(`svg`,{"aria-hidden":!0,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,U.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function Ol({src:e,alt:t}){let[n,r]=(0,H.useState)(!1);return n?(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Image unavailable`,t?`: ${t}`:``,`. Open the pull request on GitHub to view it.`]}):(0,U.jsx)(Mo,{src:e,alt:t,referrerPolicy:`no-referrer`,onError:()=>r(!0),className:`my-2 max-h-[36rem] max-w-full rounded border object-contain`})}var kl=(0,H.createContext)(void 0),Al=kl.Provider;function jl(){return(0,H.useContext)(kl)}function Ml(e){let t=Math.max(0,e.activeSubagents),n=Math.max(0,e.activeBackgroundCalls),r=Math.max(0,e.activeWorkflows??0),i=[t>0?`${t} agent${t===1?``:`s`}`:void 0,n>0?`${n} background call${n===1?``:`s`}`:void 0,r>0?`${r} workflow${r===1?``:`s`}`:void 0].filter(e=>e!==void 0);if(i.length!==0)return`${i.length<3?i.join(` and `):`${i.slice(0,-1).join(`, `)} and ${i.at(-1)}`} running`}function Nl(e){let t=Ml(e);return t===void 0?e.status:`${e.status}, ${t}`}function Pl(e,t){switch(e.status){case`running`:return{label:`started`,at:mo(e.startedAt,t)};case`complete`:return{label:`finished`,at:mo(e.endedAt??e.startedAt,t)};case`aborted`:return{label:`stopped`,at:mo(e.endedAt??e.startedAt,t)};case`error`:return{label:`failed`,at:mo(e.endedAt??e.startedAt,t)}}}function Fl(e=3e4){let[t,n]=(0,H.useState)(()=>Date.now());return(0,H.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Il({input:e,query:t}){let n=ho(e);return n?(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-md border bg-muted`,children:[n.path===void 0?null:(0,U.jsx)(Ll,{path:n.path}),(0,U.jsxs)(`div`,{className:`overflow-x-auto`,children:[n.removed.map((e,n)=>(0,U.jsx)(Rl,{sign:`-`,line:e,query:t,kind:`removed`},`-${n}`)),n.added.map((e,n)=>(0,U.jsx)(Rl,{sign:`+`,line:e,query:t,kind:`added`},`+${n}`))]})]}):null}function Ll({path:e}){let t=e.lastIndexOf(`/`);return(0,U.jsxs)(`p`,{className:`m-0 truncate border-b px-2 py-1 font-mono text-xs`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:t<0?``:`${e.slice(0,t)}/`}),(0,U.jsx)(`span`,{className:`text-foreground`,children:t<0?e:e.slice(t+1)})]})}function Rl({sign:e,line:t,query:n,kind:r}){return(0,U.jsxs)(`div`,{className:g(`grid grid-cols-[1.25rem_minmax(0,1fr)] font-mono text-xs whitespace-pre`,ts(r)),children:[(0,U.jsx)(`span`,{className:`pl-2 select-none`,"aria-hidden":!0,children:e}),(0,U.jsx)(`span`,{children:(0,U.jsx)(qo,{text:t,query:n})})]})}function zl({entry:e,query:t}){let n=ho(e.input)!==void 0;return(0,U.jsxs)(U.Fragment,{children:[n?null:(0,U.jsx)(Vl,{label:`input`,value:e.input,query:t}),(0,U.jsx)(Vl,{label:`update`,value:e.update,query:t}),(0,U.jsx)(Vl,{label:`result`,value:e.result,query:t})]})}var Bl=2e4;function Vl({label:e,value:t,query:n}){if(t==null||t===``)return null;let r=typeof t==`string`?t:Ul(t);if(r===``)return null;let i=e!==`input`&&r.length<=Bl?Hl(t):void 0;return(0,U.jsxs)(`div`,{className:`mt-1.5 first:mt-0`,children:[(0,U.jsx)(`p`,{className:`m-0 mb-1 text-xs text-muted-foreground`,children:e}),i?i.map(e=>(0,U.jsx)(Vl,{label:e.label,value:e.text,query:n},e.label)):(0,U.jsx)(`pre`,{className:`m-0 max-h-72 overflow-auto rounded-md border bg-muted p-2 font-mono text-xs whitespace-pre-wrap text-foreground [overflow-wrap:anywhere]`,children:r.length>Bl?r:(0,U.jsx)(ns,{text:r,query:n})})]})}function Hl(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=t.content;if(!Array.isArray(n))return;let r=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`text`&&typeof t.text==`string`&&go(t.text)?t.text:void 0};if(!n.some(e=>r(e)!==void 0))return;let i=n.flatMap((e,t)=>{let n=r(e),i=`content ${t+1}`;if(n===void 0)return[{label:i,text:Ul(e)}];let{type:a,text:o,...s}=e,c=[{label:`${i} (text)`,text:n}];return Object.keys(s).length>0&&c.push({label:`${i} metadata`,text:Ul(s)}),c}),{content:a,...o}=t;return Object.keys(o).length>0&&i.push({label:`metadata`,text:Ul(o)}),i}function Ul(e){try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function Wl(e,t){let n=new Date(e),r=n.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?r:`${n.toLocaleDateString(void 0,{day:`numeric`,month:`short`,...n.getFullYear()===t.getFullYear()?{}:{year:`numeric`}})}, ${r}`}var Gl=(0,H.createContext)({}),Kl=Gl.Provider;function ql(){return(0,H.useContext)(Gl).openSession}function Jl(){return(0,H.useContext)(Gl).openDiff}function Yl({userMessageId:e}){let{rewind:t,fork:n}=(0,H.useContext)(Gl);return(0,U.jsxs)(U.Fragment,{children:[t?(0,U.jsxs)(Xl,{icon:(0,U.jsx)(Hn,{"aria-hidden":!0}),label:t.blocked??`Rewind to before this message`,disabled:t.blocked!==void 0,children:[(0,U.jsx)(ao,{onClick:()=>t.run(e,`conversation`),children:`Conversation`}),t.files?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ao,{onClick:()=>t.run(e,`files`),children:`Code`}),(0,U.jsx)(ao,{onClick:()=>t.run(e,`both`),children:`Both`})]}):null]}):null,n?(0,U.jsxs)(Xl,{icon:(0,U.jsx)(Nn,{"aria-hidden":!0}),label:`Fork from before this message`,children:[(0,U.jsx)(ao,{onClick:()=>n.run(e,!1),children:`Same Scope`}),n.worktree?(0,U.jsx)(ao,{onClick:()=>n.run(e,!0),children:`New Worktree`}):null]}):null]})}function Xl({icon:e,label:t,disabled:n=!1,children:r}){return(0,U.jsxs)(no,{children:[(0,U.jsxs)(ga,{children:[(0,U.jsx)(_a,{render:(0,U.jsx)(ro,{disabled:n,render:(0,U.jsx)(O,{variant:`ghost`,size:`icon-xs`,"aria-label":t,children:e})})}),(0,U.jsx)(va,{children:t})]}),(0,U.jsx)(io,{className:`min-w-40`,children:r})]})}var Zl=(0,H.memo)(function(e){return e.entry.rewound?(0,U.jsx)(`div`,{className:`opacity-50`,children:Ql(e)}):Ql(e)});function Ql({entry:e,query:t,sessionId:n,background:r}){switch(e.kind){case`user`:return(0,U.jsx)($l,{entry:e,query:t,sessionId:n});case`assistant`:return(0,U.jsx)(tu,{entry:e,query:t});case`thinking`:return(0,U.jsx)(iu,{entry:e,query:t});case`tool`:return(0,U.jsx)(au,{entry:e,query:t,background:r});case`subagent`:return(0,U.jsx)(cu,{entry:e,query:t});case`background_call`:return(0,U.jsx)(uu,{entry:e});case`enquiry`:return(0,U.jsx)(ou,{entry:e,query:t});case`notice`:return(0,U.jsx)(hu,{entry:e,query:t});case`marker`:return(0,U.jsx)(_u,{entry:e});default:return null}}function $l({entry:e,query:t,sessionId:n}){let r=(0,H.useMemo)(()=>Hc(e.text),[e.text]);return(0,U.jsxs)(`div`,{className:`group/message relative flex flex-col items-end py-3 before:absolute before:inset-y-0 before:-right-[100vw] before:-left-[100vw] before:content-['']`,children:[(0,U.jsxs)(`div`,{className:g(`relative min-w-0 max-w-[90%] rounded-2xl rounded-br-sm px-4 py-3 sm:max-w-[80%]`,e.fromSessionId===void 0&&e.producer===void 0?`bg-muted`:`border border-border bg-muted/40 text-muted-foreground`),children:[e.fromSessionId===void 0?null:(0,U.jsxs)(`p`,{className:`m-0 mb-2 text-xs text-muted-foreground`,children:[`From `,(0,U.jsx)(mu,{sessionId:e.fromSessionId,query:t})]}),e.producer===void 0?null:(0,U.jsx)(`p`,{className:`m-0 mb-2 text-xs text-muted-foreground`,children:`From the parent agent`}),e.attachments?.length?(0,U.jsx)(eu,{ids:e.attachments,sessionId:n}):null,(0,U.jsx)(gl,{blocks:r,query:t}),e.note===void 0?null:(0,U.jsx)(`p`,{className:`-mx-4 -mb-3 mt-3 rounded-b-2xl rounded-br-sm border-t border-border bg-background/60 px-4 py-2 text-xs text-muted-foreground`,children:e.note.replace(/^\[Flow\] /,``)})]}),e.at?(0,U.jsx)(nu,{at:e.at,side:`right`,children:e.rewound||e.producer?null:(0,U.jsx)(`span`,{className:`inline-flex [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/message:opacity-100 focus-within:opacity-100 has-[[aria-expanded=true]]:opacity-100`,children:(0,U.jsx)(Yl,{userMessageId:e.id})})}):null]})}function eu({ids:e,sessionId:t}){return(0,U.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:e.map(e=>(0,U.jsx)(Mo,{src:`/api/sessions/${encodeURIComponent(t)}/attachments/${encodeURIComponent(e)}`,alt:``,className:`max-h-64 max-w-full rounded-md border border-border`},e))})}function tu({entry:e,query:t}){let n=(0,H.useMemo)(()=>Hc(e.text),[e.text]),r=Jl(),i=(0,U.jsx)(gl,{blocks:n,query:t,trailing:e.final?void 0:(0,U.jsx)(ru,{})});return(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(vu,{children:e.excerpts?(0,U.jsx)(ll,{value:{excerpts:e.excerpts,openDiff:r},children:i}):i}),e.endedAt?(0,U.jsx)(nu,{at:e.endedAt,side:`left`}):null]})}function nu({at:e,side:t,children:n}){return(0,U.jsxs)(`div`,{className:g(`relative mt-1 flex items-center gap-1 text-xs whitespace-nowrap text-muted-foreground/70`,t===`right`&&`flex-row-reverse @min-[68rem]/transcript:flex-row`,`@min-[68rem]/transcript:absolute @min-[68rem]/transcript:mt-0 @min-[68rem]/transcript:leading-[1.375rem]`,t===`right`?`text-right @min-[68rem]/transcript:bottom-6 @min-[68rem]/transcript:left-full @min-[68rem]/transcript:ml-4`:`@min-[68rem]/transcript:right-full @min-[68rem]/transcript:bottom-1 @min-[68rem]/transcript:mr-4`),children:[(0,U.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:Wl(e,new Date)}),n]})}function ru(){return(0,U.jsx)(`span`,{className:`animate-caret-blink ml-px inline-block w-[1ch] text-primary`,"aria-hidden":!0,children:`▍`})}function iu({entry:e,query:t}){let[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(!1),o=(0,H.useRef)(null),s=(0,H.useMemo)(()=>Hc(e.text),[e.text]),c=e.final&&!n,l=e.text.trim()===``;return(0,H.useLayoutEffect)(()=>{let e=o.current;if(!e||!c)return;let t=new ResizeObserver(()=>a(e.scrollHeight>e.clientHeight+1));return t.observe(e),()=>t.disconnect()},[c,l]),l?null:(0,U.jsxs)(vu,{children:[(0,U.jsx)(`div`,{ref:o,className:g(`text-muted-foreground italic`,c&&`max-h-[4.5rem] overflow-hidden`),children:(0,U.jsx)(gl,{blocks:s,query:t,trailing:e.final?void 0:(0,U.jsx)(ru,{})})}),e.final&&(n||i)?(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(!n),className:`mt-0.5 text-xs text-muted-foreground hover:text-foreground`,children:n?`less`:`more`}):null]})}function au({entry:e,query:t,background:n}){let[r,i]=(0,H.useState)(void 0),a=r??e.status===`error`,o=e.todos?Xo(e.todos):Bi(e.input),s=Vo(e.authorisation),c=To(e);return(0,U.jsxs)(`details`,{open:a,onToggle:e=>i(e.currentTarget.open),className:`group/tool text-foreground`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-default items-center gap-2 rounded-md px-1.5 py-1 select-none hover:bg-muted/50 cursor-tilt relative [--tilt-angle-x:10deg] [--tilt-angle-y:1.5deg] [--tilt-lift:1.005]`,children:[(0,U.jsx)(Do,{name:e.name,className:e.status===`error`||n?.status===`error`?`text-destructive`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 shrink-0 text-sm text-muted-foreground [overflow-wrap:anywhere]`,children:(0,U.jsx)(Lo,{name:e.name})}),o===void 0?null:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground/80`,children:o}),s?(0,U.jsx)(`span`,{className:g(`ml-auto shrink-0 text-xs`,e.authorisation===`denied`?`text-destructive`:e.authorisation===`asked`?`text-status-awaiting`:`text-muted-foreground`),children:s}):e.status===`running`?(0,U.jsx)(In,{"aria-label":`running`,className:`ml-auto size-3.5 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none`}):n?(0,U.jsx)(du,{entry:n}):c?(0,U.jsx)(`span`,{className:g(`ml-auto shrink-0 font-mono text-xs`,e.status===`error`?`text-destructive`:`text-muted-foreground`),children:c}):null]}),(0,U.jsx)(`div`,{className:`my-1 ml-6 rounded-lg border p-3`,children:e.todos?e.todos.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The Todo List was cleared.`}):(0,U.jsx)($o,{items:e.todos,query:t}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Il,{input:e.input,query:t}),(0,U.jsx)(zl,{entry:e,query:t})]})})]})}function ou({entry:e,query:t}){return(0,U.jsx)(`div`,{className:`text-foreground`,children:e.questions.map((n,r)=>(0,U.jsx)(su,{entry:e,index:r,query:t},n.question))})}function su({entry:e,index:t,query:n}){let r=e.questions[t],i=e.answers?.[t]??[],a=r.options.filter(e=>!i.includes(e.label)).map(e=>e.label);return(0,U.jsxs)(`details`,{className:`group/question`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-default items-center gap-2 rounded-md px-1.5 py-1 text-sm select-none hover:bg-muted/50 cursor-tilt relative [--tilt-angle-x:10deg] [--tilt-angle-y:1.5deg] [--tilt-lift:1.005]`,children:[(0,U.jsx)(Ln,{"aria-hidden":!0,className:g(`size-3.5 shrink-0 text-muted-foreground`,t>0&&`invisible`)}),(0,U.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[r.header,` `]}),i.length===0?(0,U.jsx)(`span`,{className:`text-muted-foreground italic`,children:e.status===`asked`?`waiting…`:`no answer`}):(0,U.jsx)(qo,{text:i.join(`, `),query:n})]}),(0,U.jsx)(Tn,{"aria-hidden":!0,className:`ml-auto size-3.5 shrink-0 text-muted-foreground transition-transform group-open/question:rotate-90`})]}),(0,U.jsxs)(`div`,{className:`mt-0.5 mb-1.5 ml-7 space-y-1 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,U.jsx)(`p`,{children:(0,U.jsx)(qo,{text:r.question,query:n})}),a.length===0?null:(0,U.jsxs)(`p`,{className:`text-muted-foreground/70`,children:[i.length===0?`Options: `:`Other options: `,(0,U.jsx)(qo,{text:a.join(` · `),query:n})]})]})]})}function cu({entry:e,query:t}){let n=e.waitingOn?`waiting on ${e.waitingOn}`:e.status,r=e.status===`running`||e.status===`waiting`,i=jl(),a=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Cn,{"aria-hidden":!0,className:g(`size-3.5 shrink-0`,lu(e.status)===`error`?`text-destructive`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:`min-w-0 text-sm text-muted-foreground [overflow-wrap:anywhere] max-sm:col-start-2 max-sm:row-start-1 max-sm:truncate`,children:e.name}),e.description===void 0?null:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground/80 max-sm:col-start-2 max-sm:col-end-4 max-sm:row-start-2`,children:(0,U.jsx)(qo,{text:e.description,query:t})}),(0,U.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground max-sm:col-start-3 max-sm:row-start-1`,children:[r?(0,U.jsx)(In,{"aria-hidden":!0,className:`size-3.5 animate-spin motion-reduce:animate-none`}):null,n]})]}),o=`flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-foreground max-sm:grid max-sm:grid-cols-[14px_minmax(0,1fr)_auto] max-sm:gap-y-1`;return i===void 0?(0,U.jsx)(`div`,{className:o,children:a}):(0,U.jsx)(`button`,{type:`button`,onClick:()=>i(bn(e)),className:g(o,`text-left hover:bg-muted/50 cursor-tilt relative [--tilt-angle-x:10deg] [--tilt-angle-y:1.5deg] [--tilt-lift:1.005]`),children:a})}function lu(e){return e===`error`?`error`:e===`running`?`running`:`complete`}function uu({entry:e}){let t=Pl(e,Fl());return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-1.5 py-1 text-foreground`,children:[(0,U.jsx)(Do,{name:e.tool,className:fu(e.status)===`error`?`text-destructive`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 text-sm text-muted-foreground [overflow-wrap:anywhere]`,children:e.tool}),(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground/70`,children:`in background`}),(0,U.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[e.status===`running`?(0,U.jsx)(In,{"aria-hidden":!0,className:`size-3.5 animate-spin motion-reduce:animate-none`}):null,t.label,` `,t.at]})]})}function du({entry:e}){let t=Pl(e,Fl());return(0,U.jsxs)(`span`,{className:g(`ml-auto flex shrink-0 items-center gap-1.5 text-xs`,e.status===`error`?`text-destructive`:`text-muted-foreground`),children:[e.status===`running`?(0,U.jsx)(In,{"aria-hidden":!0,className:`size-3.5 animate-spin motion-reduce:animate-none`}):null,(0,U.jsx)(`span`,{className:`sr-only`,children:`in background,`}),t.label,` `,t.at]})}function fu(e){return e===`error`?`error`:e===`running`?`running`:`complete`}var pu={info:`text-muted-foreground`,warn:`text-foreground`,error:`text-destructive`};function mu({sessionId:e,query:t}){let{sessions:n}=Ei(),r=n.find(t=>t.id===e);return r?(0,U.jsx)(`a`,{href:Ni({sessionId:r.id}),className:`rounded-sm font-sans font-medium text-foreground outline-none transition-[text-shadow] duration-150 hover:[text-shadow:0_0_8px_color-mix(in_srgb,currentColor_60%,transparent)] focus-visible:ring-3 focus-visible:ring-ring/30`,children:(0,U.jsx)(qo,{text:Ii(r),query:t})}):(0,U.jsx)(`span`,{className:`text-foreground`,children:(0,U.jsx)(qo,{text:e,query:t})})}function hu({entry:e,query:t}){let n=pu[e.level],r=e.sessionId===void 0?-1:e.text.indexOf(e.sessionId);return(0,U.jsx)(vu,{gutter:`!`,gutterClassName:n,children:(0,U.jsx)(`p`,{className:g(`m-0 font-mono text-sm whitespace-pre-wrap [overflow-wrap:anywhere]`,n),children:r===-1||e.sessionId===void 0?(0,U.jsx)(qo,{text:e.text,query:t}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(qo,{text:e.text.slice(0,r),query:t}),(0,U.jsx)(mu,{sessionId:e.sessionId,query:t}),(0,U.jsx)(qo,{text:e.text.slice(r+e.sessionId.length),query:t})]})})})}var gu={revived:`text-primary`,settled:`text-muted-foreground`,dormant:`text-muted-foreground`,compacted:`text-muted-foreground`,rewound:`text-muted-foreground`,forked:`text-muted-foreground`};function _u({entry:e}){let t=gu[e.marker],n=ql();return(0,U.jsxs)(`div`,{className:g(`flex items-center gap-2 py-2`,t),role:`separator`,"aria-label":e.text,children:[(0,U.jsx)(`span`,{className:`h-px flex-1 bg-current opacity-50`,"aria-hidden":!0}),e.fromSessionId&&n?(0,U.jsx)(O,{variant:`link`,size:`xs`,className:`h-auto p-0 text-xs text-current`,onClick:()=>n(e.fromSessionId),children:`Forked from another Agent Session`}):(0,U.jsx)(`span`,{className:`text-xs`,children:e.text}),(0,U.jsx)(`span`,{className:`h-px flex-1 bg-current opacity-50`,"aria-hidden":!0})]})}function vu({gutter:e,gutterClassName:t,children:n}){return(0,U.jsxs)(`div`,{className:g(`py-1`,e&&`grid grid-cols-[2ch_minmax(0,1fr)] gap-0`),children:[e?(0,U.jsx)(`span`,{"aria-hidden":!0,className:g(`font-mono text-sm select-none`,t),children:e}):null,n]})}function yu(e,t=40){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function bu(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function xu(e,t=`|`){return e.map(e=>Ju(e)).join(t)}function Su(e,t){return typeof t==`bigint`?t.toString():t}var Cu=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function wu(e){return new Cu(e)}function Tu(e){return e==null}function Eu(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Du(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Ou=Symbol(`evaluating`);function ku(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ou)return r===void 0&&(r=Ou,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Au(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ju(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Mu(e){return ju(e._zod.def)??e._zod.def.shape}function Nu(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Au(this,t,e),e},enumerable:!0,configurable:!0})}function Pu(e,t,n){t in e?Au(e,t,n):e[t]=n}function Fu(e,t,n,r){let i=Mu(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Nu(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Pu(e,a,r?r(n.value,a):n.value))}}function Iu(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Nu(e,n,()=>t[n]):Pu(e,n,r.value))}}function Lu(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ru(e){return JSON.stringify(e)}function zu(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Bu=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Vu(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Hu=wu(()=>{if(Id.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Uu(e){if(Vu(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Vu(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Wu(e){return Uu(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Gu=new Set([`string`,`number`,`symbol`]);function Ku(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function qu(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function G(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ju(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Yu(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var Xu={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Zu={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Qu(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Fu(i,e,$u(e,t)),qu(e,Lu(n,{shape:i,checks:[]}))}function $u(e,t){let n=Mu(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function ed(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set($u(e,t)),a={};return Fu(a,e,Reflect.ownKeys(Mu(e)).filter(e=>!i.has(e))),qu(e,Lu(n,{shape:a,checks:[]}))}function td(e,t){if(!Uu(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Mu(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return qu(e,Lu(e._zod.def,{shape:nd(e,t)}))}function nd(e,t){let n={};return Fu(n,e,Reflect.ownKeys(Mu(e))),Iu(n,t),n}function rd(e,t){if(!Uu(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return qu(e,Lu(e._zod.def,{shape:nd(e,t)}))}function id(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Fu(n,e,Reflect.ownKeys(Mu(e))),Fu(n,t,Reflect.ownKeys(Mu(t))),qu(e,Lu(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ad(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set($u(t,n)):void 0,o={};return Fu(o,t,Reflect.ownKeys(Mu(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),qu(t,Lu(t._zod.def,{shape:o,checks:[]}))}function od(e,t,n){let r=n?new Set($u(t,n)):void 0,i={};return Fu(i,t,Reflect.ownKeys(Mu(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),qu(t,Lu(t._zod.def,{shape:i}))}function sd(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function cd(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ld(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ud(e){return typeof e==`string`?e:e?.message}function dd(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function fd(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:ud(e.inst?._zod.def?.error?.(e))??ud(a?.(e))??ud(t?.error?.(e))??ud(n.customError?.(e))??ud(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var pd=/[\uD800-\uDBFF]/;function md(e){let t=e.length;if(!pd.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function hd(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function gd(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function _d(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function vd(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Sd(e,n,r.value)}}function yd(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function bd(e,t,n){return yd(e,t,n,!1)}function xd(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return yd(this,n,r(this))},set(e){yd(this,n,e)}})}return t}function Sd(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:yd(this,t,n.bind(this))},set(e){yd(this,t,e)}})}function Cd(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var wd,Td=!1,Ed={configurable:!0,get(){Td=!0}};function K(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&wd!==e._zod){wd=void 0;return}wd=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Ed);let e=Td;Td=!1;try{let r=n(this);return Td?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Td||=e,r}catch(n){throw delete this[t],Td||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Dd(e,t,n,r){let i=Cd(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Od=`~constantCatch`;function kd(e){let t=()=>e;return t[Od]=!0,t}var Ad,jd={value:void 0,enumerable:!1},Md=`captureStackTrace`in Error?Error:null;function Nd(e){let t=Md;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Md=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function q(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){jd.value=new a(r);try{Object.defineProperty(n,"_zod",jd)}finally{jd.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),vd(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Nd(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Pd=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Fd=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Ad=globalThis).__zod_globalConfig??(Ad.__zod_globalConfig={});var Id=globalThis.__zod_globalConfig;function Ld(e){return e&&Object.assign(Id,e),Id}function Rd(){let e=this._zod;return e.message??=JSON.stringify(e.def,Su,2),e.message}function zd(e){this._zod.message=e}var Bd={get:Rd,set:zd,enumerable:!0,configurable:!0},Vd={value:void 0,enumerable:!1},Hd=new WeakSet([Object.prototype,Error.prototype]),Ud=(e,t)=>{e.name=`$ZodError`,Vd.value=t,Object.defineProperty(e,"issues",Vd),Vd.value=void 0,Object.defineProperty(e,"message",Bd);let n=Object.getPrototypeOf(e);Hd.has(n)||(Hd.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Wd=q(`$ZodError`,Ud);q(`$ZodError`,Ud,void 0,{Parent:Error});function Gd(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Kd(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Gd(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function qd(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Jd(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Yd=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Pd;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>fd(e,o,Ld())));throw Bu(n,a?.callee??t),n}return s.value};return t},Xd=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>fd(e,o,Ld())));throw Bu(n,a?.callee??t),n}return s.value};return t},Zd=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Pd;return a.issues.length?Qd(e,a.issues,i):{success:!0,data:a.value}};function Qd(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>fd(e,n,Ld()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var $d=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Qd(e,a.issues,i):{success:!0,data:a.value}},ef=Symbol.for(`zod.compile.invalid`),tf=Symbol.for(`zod.compile.fallback`),nf=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==ef)return!0;if(r.definite===!0&&n===void 0)return!1}return rf(e,t,n)});function rf(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[tf]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Pd;return a.issues.length===0}var af=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},of=e=>{let t=Yd(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Jd(n,a))};return n},sf=e=>{let t=Yd(e),n=(e,r,i,a)=>t(e,r,i,Jd(n,a));return n},cf=e=>{let t=Xd(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Jd(n,a))};return n},lf=e=>{let t=Xd(e),n=async(e,r,i,a)=>await t(e,r,i,Jd(n,a));return n},uf=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Zd(e)(t,n,i)},df=e=>(t,n,r)=>Zd(e)(t,n,r),ff=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return $d(e)(t,n,i)},pf=e=>async(t,n,r)=>$d(e)(t,n,r),mf=/^[cC][0-9a-z]{6,}$/,hf=/^[0-9a-z]+$/,gf=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,_f=/^[0-9a-vA-V]{20}$/,vf=/^[A-Za-z0-9]{27}$/,yf=/^[a-zA-Z0-9_-]{21}$/;function bf(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var xf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Sf=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Cf=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,wf=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Tf=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Ef(){return new RegExp(Tf,`u`)}var Df=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Of=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,kf=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Af=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Mf=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Nf=/^https?$/,Pf=/^\+[1-9]\d{6,14}$/,Ff=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function If(e){return RegExp(`^${e}$`)}var Lf=If(Ff);function Rf(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function zf(e){return RegExp(`^${Rf(e)}$`)}function Bf(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Rf({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Rf({precision:e.precision})}`:n;return RegExp(`^${Ff}T(?:${r})$`)}var Vf=/^[\s\S]{0,}$/,Hf=/^-?\d+$/,Uf=/^-?\d+(?:\.\d+)?$/,Wf=/^(?:true|false)$/i,Gf=/^null$/i,Kf=/^[^A-Z]*$/,qf=/^[^a-z]*$/,Jf=q(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Yf=e=>{let t=e.value;return!Tu(t)&&t.length!==void 0},Xf={number:`number`,bigint:`bigint`,object:`date`},Zf=q(`$ZodCheckLessThan`,(e,t)=>{Jf.init(e,t);let n=Xf[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Xf[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Qf=q(`$ZodCheckGreaterThan`,(e,t)=>{Jf.init(e,t);let n=Xf[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Xf[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$f=q(`$ZodCheckMultipleOf`,(e,t)=>{Jf.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Du(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ep=q(`$ZodCheckNumberFormat`,(e,t)=>{Jf.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Xu[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),tp=q(`$ZodCheckMaxLength`,(e,t)=>{var n;Jf.init(e,t),(n=e._zod.def).when??(n.when=Yf),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?md(r):i)<=t.maximum)return;let a=hd(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),np=q(`$ZodCheckMinLength`,(e,t)=>{var n;Jf.init(e,t),(n=e._zod.def).when??(n.when=Yf),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?md(r):i)>=t.minimum)return;let a=hd(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),rp=q(`$ZodCheckLengthEquals`,(e,t)=>{var n;Jf.init(e,t),(n=e._zod.def).when??(n.when=Yf),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?md(r):i;if(a===t.length)return;let o=hd(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ip=q(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Jf.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ap=q(`$ZodCheckRegex`,(e,t)=>{ip.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),op=q(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Kf,ip.init(e,t)}),sp=q(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=qf,ip.init(e,t)}),cp=q(`$ZodCheckIncludes`,(e,t)=>{Jf.init(e,t);let n=Ku(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),lp=q(`$ZodCheckStartsWith`,(e,t)=>{Jf.init(e,t);let n=RegExp(`^${Ku(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),up=q(`$ZodCheckEndsWith`,(e,t)=>{Jf.init(e,t);let n=RegExp(`.*${Ku(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),dp=q(`$ZodCheckOverwrite`,(e,t)=>{Jf.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),fp=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
81
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
82
|
+
`)}\n};`)(...Object.values(this.closed))}},pp={major:4,minor:6,patch:5},mp=q(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pp;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=sd(t),a;for(let o of n){if(o._zod.def.when){if(cd(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Pd;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(dd(t.issues,n,e),i||=sd(t,n))});else{if(t.issues.length===n)continue;dd(t.issues,n,e),i||=sd(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(sd(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Pd;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Pd;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return bd(this,`~standard`,_p(this))},set"~standard"(e){yd(this,`~standard`,e)}}),hp=(e,t)=>e.issues.length?{issues:e.issues.map(e=>fd(e,t,Ld()))}:{value:e.value};async function gp(e,t){let n={async:!0};return hp(await e._zod.run({value:t,issues:[]},n),n)}function _p(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return hp(r,n)}catch{}return gp(e,t)},vendor:`zod`,version:1}}var vp=q(`$ZodString`,(e,t)=>{mp.init(e,t),e._zod.pattern=t.pattern??Vf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),yp=q(`$ZodStringFormat`,(e,t)=>{ip.init(e,t),vp.init(e,t)}),bp=q(`$ZodGUID`,(e,t)=>{t.pattern??=Sf,yp.init(e,t)}),xp=q(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Cf(e)}else t.pattern??=Cf();yp.init(e,t)}),Sp=q(`$ZodEmail`,(e,t)=>{t.pattern??=wf,yp.init(e,t)});function Cp(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function wp(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Cp(e)||2:Tp(e,t)}function Tp(e,t){if(!t.normalize&&t.protocol?.source===Nf.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Ep=/[\t\n\r]/g;function Dp(e){return e.replace(Ep,``)}function Op(e,t){return t.lastIndex=0,t.test(e.hostname)}function kp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Ap=q(`$ZodURL`,(e,t)=>{yp.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=wp(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Dp(r);return}t.hostname&&!Op(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!kp(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Dp(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),jp=q(`$ZodEmoji`,(e,t)=>{t.pattern??=Ef(),yp.init(e,t)}),Mp=q(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?yf:bf(t.length),yp.init(e,t)}),Np=q(`$ZodCUID`,(e,t)=>{t.pattern??=mf,yp.init(e,t)}),Pp=q(`$ZodCUID2`,(e,t)=>{t.pattern??=hf,yp.init(e,t)}),Fp=q(`$ZodULID`,(e,t)=>{t.pattern??=gf,yp.init(e,t)}),Ip=q(`$ZodXID`,(e,t)=>{t.pattern??=_f,yp.init(e,t)}),Lp=q(`$ZodKSUID`,(e,t)=>{t.pattern??=vf,yp.init(e,t)}),Rp=q(`$ZodISODateTime`,(e,t)=>{t.pattern??=Bf(t),yp.init(e,t)}),zp=q(`$ZodISODate`,(e,t)=>{t.pattern??=Lf,yp.init(e,t)}),Bp=q(`$ZodISOTime`,(e,t)=>{t.pattern??=zf(t),yp.init(e,t)}),Vp=q(`$ZodISODuration`,(e,t)=>{t.pattern??=xf,yp.init(e,t)}),Hp=q(`$ZodIPv4`,(e,t)=>{t.pattern??=Df,yp.init(e,t)}),Up=/^[0-9a-fA-F:.]+$/;function Wp(e){return Up.test(e)?Cp(`http://[${e}]`):!1}var Gp=q(`$ZodIPv6`,(e,t)=>{t.pattern??=Of,yp.init(e,t),e._zod.check=n=>{Wp(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Kp=q(`$ZodCIDRv4`,(e,t)=>{t.pattern??=kf,yp.init(e,t)});function qp(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Wp(n)}var Jp=q(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Af,yp.init(e,t),e._zod.check=n=>{qp(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Yp(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Xp=/^[0-9a-zA-Z+/]*={0,2}$/,Zp=q(`$ZodBase64`,(e,t)=>{t.pattern??=Xp,yp.init(e,t),e._zod.check=n=>{Yp(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Qp=/^[A-Za-z0-9_-]*$/;function $p(e){if(!Qp.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Yp(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var em=q(`$ZodBase64URL`,(e,t)=>{t.pattern??=Qp,yp.init(e,t),e._zod.check=n=>{$p(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),tm=q(`$ZodE164`,(e,t)=>{t.pattern??=Pf,yp.init(e,t)});function nm(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var rm=q(`$ZodJWT`,(e,t)=>{yp.init(e,t),e._zod.check=n=>{nm(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),im=q(`$ZodNumber`,(e,t)=>{mp.init(e,t),e._zod.pattern=Uf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),am=q(`$ZodNumberFormat`,(e,t)=>{ep.init(e,t),im.init(e,t)}),om=q(`$ZodBoolean`,(e,t)=>{mp.init(e,t),e._zod.pattern=Wf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),sm=q(`$ZodNull`,(e,t)=>{mp.init(e,t),e._zod.pattern=Gf,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),cm=q(`$ZodUnknown`,(e,t)=>{mp.init(e,t),e._zod.parse=e=>e}),lm=q(`$ZodNever`,(e,t)=>{mp.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function um(e,t,n){e.issues.length&&t.issues.push(...ld(n,e.issues)),t.value[n]=e.value}var dm=q(`$ZodArray`,(e,t)=>{mp.init(e,t);let n=Id.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>um(t,r,e)));else if(um(c,r,e),s&&c.issues.length!==0&&sd(c))break}return o.length?Promise.all(o).then(()=>r):r}});function fm(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...ld(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var pm=[];function mm(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:pm,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Yu(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function hm(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(sd(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>fm(e,n,i,t,d,f))):fm(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var gm=q(`$ZodObject`,(e,t)=>{mp.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=wu(()=>mm(t));K(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Au(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Vu,o=t.catchall,s,c=Id.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(sd(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>fm(n,t,e,r,a,o))):fm(s,t,e,r,a,o)}return o?hm(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),_m=q(`$ZodObjectJIT`,(e,t)=>{gm.init(e,t);let n=e._zod.parse,r=wu(()=>mm(t)),i=Id.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new fp([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
83
|
+
let ${e}_ab = false;
|
|
84
|
+
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
85
|
+
const iss = ${e}.issues[i];
|
|
86
|
+
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
87
|
+
payload.issues.push(iss);
|
|
88
|
+
if (iss.continue !== true) ${e}_ab = true;
|
|
89
|
+
}
|
|
90
|
+
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
91
|
+
payload.value = newResult;
|
|
92
|
+
return payload;
|
|
93
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Ru(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
94
|
+
const ${n}_present = ${i};
|
|
95
|
+
if (!${n}.issues.length || ${n}_present) {
|
|
96
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (${e}) {
|
|
100
|
+
newResult[${r}] = ${n}.value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
`)}else f?(o.write(`
|
|
105
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
106
|
+
}
|
|
107
|
+
`),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
|
|
108
|
+
if (${n}.value !== undefined || ${i}) {
|
|
109
|
+
newResult[${r}] = ${n}.value;
|
|
110
|
+
}
|
|
111
|
+
`)):o.write(`
|
|
112
|
+
const ${n}_present = ${i};
|
|
113
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
114
|
+
}
|
|
115
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
116
|
+
payload.issues.push({
|
|
117
|
+
code: "invalid_type",
|
|
118
|
+
expected: "nonoptional",
|
|
119
|
+
input: undefined,
|
|
120
|
+
path: [${r}]
|
|
121
|
+
});
|
|
122
|
+
if (ctx && ctx.abortEarly) {
|
|
123
|
+
payload.value = newResult;
|
|
124
|
+
return payload;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (${n}_present) {
|
|
129
|
+
newResult[${r}] = ${n}.value;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Vu,c=!Id.jitless,l=c&&Hu.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?hm([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function vm(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!sd(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>fd(e,r,Ld())))}),t)}var ym=q(`$ZodUnion`,(e,t)=>{mp.init(e,t),K(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),K(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),K(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),K(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Eu(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>vm(t,r,e,i)):vm(o,r,e,i)}});function bm(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var xm=q(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ym.init(e,t);let n=e._zod.parse;K(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Au(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=ju(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=wu(()=>bm(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Vu(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Sm=q(`$ZodIntersection`,(e,t)=>{mp.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>wm(e,t,n)):wm(e,i,a)}});function Cm(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Uu(e)&&Uu(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Cm(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Cm(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function wm(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Cm(t.value,n.value);if(!c.valid){if(sd(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Tm=q(`$ZodRecord`,(e,t)=>{mp.init(e,t);let n=Id.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Uu(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>fd(e,i,Ld())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...ld(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...ld(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Uf.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>fd(e,i,Ld())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...ld(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...ld(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Em=q(`$ZodEnum`,(e,t)=>{mp.init(e,t);let n=bu(t.entries),r=new Set(n);e._zod.values=r,K(e,`pattern`,e=>{let t=bu(e.def.entries).filter(e=>Gu.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Ku(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Dm=q(`$ZodLiteral`,(e,t)=>{mp.init(e,t);let n=new Set(t.values);e._zod.values=n,K(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Ku(e):e?Ku(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Om=q(`$ZodTransform`,(e,t)=>{mp.init(e,t),e._zod.optin=`optional`,Id.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fd(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Pd;return n.value=i,n}});function km(e,t){return e.value=t.issues.length?void 0:t.value,e}var Am=q(`$ZodOptional`,(e,t)=>{mp.init(e,t),K(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,K(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),K(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Eu(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>km(e,t)):km(e,r)}return t.innerType._zod.run(e,n)}}),jm=q(`$ZodExactOptional`,(e,t)=>{Am.init(e,t),K(e,`values`,e=>e.def.innerType._zod.values),K(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Mm=q(`$ZodNullable`,(e,t)=>{mp.init(e,t),K(e,`optin`,e=>e.def.innerType._zod.optin),K(e,`optout`,e=>e.def.innerType._zod.optout),K(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Eu(t.source)}|null)$`):void 0}),K(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Nm=q(`$ZodDefault`,(e,t)=>{mp.init(e,t),e._zod.optin=`defaulted`,K(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Pm(e,t)):Pm(r,t)}});function Pm(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Fm=q(`$ZodPrefault`,(e,t)=>{mp.init(e,t),e._zod.optin=`defaulted`,K(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Im=q(`$ZodNonOptional`,(e,t)=>{mp.init(e,t),K(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Lm(t,e)):Lm(i,e)}});function Lm(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Rm(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>fd(e,r,Ld()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var zm=q(`$ZodCatch`,(e,t)=>{mp.init(e,t),K(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),K(e,`optout`,e=>e.def.innerType._zod.optout),K(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Rm(e,r,t,n)):Rm(e,r,t,n)}}),Bm=q(`$ZodPipe`,(e,t)=>{mp.init(e,t),K(e,`values`,e=>e.def.in._zod.values),K(e,`optin`,e=>e.def.in._zod.optin),K(e,`optout`,e=>e.def.out._zod.optout),K(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Vm(e,t.in,n)):Vm(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Vm(e,t.out,n)):Vm(r,t.out,n)}});function Vm(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Hm=q(`$ZodReadonly`,(e,t)=>{mp.init(e,t),K(e,`propValues`,e=>e.def.innerType._zod.propValues),K(e,`values`,e=>e.def.innerType._zod.values),K(e,`optin`,e=>e.def.innerType?._zod?.optin),K(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Um):Um(r)}});function Um(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Wm=q(`$ZodLazy`,(e,t)=>{mp.init(e,t),ku(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),K(e,`pattern`,e=>e.innerType?._zod?.pattern),K(e,`propValues`,e=>e.innerType?._zod?.propValues),K(e,`optin`,e=>e.innerType?._zod?.optin??void 0),K(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Gm=q(`$ZodCustom`,(e,t)=>{Jf.init(e,t),mp.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Km(t,n,r,e));Km(i,n,r,e)}});function Km(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(_d(e))}}var qm=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Jm=`~memo`,Ym=[];function Xm(e){return typeof e==`object`&&!!e}function Zm(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Qm=new WeakMap,$m=0,eh=1,th=2;function nh(e,t,n){let r=Qm.get(e);if(r!==void 0)return r?th:$m;if(t.has(e))return th;t.add(e);let i=$m,a=e=>{if(i!==th&&e?._zod){let r=nh(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=$m;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?eh:o.value?._zod?nh(o.value,t,n):$m;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=ju(c);s(e?o(e,!0):eh),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?nh(r,t,!1):eh);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),rh(e,i)}function rh(e,t){return t!==eh&&Qm.set(e,t===th),t}function ih(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var ah,oh=[],sh={alloc(e,t,n){let r=ah;if(!r)return n;ah=void 0;let i={value:n,issues:null};return r.set(t.value,i),oh.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&lh(n,e.value))throw new qm;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=nh(e,new Set,!1);if(i===$m)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===th||r?n=!0:r=!0}let l=s.value;if(!Xm(l))return t(s,c);let u=c[Jm];u||(u={buckets:new WeakMap,backEdges:void 0},c[Jm]=u);let d;i===c?d=a:(d=ih(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Zm(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;ah=d;let p=oh.length,m=t(s,c);ah=void 0;let h=oh.length>p?oh.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Zm(e.issues):Ym),e)):(h&&(h.issues=m.issues.length?Zm(m.issues):Ym),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ch(){return sh}function lh(e,t){let n=e[Jm]?.backEdges;return n!==void 0&&Xm(t)&&n.has(t)}var uh=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(gd(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Ju(e.values[0])}`:`Invalid option: expected one of ${xu(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${xu(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function dh(){return{localeError:uh()}}var fh,ph=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function mh(){return new ph}(fh=globalThis).__zod_globalRegistry??(fh.__zod_globalRegistry=mh());var hh=globalThis.__zod_globalRegistry;function gh(e){return e.checks&&=[...e.checks],e}function _h(e,t){return new e(gh({type:`string`,...G(t)}))}function vh(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...G(t)})}function yh(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...G(t)})}function bh(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...G(t)})}function xh(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...G(t)})}function Sh(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...G(t)})}function Ch(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...G(t)})}function wh(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...G(t)})}function Th(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...G(t)})}function Eh(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...G(t)})}function Dh(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...G(t)})}function Oh(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...G(t)})}function kh(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...G(t)})}function Ah(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...G(t)})}function jh(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...G(t)})}function Mh(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...G(t)})}function Nh(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...G(t)})}function Ph(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...G(t)})}function Fh(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...G(t)})}function Ih(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...G(t)})}function Lh(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...G(t)})}function Rh(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...G(t)})}function zh(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...G(t)})}function Bh(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...G(t)})}function Vh(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...G(t)})}function Hh(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...G(t)})}function Uh(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...G(t)})}function Wh(e,t){return new e(gh({type:`number`,checks:[],...G(t)}))}function Gh(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...G(t)})}function Kh(e,t){return new e({type:`boolean`,...G(t)})}function qh(e,t){return new e({type:`null`,...G(t)})}function Jh(e){return new e({type:`unknown`})}function Yh(e,t){return new e({type:`never`,...G(t)})}function Xh(e,t){return new Zf({check:`less_than`,...G(t),value:e,inclusive:!1})}function Zh(e,t){return new Zf({check:`less_than`,...G(t),value:e,inclusive:!0})}function Qh(e,t){return new Qf({check:`greater_than`,...G(t),value:e,inclusive:!1})}function $h(e,t){return new Qf({check:`greater_than`,...G(t),value:e,inclusive:!0})}function eg(e,t){return new $f({check:`multiple_of`,...G(t),value:e})}function tg(e,t){return new tp({check:`max_length`,...G(t),maximum:e})}function ng(e,t){return new np({check:`min_length`,...G(t),minimum:e})}function rg(e,t){return new rp({check:`length_equals`,...G(t),length:e})}function ig(e,t){return new ap({check:`string_format`,format:`regex`,...G(t),pattern:e})}function ag(e){return new op({check:`string_format`,format:`lowercase`,...G(e)})}function og(e){return new sp({check:`string_format`,format:`uppercase`,...G(e)})}function sg(e,t){return new cp({check:`string_format`,format:`includes`,...G(t),includes:e})}function cg(e,t){return new lp({check:`string_format`,format:`starts_with`,...G(t),prefix:e})}function lg(e,t){return new up({check:`string_format`,format:`ends_with`,...G(t),suffix:e})}function ug(e){return new dp({check:`overwrite`,tx:e})}function dg(e){return ug(t=>t.normalize(e))}function fg(){return ug(e=>e.trim())}function pg(){return ug(e=>e.toLowerCase())}function mg(){return ug(e=>e.toUpperCase())}function hg(){return ug(e=>zu(e))}function gg(e,t,n){return new e({type:`array`,element:t,...G(n)})}function _g(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...G(n)})}function vg(e,t){let n=yg(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(_d(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(_d(r))}},e(t.value,t)),t);return n}function yg(e,t){let n=new Jf({check:`custom`,...G(t)});return n._zod.check=e,n}function bg(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Au(e,t,n[t]);return e}function xg(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??hh,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Sg(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Cg(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Cg(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&bg(o.schema,c),t.io===`input`&&Ng(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function wg(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Tg(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${wg(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+wg(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
133
|
+
|
|
134
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Eg(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Eg(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Dg=new Set([`type`,`properties`,`required`,`additionalProperties`]),Og=[`oneOf`,`anyOf`];function kg(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ag(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Dg.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??kg(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Au(n,r,e.length===1?e[0]:Ag(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=kg(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function jg(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Dg)if(t in e)return;let n=t.filter(e=>Og.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ag(t);else{let e=n[0],i=Og.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ag([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,bg(e,r))}function Mg(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):bg(i,s),bg(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Eg(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])jg(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}bg(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Au(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Fg(t,`input`,e.processors),output:Fg(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ng(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ng(r.element,n);if(r.type===`set`)return Ng(r.valueType,n);if(r.type===`lazy`)return Ng(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Ng(r.innerType,n);if(r.type===`intersection`)return Ng(r.left,n)||Ng(r.right,n);if(r.type===`record`||r.type===`map`)return Ng(r.keyType,n)||Ng(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ng(r.in,n)||Ng(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ng(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ng(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ng(e,n))return!0;return!!(r.rest&&Ng(r.rest,n))}return!1}var Pg=(e,t={})=>n=>{let r=xg({...n,processors:t});return Cg(e,r),Tg(r,e),Mg(r,e)},Fg=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=xg({...i??{},target:a,io:t,processors:n});return Cg(e,o),Tg(o,e),Mg(o,e)},Ig=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Lg=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rg=(e,t)=>{Ig(e,`minimum`,t),Lg(e,`maximum`,t)},zg=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Bg=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Vg=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Hg=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ug=(e,t)=>Ig(e,`minimum`,t.minimum),Wg=(e,t)=>Lg(e,`maximum`,t.maximum),Gg=e=>(t,n)=>{Hg(t,n.format);let[r,i]=e[n.format];Ig(t,`minimum`,r),Lg(t,`maximum`,i)},Kg={greater_than:(e,t)=>Ig(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Lg(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>zg(e,t.value),number_format:Gg(Xu),bigint_format:Gg(Zu),min_length:Ug,max_length:Wg,length_equals:(e,t)=>Rg(e,t.length),min_size:Ug,max_size:Wg,size_equals:(e,t)=>Rg(e,t.size),string_format:(e,t)=>{Hg(e,t.format),t.pattern&&Bg(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Vg(e,t.mime)};function qg(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Kg[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ig(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ig(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Lg(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Lg(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&zg(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Vg(t,i.mime);for(let e of i.patterns??[])Bg(t,e);return t}var Jg={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yg=new Map([[Xp,jf],[Qp,Mf]]),Xg=e=>Yg.get(e)??e,Zg=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=qg(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jg[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Xg);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Qg=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=qg(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Sg(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},$g=(e,t,n,r)=>{n.type=`boolean`},e_=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},t_=(e,t,n,r)=>{n.not={}},n_=(e,t,n,r)=>{let i=e._zod.def,a=bu(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},r_=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Sg(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Sg(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},i_=(e,t,n,r)=>{Sg(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},a_=(e,t,n,r)=>{Sg(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},o_=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=qg(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Cg(a.element,t,{...r,path:[...r.path,`items`]})};function s_(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?s_(t.out):t.type===`catch`?s_(t.innerType):e._zod.optin}var c_=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Sg(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Au(i.properties,e,Cg(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?s_(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Cg(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},l_=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Cg(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},u_=(e,t,n,r)=>{let i=e._zod.def,a=Cg(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Cg(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function d_(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=d_(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>d_(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Uf:Hf).source),p):p}var f_=new WeakMap;function p_(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of f_.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=d_(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var m_=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=qg(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Cg(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Au(i.patternProperties,Xg(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Cg(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=f_.get(t);n||(n=[],f_.set(t,n),t.deferred.push(()=>p_(t))),n.push(e)}i.additionalProperties=Cg(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&s_(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},h_=(e,t,n,r)=>{let i=e._zod.def,a=Cg(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},g_=(e,t,n,r)=>{let i=e._zod.def;Cg(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},__=Symbol();function v_(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Sg(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),__):JSON.parse(o)}var y_=(e,t,n,r)=>{let i=e._zod.def;Cg(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=v_(i.defaultValue,e,t,n,r);o!==__&&(n.default=o)},b_=(e,t,n,r)=>{let i=e._zod.def;Cg(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=v_(i.defaultValue,e,t,n,r);o!==__&&(n._prefault=o)},x_=(e,t,n,r)=>{let i=e._zod.def;Cg(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Sg(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},S_=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Cg(o,t,r);let s=t.seen.get(e);s.ref=o},C_=(e,t,n,r)=>{let i=e._zod.def;Cg(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},w_=(e,t,n,r)=>{let i=e._zod.def;Cg(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},T_=(e,t,n,r)=>{let i=e._zod.innerType;Cg(i,t,r);let a=t.seen.get(e);a.ref=i},E_=new WeakSet([Object.prototype,Error.prototype]);function D_(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var O_=q(`ZodError`,(e,t)=>{Wd.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);E_.has(n)||(E_.add(n),D_(n,`format`,e=>t=>qd(e,t)),D_(n,`flatten`,e=>t=>Kd(e,t)),D_(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Su,2)}),D_(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Su,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),k_=Yd(O_),A_=Xd(O_),j_=Zd(O_),M_=$d(O_),N_=of(O_),P_=sf(O_),F_=cf(O_),I_=lf(O_),L_=uf(O_),R_=df(O_),z_=ff(O_),B_=pf(O_);function V_(){Id.localeError||Ld(dh())}function H_(){Id.memoizer||Ld({memoizer:ch()})}var U_=q(`ZodType`,(e,t)=>(V_(),mp.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Lu(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return qu(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(fy(e,t))},superRefine(e,t){return this.check(py(e,t))},overwrite(e){return this.check(ug(e))},optional(){return Kv(this)},exactOptional(){return Jv(this)},nullable(){return Xv(this)},nullish(){return Kv(Xv(this))},nonoptional(e){return ny(this,e)},array(){return kv(this)},or(e){return Mv([this,e])},and(e){return Iv(this,e)},transform(e){return oy(this,Wv(e))},default(e){return Qv(this,e)},prefault(e){return ey(this,e)},catch(e){return iy(this,e)},pipe(e){return oy(this,e)},readonly(){return cy(this)},describe(e){let t=this.clone();return hh.add(t,{description:e}),t},meta(...e){if(e.length===0)return hh.get(this);let t=this.clone();return hh.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return bd(this,`~standard`,{..._p(this),jsonSchema:{input:Fg(this,`input`),output:Fg(this,`output`)}})},set"~standard"(e){yd(this,`~standard`,e)},parse:function e(t,n){return k_(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await A_(this,t,n,{callee:e})},safeParse(e,t){return j_(this,e,t)},async safeParseAsync(e,t){return M_(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){yd(this,`spa`,e)},validate(e,t){return nf(this,e,t)},validateAsync(e,t){return af(this,e,t)},encode:function e(t,n){return N_(this,t,n,{callee:e})},decode:function e(t,n){return P_(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await F_(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await I_(this,t,n,{callee:e})},safeEncode(e,t){return L_(this,e,t)},safeDecode(e,t){return R_(this,e,t)},async safeEncodeAsync(e,t){return z_(this,e,t)},async safeDecodeAsync(e,t){return B_(this,e,t)},toJSONSchema(e){return Pg(this,{})(e)},get description(){return hh.get(this)?.description},get _def(){return this._zod.def}}),W_=q(`_ZodString`,(e,t)=>{vp.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zg(e,t,n,r)},xd({format:e=>qg(e).format??null,minLength:e=>qg(e).minimum??null,maxLength:e=>qg(e).maximum??null},{regex(...e){return this.check(ig(...e))},includes(...e){return this.check(sg(...e))},startsWith(...e){return this.check(cg(...e))},endsWith(...e){return this.check(lg(...e))},min(...e){return this.check(ng(...e))},max(...e){return this.check(tg(...e))},length(...e){return this.check(rg(...e))},nonempty(...e){return this.check(ng(1,...e))},lowercase(e){return this.check(ag(e))},uppercase(e){return this.check(og(e))},trim(){return this.check(fg())},normalize(...e){return this.check(dg(...e))},toLowerCase(){return this.check(pg())},toUpperCase(){return this.check(mg())},slugify(){return this.check(hg())}})),G_=q(`ZodString`,(e,t)=>{vp.init(e,t),W_.init(e,t)},{email(e){return this.check(vh(Z_,e))},url(e){return this.check(wh(ev,e))},jwt(e){return this.check(zh(hv,e))},emoji(e){return this.check(Th(tv,e))},guid(e){return this.check(yh(Q_,e))},uuid(e){return this.check(bh($_,e))},uuidv4(e){return this.check(xh($_,e))},uuidv6(e){return this.check(Sh($_,e))},uuidv7(e){return this.check(Ch($_,e))},nanoid(e){return this.check(Eh(nv,e))},cuid(e){return this.check(Dh(rv,e))},cuid2(e){return this.check(Oh(iv,e))},ulid(e){return this.check(kh(av,e))},base64(e){return this.check(Ih(fv,e))},base64url(e){return this.check(Lh(pv,e))},xid(e){return this.check(Ah(ov,e))},ksuid(e){return this.check(jh(sv,e))},ipv4(e){return this.check(Mh(cv,e))},ipv6(e){return this.check(Nh(lv,e))},cidrv4(e){return this.check(Ph(uv,e))},cidrv6(e){return this.check(Fh(dv,e))},e164(e){return this.check(Rh(mv,e))},datetime(e){return this.check(Bh(q_,e))},date(e){return this.check(Vh(J_,e))},time(e){return this.check(Hh(Y_,e))},duration(e){return this.check(Uh(X_,e))}});function J(e){return _h(G_,e)}var K_=q(`ZodStringFormat`,(e,t)=>{yp.init(e,t),W_.init(e,t)}),q_=q(`ZodISODateTime`,(e,t)=>{Rp.init(e,t),K_.init(e,t)}),J_=q(`ZodISODate`,(e,t)=>{zp.init(e,t),K_.init(e,t)}),Y_=q(`ZodISOTime`,(e,t)=>{Bp.init(e,t),K_.init(e,t)}),X_=q(`ZodISODuration`,(e,t)=>{Vp.init(e,t),K_.init(e,t)}),Z_=q(`ZodEmail`,(e,t)=>{Sp.init(e,t),K_.init(e,t)}),Q_=q(`ZodGUID`,(e,t)=>{bp.init(e,t),K_.init(e,t)}),$_=q(`ZodUUID`,(e,t)=>{xp.init(e,t),K_.init(e,t)}),ev=q(`ZodURL`,(e,t)=>{Ap.init(e,t),K_.init(e,t)}),tv=q(`ZodEmoji`,(e,t)=>{jp.init(e,t),K_.init(e,t)}),nv=q(`ZodNanoID`,(e,t)=>{Mp.init(e,t),K_.init(e,t)}),rv=q(`ZodCUID`,(e,t)=>{Np.init(e,t),K_.init(e,t)}),iv=q(`ZodCUID2`,(e,t)=>{Pp.init(e,t),K_.init(e,t)}),av=q(`ZodULID`,(e,t)=>{Fp.init(e,t),K_.init(e,t)}),ov=q(`ZodXID`,(e,t)=>{Ip.init(e,t),K_.init(e,t)}),sv=q(`ZodKSUID`,(e,t)=>{Lp.init(e,t),K_.init(e,t)}),cv=q(`ZodIPv4`,(e,t)=>{Hp.init(e,t),K_.init(e,t)}),lv=q(`ZodIPv6`,(e,t)=>{Gp.init(e,t),K_.init(e,t)}),uv=q(`ZodCIDRv4`,(e,t)=>{Kp.init(e,t),K_.init(e,t)}),dv=q(`ZodCIDRv6`,(e,t)=>{Jp.init(e,t),K_.init(e,t)}),fv=q(`ZodBase64`,(e,t)=>{Zp.init(e,t),K_.init(e,t)}),pv=q(`ZodBase64URL`,(e,t)=>{em.init(e,t),K_.init(e,t)}),mv=q(`ZodE164`,(e,t)=>{tm.init(e,t),K_.init(e,t)}),hv=q(`ZodJWT`,(e,t)=>{rm.init(e,t),K_.init(e,t)}),gv=q(`ZodNumber`,(e,t)=>{im.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qg(e,t,n,r),e.isFinite=!0},xd({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=qg(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=qg(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=qg(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>qg(e).format??null},{gt(e,t){return this.check(Qh(e,t))},gte(e,t){return this.check($h(e,t))},min(e,t){return this.check($h(e,t))},lt(e,t){return this.check(Xh(e,t))},lte(e,t){return this.check(Zh(e,t))},max(e,t){return this.check(Zh(e,t))},int(e){return this.check(yv(e))},safe(e){return this.check(yv(e))},positive(e){return this.check(Qh(0,e))},nonnegative(e){return this.check($h(0,e))},negative(e){return this.check(Xh(0,e))},nonpositive(e){return this.check(Zh(0,e))},multipleOf(e,t){return this.check(eg(e,t))},step(e,t){return this.check(eg(e,t))},finite(){return this}}));function _v(e){return Wh(gv,e)}var vv=q(`ZodNumberFormat`,(e,t)=>{am.init(e,t),gv.init(e,t)});function yv(e){return Gh(vv,e)}var bv=q(`ZodBoolean`,(e,t)=>{om.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$g(e,t,n,r)});function xv(e){return Kh(bv,e)}var Sv=q(`ZodNull`,(e,t)=>{sm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>e_(e,t,n,r)});function Cv(e){return qh(Sv,e)}var wv=q(`ZodUnknown`,(e,t)=>{cm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Tv(){return Jh(wv)}var Ev=q(`ZodNever`,(e,t)=>{lm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>t_(e,t,n,r)});function Dv(e){return Yh(Ev,e)}var Ov=q(`ZodArray`,(e,t)=>{H_(),dm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>o_(e,t,n,r),e.element=t.element},{min(e,t){return this.check(ng(e,t))},nonempty(e){return this.check(ng(1,e))},max(e,t){return this.check(tg(e,t))},length(e,t){return this.check(rg(e,t))},unwrap(){return this.element}});function kv(e,t){return gg(Ov,e,t)}var Av=q(`ZodObject`,(e,t)=>{H_(),_m.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>c_(e,t,n,r),Dd(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Bv(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Lu(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Lu(this._zod.def,{catchall:Tv()}))},loose(){return this.clone(Lu(this._zod.def,{catchall:Tv()}))},strict(){return this.clone(Lu(this._zod.def,{catchall:Dv()}))},strip(){return this.clone(Lu(this._zod.def,{catchall:void 0}))},extend(e){return td(this,e)},safeExtend(e){return rd(this,e)},merge(e){return id(this,e)},pick(e){return Qu(this,e)},omit(e){return ed(this,e)},partial(...e){return ad(Gv,this,e[0])},exactPartial(...e){return ad(qv,this,e[0],`exactPartial`)},required(...e){return od(ty,this,e[0])}});function Y(e,t){return new Av({type:`object`,shape:e??{},...G(t)})}var jv=q(`ZodUnion`,(e,t)=>{ym.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>l_(e,t,n,r),e.options=t.options});function Mv(e,t){return new jv({type:`union`,options:e,...G(t)})}var Nv=q(`ZodDiscriminatedUnion`,(e,t)=>{jv.init(e,t),xm.init(e,t)});function Pv(e,t,n){return new Nv({type:`union`,options:t,discriminator:e,...G(n)})}var Fv=q(`ZodIntersection`,(e,t)=>{Sm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>u_(e,t,n,r)});function Iv(e,t){return new Fv({type:`intersection`,left:e,right:t})}var Lv=q(`ZodRecord`,(e,t)=>{H_(),Tm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>m_(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Rv(e,t,n){return!t||!t._zod?new Lv({type:`record`,keyType:J(),valueType:e,...G(t)}):new Lv({type:`record`,keyType:e,valueType:t,...G(n)})}var zv=q(`ZodEnum`,(e,t)=>{Em.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>n_(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new zv({...t,checks:[],...G(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new zv({...t,checks:[],...G(r),entries:i})}});function Bv(e,t){return new zv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...G(t)})}var Vv=q(`ZodLiteral`,(e,t)=>{Dm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>r_(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Hv(e,t){return new Vv({type:`literal`,values:Array.isArray(e)?e:[e],...G(t)})}var Uv=q(`ZodTransform`,(e,t)=>{H_(),Om.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>a_(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fd(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(_d(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(_d(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Wv(e){return new Uv({type:`transform`,transform:e})}var Gv=q(`ZodOptional`,(e,t)=>{Am.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>w_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Kv(e){return new Gv({type:`optional`,innerType:e})}var qv=q(`ZodExactOptional`,(e,t)=>{jm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>w_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jv(e){return new qv({type:`optional`,innerType:e})}var Yv=q(`ZodNullable`,(e,t)=>{Mm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>h_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xv(e){return new Yv({type:`nullable`,innerType:e})}var Zv=q(`ZodDefault`,(e,t)=>{Nm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>y_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Qv(e,t){return new Zv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Wu(t)}})}var $v=q(`ZodPrefault`,(e,t)=>{Fm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>b_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ey(e,t){return new $v({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Wu(t)}})}var ty=q(`ZodNonOptional`,(e,t)=>{Im.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>g_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ny(e,t){return new ty({type:`nonoptional`,innerType:e,...G(t)})}var ry=q(`ZodCatch`,(e,t)=>{zm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>x_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function iy(e,t){return new ry({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:kd(t)})}var ay=q(`ZodPipe`,(e,t)=>{Bm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>S_(e,t,n,r),e.in=t.in,e.out=t.out});function oy(e,t){return new ay({type:`pipe`,in:e,out:t})}var sy=q(`ZodReadonly`,(e,t)=>{Hm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>C_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cy(e){return new sy({type:`readonly`,innerType:e})}var ly=q(`ZodLazy`,(e,t)=>{Wm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>T_(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function uy(e){return new ly({type:`lazy`,getter:e})}var dy=q(`ZodCustom`,(e,t)=>{Gm.init(e,t),U_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>i_(e,t,n,r)});function fy(e,t={}){return _g(dy,e,t)}function py(e,t){return vg(e,t)}function my(e){let t=uy(()=>Mv([J(e),_v(),xv(),Cv(),kv(t),Rv(J(),t)]));return t}var hy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),gy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=hy(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),X=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=hy(),n=gy(),r=hy();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=gy();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
135
|
+
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-->0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${L(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${L(n)} ${e} ${L(r)}`}function L(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Z=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=X(),n=hy();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0||(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0||{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0||(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0||Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),_y=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),vy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=X(),n=Z(),r=_y();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),yy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=vy(),n=X(),r=_y(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),by=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),xy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Sy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=by(),n=xy(),r=vy(),i=X(),a=Z(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
136
|
+
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
137
|
+
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|
|
138
|
+
|| ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;var g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),Cy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;var t=X(),n=Z();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),wy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;var t=X(),n=Z(),r=_y(),i=Z();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;var h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),Ty=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=X(),n=_y(),r=wy(),i=vy();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),Ey=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=X(),n=Z();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Dy=i(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),Oy=i(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else(p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),ky=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=Z(),n=Dy(),r=Oy(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;var o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;var d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;var m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),Ay=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=yy(),n=Sy(),r=xy(),i=Sy(),a=Cy(),o=Ty(),s=Ey(),c=X(),l=_y(),u=ky(),d=Z(),f=vy();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),j(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return N(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);N(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function j(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&M(e),t.return((0,c._)`${l.default.errors} === 0`))}function M({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function N(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>ne(e,`$ref`,h.all.$ref.definition));return}p.jtd||F(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),P(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):P(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function P(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&ne(e,n.keyword,n.definition,t.type)})}function F(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(I(e,t),e.opts.allowUnionTypes||L(e,t),R(e,e.dataTypes))}function I(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{z(e.dataTypes,t)||te(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),B(e,t)}}function L(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&te(e,`use allowUnionTypes to allow union type keyword`)}function R(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>ee(t,e))&&te(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ee(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function z(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function B(e,t){let n=[];for(let r of e.dataTypes)z(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function te(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var V=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,ae(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=V;function ne(e,t,n,r){let i=new V(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}var re=/^\/(?:[^~]|~0|~1)*$/,ie=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ae(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!re.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ie.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=ae})),jy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),My=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ky();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),Ny=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=X(),n=jy(),r=_y(),i=ky(),a=Z(),o=Ay(),s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;var h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),Py=r({$id:()=>Fy,additionalProperties:()=>!1,default:()=>By,description:()=>Iy,properties:()=>zy,required:()=>Ry,type:()=>Ly}),Fy,Iy,Ly,Ry,zy,By,Vy=n((()=>{Fy=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,Iy=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,Ly=`object`,Ry=[`$data`],zy={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},By={$id:Fy,description:Iy,type:Ly,required:Ry,properties:zy,additionalProperties:!1}})),Hy=i(((e,t)=>{var n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),s=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),c=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),l=Array(256);{let e=`0123456789ABCDEF`;for(let t=0;t<256;t++)l[t]=`%`+e[t>>4]+e[t&15]}function u(e){return e<2048?l[192|e>>6]+l[128|e&63]:e<65536?l[224|e>>12]+l[128|e>>6&63]+l[128|e&63]:l[240|e>>18]+l[128|e>>12&63]+l[128|e>>6&63]+l[128|e&63]}function d(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}var f=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),p=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),m=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),h=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function g(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!m(e[t])){if(e[t]===`%`&&t+2<e.length&&i(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function _(e){let t=-1,n=0,r=-1,i=0;for(let a=0;a<e.length;a++)e[a]===`0`?(r===-1&&(r=a),i++,i>n&&(n=i,t=r)):(r=-1,i=0);if(n<2)return e.join(`:`);let a=e.slice(0,t).join(`:`),o=e.slice(t+n).join(`:`);return a+`::`+o}function v(e){let t=e.indexOf(`::`);if(t!==-1&&e.indexOf(`::`,t+1)!==-1)return;let n=t===-1?e.split(`:`):e.slice(0,t).split(`:`),i=t===-1?[]:e.slice(t+2).split(`:`);t!==-1&&(n.length===1&&n[0]===``&&(n.length=0),i.length===1&&i[0]===``&&(i.length=0));let a=n.concat(i),o=0;for(let e=0;e<a.length;e++){let n=a[e];if(n===``)return;if(n.indexOf(`.`)!==-1){if(e!==a.length-1||t!==-1&&i.length===0||!r(n))return;o+=2;continue}if(!f(n))return;a[e]=parseInt(n,16).toString(16),o++}if(t===-1)return o===8?_(a):void 0;if(o>=8)return;let s=a.slice(0,n.length);for(let e=o;e<8;e++)s.push(`0`);for(let e=n.length;e<a.length;e++)s.push(a[e]);return _(s)}function y(e){let t=e[0]===`[`&&e[e.length-1]===`]`;if((e[0]===`[`||e[e.length-1]===`]`)&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&p(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(b(n,`:`)<2)return{host:e,isIPV6:!1,error:t};let r=``,i=n.indexOf(`%`);if(i!==-1){let t=n.slice(i,i+3).toLowerCase()===`%25`?3:1;if(r=n.slice(i+t),!g(r))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,i)}let a=v(n);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(r?`%`+r:``),escapedHost:a+(r?`%25`+r:``),isIPV6:!0}}function b(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function x(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}n.push(t);break}if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}var S={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},C=/[@/?#:]/g,w=/[@/?#]/g;function T(e,t){let n=t?w:C;return n.lastIndex=0,e.replace(n,e=>S[e])}function E(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function D(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}if(o(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=N(i)?r:l[i];else if(i<55296||i>57343)t+=u(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=u(65536+(i-55296<<10)+(r-56320)),n++):t+=u(65533)}else t+=u(65533)}}return t}function O(e,t=!1){let n=``,r=t&&e[0]!==`/`;for(let t=0;t<e.length;t++){let a=e[t];if(a===`%`&&t+2<e.length){let r=e.slice(t+1,t+3);if(i(r)){n+=`%`+r.toUpperCase(),t+=2;continue}}if(a===`/`&&(r=!1),o(a)&&(a!==`:`||!r))n+=a;else{let r=e.charCodeAt(t);if(r<128)n+=l[r];else if(r<55296||r>57343)n+=u(r);else if(r<=56319&&t+1<e.length){let i=e.charCodeAt(t+1);i>=56320&&i<=57343?(n+=u(65536+(r-55296<<10)+(i-56320)),t++):n+=u(65533)}else n+=u(65533)}}return n}function k(e,t){let n=``;for(let r=0;r<e.length;r++){let a=e[r];if(a===`%`&&r+2<e.length){let t=e.slice(r+1,r+3);if(i(t)){n+=`%`+t.toUpperCase(),r+=2;continue}}if(t(a))n+=a;else{let t=e.charCodeAt(r);if(t<128)n+=l[t];else if(t<55296||t>57343)n+=u(t);else if(t<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(n+=u(65536+(t-55296<<10)+(i-56320)),r++):n+=u(65533)}else n+=u(65533)}}return n}function A(e){return k(e,c)}function j(e){return k(e,s)}function M(e){return k(e,s)}function N(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function P(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));a(i)?t+=i:t+=`%`+e,n+=2;continue}}if(s(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=N(i)?r:l[i];else if(i<55296||i>57343)t+=u(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=u(65536+(i-55296<<10)+(r-56320)),n++):t+=u(65533)}else t+=u(65533)}}return t}function F(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function I(e){let t=[];if(e.userinfo!==void 0&&(t.push(A(e.userinfo)),t.push(`@`)),e.host!==void 0){let n=e.host;if(!r(n)){let e=y(n);e.isIPV6!==!0&&e.isIPVFuture!==!0&&(n=E(n,!0),e=y(n)),n=e.isIPV6===!0||e.isIPVFuture===!0?`[${e.escapedHost}]`:T(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:h,recomposeAuthority:I,reescapeHostDelimiters:T,normalizePercentEncoding:E,normalizePathEncoding:D,serializePathEncoding:O,normalizeQueryFragmentEncoding:P,encodeUserinfo:A,encodeQuery:j,encodeFragment:M,escapePreservingEscapes:F,removeDotSegments:x,isIPv4:r,isUUID:n,normalizeIPv6:y,stringArrayToHexStripped:d}})),Uy=i(((e,t)=>{var{isUUID:n}=Hy(),r=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf(`?`),n=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=n&&n!==`/`?n:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n&&n[0]===e.path){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}var h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),Wy=i(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,serializePathEncoding:s,normalizeQueryFragmentEncoding:c,encodeQuery:l,encodeFragment:u,reescapeHostDelimiters:d,isIPv4:f,nonSimpleDomain:p}=Hy(),{SCHEMES:m,getSchemeHandler:h}=Uy(),g=/^[A-Za-z][A-Za-z0-9+.-]*$/u,_=`URI scheme is malformed.`;function v(e){let t=unescape(String(e));if(!g.test(t))throw TypeError(_);return t}function y(e,t){return typeof e==`string`?e=N(e,t):typeof e==`object`&&(e=M(C(e,t),t)),e}function b(e,t,r){let i=r?Object.assign({scheme:`null`},r):{scheme:`null`},{parsed:a,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:c,malformedHost:l,malformedScheme:u}=j(e,i),{parsed:d,malformedAuthorityOrPort:p,malformedPercentEncoding:m,malformedSchemeSpecific:g,malformedHost:_,malformedScheme:v}=j(t,i);if(o||p||s||m||c||g||l||_||u||v)throw Error(a.error||d.error||`URI is malformed.`);let y=x(a,d,i,!0),b=h(r&&r.scheme||y.scheme),S=y.host,w=S!==void 0&&S!==``&&(f(S)||n(S).isIPV6);A(y,r||{},b,w);let T=S&&S.indexOf(`%`)!==-1&&!/\P{ASCII}/u.test(S);if(y.error&&!T)throw Error(y.error);return i.skipEscape=!0,C(y,i)}function x(e,t,n,i){let a={};return i||(e=M(C(e,n),n),t=M(C(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):(a.path=(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?`/`+t.path:e.path?e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,a.query=t.query===void 0?e.query:t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function S(e,t,n){let r=F(e,n),i=F(t,n);return r!==void 0&&i!==void 0&&r===i}function C(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[];n.scheme&&=v(n.scheme);let d=h(o.scheme||n.scheme);d&&d.serialize&&d.serialize(n,o);let f=n.userinfo!==void 0||n.host!==void 0||n.port!==void 0,p=!o.skipEscape&&n.scheme===void 0&&!f;n.path!==void 0&&(n.path=o.skipEscape?a(n.path):s(n.path,p)),o.reference!==`suffix`&&n.scheme&&(n.scheme=v(n.scheme),c.push(n.scheme,`:`));let m=i(n);if(m!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(m),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!d||!d.absolutePath)&&(e=r(e)),p&&(e=s(e,!0)),m===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,l(n.query)),n.fragment!==void 0&&c.push(`#`,u(n.fragment)),c.join(``)}var w=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,T=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,E=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function D(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function O(e){if(e===void 0)return!1;let t=e.indexOf(`%`);for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf(`%`,t+3)}return!1}function k(e){let t=e[4];return O(e[3])||t!==void 0&&(t[0]!==`[`||t[t.length-1]!==`]`)&&O(t)||O(e[6])||O(e[7])||O(e[8])}function A(e,t,n,r){if(!t.unicodeSupport&&(!n||!n.unicodeSupport)&&e.host&&e.host[0]!==`[`&&(t.domainHost||n&&n.domainHost)&&r===!1&&p(e.host))try{e.host=new URL(`http://`+e.host).hostname}catch(t){return e.error=e.error||`Host's domain name can not be converted to ASCII: `+t,!0}return!1}function j(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},s=!1,l=!1,u=!1,p=!1,v=!1,y=!1,b=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let x=e.match(T);x!==null&&x[1].indexOf(`\\`)!==-1&&(i.error=`URI authority must not contain a literal backslash.`,s=!0);let S=e.match(E);if(S!==null){let e=S[1],t=e.replace(/[\t\n\r]/g,``);t.length>=2&&(t.slice(0,2)===`//`?e.length!==t.length&&(i.error=i.error||`URI authority introducer must not contain whitespace.`,s=!0):(i.error=i.error||`URI authority must not contain a literal backslash.`,s=!0))}let C=e.match(w);if(C){if(i.scheme=C[1],i.userinfo=C[3],i.host=C[4],i.port=parseInt(C[5],10),i.path=C[6]||``,i.query=C[7],i.fragment=C[8],i.scheme!==void 0){let e=unescape(i.scheme);g.test(e)?i.scheme=e.toLowerCase():(i.error=i.error||_,y=!0)}l=k(C),l&&(i.error=i.error||`URI contains malformed percent-encoding.`),isNaN(i.port)&&(i.port=C[5]);let t=D(i,C);if(t!==void 0&&(i.error=i.error||t,s=!0),i.host){if(f(i.host)===!1){let e=i.host[0]===`[`&&i.host[i.host.length-1]===`]`,t=n(i.host);b=t.isIPV6||t.isIPVFuture===!0,v=e&&t.error===!0,i.host=b?t.host:t.host.toLowerCase(),v&&(i.error=i.error||`URI host is malformed.`,s=!0)}else b=!0}i.reference=i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?`same-document`:i.scheme===void 0?`relative`:i.fragment===void 0?`absolute`:`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let x=h(r.scheme||i.scheme);p=A(i,r,x,b),(!x||x&&!x.skipNormalize)&&(e.indexOf(`%`)!==-1&&i.host!==void 0&&!v&&(i.host=d(b?i.host:a(i.host,!0),b)),i.path&&=o(i.path),i.query&&=c(i.query),i.fragment&&=c(i.fragment)),x&&x.parse&&(x.parse(i,r),x===m.urn&&i.nid===void 0&&(u=!0))}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:s,malformedPercentEncoding:l,malformedSchemeSpecific:u,malformedHost:p,malformedScheme:y}}function M(e,t){return j(e,t).parsed}function N(e,t){return P(e,t).normalized}function P(e,t){let{parsed:n,malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}=j(e,t);return{normalized:r||i||a||o||s?e:C(n,t),malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}}function F(e,t){if(typeof e!=`string`&&typeof e!=`object`)return;let n;try{n=typeof e==`string`?e:C(e,t)}catch{return}let{normalized:r,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:c}=P(n,t);return i||a||o||s||c?void 0:r}var I={SCHEMES:m,normalize:y,resolve:b,resolveComponent:x,equal:S,serialize:C,parse:M};t.exports=I,t.exports.default=I,t.exports.fastUri=I})),Gy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Wy();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Ky=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var n=Ay();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return n.KeywordCxt}});var r=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});var i=jy(),a=My(),o=by(),s=Ny(),c=X(),l=ky(),u=Sy(),d=Z(),f=(Vy(),t(Py).default),p=Gy(),m=(e,t)=>new RegExp(e,t);m.code=`new RegExp`;var h=[`removeAdditional`,`useDefaults`,`coerceTypes`],g=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),_={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},v={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`},y=200;function b(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??m,a=e.uriResolver??p.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??y,loopEnum:e.loopEnum??y,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var x=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...b(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new c.ValueScope({scope:{},prefixes:g,es5:t,lines:n}),this.logger=k(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,o.getRules)(),S.call(this,_,e,`NOT SUPPORTED`),S.call(this,v,e,`DEPRECATED`,`warn`),this._metaOpts=D.call(this),e.formats&&T.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),w.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=f;n===`id`&&(r={...f},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await i.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function i(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof a.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await i.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,l.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=C.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new s.SchemaEnv({schema:{},schemaId:n});if(t=s.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=C.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,l.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(j.call(this,n,t),!t)return(0,d.eachItem)(n,e=>M.call(this,e)),this;P.call(this,t);let r={...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)};return(0,d.eachItem)(n,r.type.length===0?e=>M.call(this,e,r):e=>r.type.forEach(t=>M.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=I(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:o}=this.opts;if(typeof e==`object`)a=e[o];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let c=this._cache.get(e);if(c!==void 0)return c;n=(0,l.normalizeId)(a||n);let u=l.getSchemaRefs.call(this,e,n);return c=new s.SchemaEnv({schema:e,schemaId:o,meta:t,baseId:n,localRefs:u}),this._cache.set(c.schema,c),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=c),r&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):s.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{s.compileSchema.call(this,e)}finally{this.opts=t}}};x.ValidationError=i.default,x.MissingRefError=a.default,e.default=x;function S(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function C(e){return e=(0,l.normalizeId)(e),this.schemas[e]||this.refs[e]}function w(){let e=this.opts.schemas;if(e){if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}}function T(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function D(){let e={...this.opts};for(let t of h)delete e[t];return e}var O={log(){},warn(){},error(){}};function k(e){if(e===!1)return O;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}var A=/^[a-z_$][a-z0-9_$:-]*$/i;function j(e,t){let{RULES:n}=this;if((0,d.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!A.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function M(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)}};t.before?N.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function N(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function P(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=I(t)),e.validateSchema=this.compile(t,!0))}var F={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function I(e){return{anyOf:[e,F]}}})),qy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Jy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;var t=My(),n=wy(),r=X(),i=_y(),a=Ny(),o=Z(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0){if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}}if(l.items!==!0){if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}}e.callRef=l,e.default=s})),Yy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=qy(),n=Jy();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Xy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),Zy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),Qy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),$y=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=Qy();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),eb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wy(),n=Z(),r=X();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),tb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),nb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wy(),n=X(),r=Z();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),rb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),ib=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Dy();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),ab=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Sy(),n=X(),r=Z(),i=ib();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),ob=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=ib();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),sb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=ib();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),cb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Xy(),n=Zy(),r=$y(),i=eb(),a=tb(),o=nb(),s=rb(),c=ab(),l=ob(),u=sb();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),lb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;var t=X(),n=Z(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),ub=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;var t=X(),n=Z(),r=wy(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),db=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ub();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),fb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=wy(),i=lb();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),pb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),mb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=X(),n=Z(),r=wy();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
|
|
139
|
+
missingProperty: ${i},
|
|
140
|
+
depsCount: ${n},
|
|
141
|
+
deps: ${r}}`};var i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),hb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),gb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wy(),n=X(),r=_y(),i=Z();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),_b=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ay(),n=wy(),r=Z(),i=gb();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),vb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wy(),n=X(),r=Z(),i=Z();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),yb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),bb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:wy().validateUnion,error:{message:`must match a schema in anyOf`}}})),xb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),Sb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),Cb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),wb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),Tb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=lb(),n=db(),r=ub(),i=fb(),a=pb(),o=mb(),s=hb(),c=gb(),l=_b(),u=vb(),d=yb(),f=bb(),p=xb(),m=Sb(),h=Cb(),g=wb();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),Eb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),Db=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[Eb().default]})),Ob=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),kb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Yy(),n=cb(),r=Tb(),i=Db(),a=Ob();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),Ab=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),jb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Ab(),r=Ny(),i=My(),a=Z();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),Mb=r({$id:()=>Pb,$schema:()=>Nb,default:()=>zb,definitions:()=>Ib,properties:()=>Rb,title:()=>Fb,type:()=>Lb}),Nb,Pb,Fb,Ib,Lb,Rb,zb,Bb=n((()=>{Nb=`http://json-schema.org/draft-07/schema#`,Pb=`http://json-schema.org/draft-07/schema#`,Fb=`Core schema meta-schema`,Ib={schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},Lb=[`object`,`boolean`],Rb={$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},zb={$schema:Nb,$id:Pb,title:Fb,definitions:Ib,type:Lb,properties:Rb,default:!0}})),Vb=i(((e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;var r=Ky(),i=kb(),a=jb(),o=(Bb(),t(Mb).default),s=[`/properties`],c=`http://json-schema.org/draft-07/schema`,l=class extends r.default{_addVocabularies(){super._addVocabularies(),i.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(a.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(o,s):o;this.addMetaSchema(e,c,!1),this.refs[`http://json-schema.org/schema`]=c}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(c)?c:void 0)}};e.Ajv=l,n.exports=e=l,n.exports.Ajv=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var u=Ay();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var d=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=jy();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var p=My();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})),Hb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicAnchor=void 0;var t=X(),n=_y(),r=Ny(),i=Jy(),a={keyword:`$dynamicAnchor`,schemaType:`string`,code:e=>o(e,e.schema)};function o(e,r){let{gen:i,it:a}=e;a.schemaEnv.root.dynamicAnchors[r]=!0;let o=(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(r)}`,c=a.errSchemaPath===`#`?a.validateName:s(e);i.if((0,t._)`!${o}`,()=>i.assign(o,c))}e.dynamicAnchor=o;function s(e){let{schemaEnv:t,schema:n,self:a}=e.it,{root:o,baseId:s,localRefs:c,meta:l}=t.root,{schemaId:u}=a.opts,d=new r.SchemaEnv({schema:n,schemaId:u,root:o,baseId:s,localRefs:c,meta:l});return r.compileSchema.call(a,d),(0,i.getValidate)(e,d)}e.default=a})),Ub=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicRef=void 0;var t=X(),n=_y(),r=Jy(),i={keyword:`$dynamicRef`,schemaType:`string`,code:e=>a(e,e.schema)};function a(e,i){let{gen:a,keyword:o,it:s}=e;if(i[0]!==`#`)throw Error(`"${o}" only supports hash fragment reference`);let c=i.slice(1);if(s.allErrors)l();else{let t=a.let(`valid`,!1);l(t),e.ok(t)}function l(e){if(s.schemaEnv.root.dynamicAnchors[c]){let r=a.let(`_v`,(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(c)}`);a.if(r,u(r,e),u(s.validateName,e))}else u(s.validateName,e)()}function u(t,n){return n?()=>a.block(()=>{(0,r.callRef)(e,t),a.let(n,!0)}):()=>(0,r.callRef)(e,t)}}e.dynamicRef=a,e.default=i})),Wb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Hb(),n=Z();e.default={keyword:`$recursiveAnchor`,schemaType:`boolean`,code(e){e.schema?(0,t.dynamicAnchor)(e,``):(0,n.checkStrictMode)(e.it,`$recursiveAnchor: false is ignored`)}}})),Gb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ub();e.default={keyword:`$recursiveRef`,schemaType:`string`,code:e=>(0,t.dynamicRef)(e,e.schema)}})),Kb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Hb(),n=Ub(),r=Wb(),i=Gb();e.default=[t.default,n.default,r.default,i.default]})),qb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=mb();e.default={keyword:`dependentRequired`,type:`object`,schemaType:`object`,error:t.error,code:e=>(0,t.validatePropertyDeps)(e)}})),Jb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=mb();e.default={keyword:`dependentSchemas`,type:`object`,schemaType:`object`,code:e=>(0,t.validateSchemaDeps)(e)}})),Yb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();e.default={keyword:[`maxContains`,`minContains`],type:`array`,schemaType:`number`,code({keyword:e,parentSchema:n,it:r}){n.contains===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "contains" is ignored`)}}})),Xb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=qb(),n=Jb(),r=Yb();e.default=[t.default,n.default,r.default]})),Zb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=_y();e.default={keyword:`unevaluatedProperties`,type:`object`,schemaType:[`boolean`,`object`],trackErrors:!0,error:{message:`must NOT have unevaluated properties`,params:({params:e})=>(0,t._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){let{gen:i,schema:a,data:o,errsCount:s,it:c}=e;if(!s)throw Error(`ajv implementation error`);let{allErrors:l,props:u}=c;u instanceof t.Name?i.if((0,t._)`${u} !== true`,()=>i.forIn(`key`,o,e=>i.if(f(u,e),()=>d(e)))):u!==!0&&i.forIn(`key`,o,e=>u===void 0?d(e):i.if(p(u,e),()=>d(e))),c.props=!0,e.ok((0,t._)`${s} === ${r.default.errors}`);function d(r){if(a===!1){e.setParams({unevaluatedProperty:r}),e.error(),l||i.break();return}if(!(0,n.alwaysValidSchema)(c,a)){let a=i.name(`valid`);e.subschema({keyword:`unevaluatedProperties`,dataProp:r,dataPropType:n.Type.Str},a),l||i.if((0,t.not)(a),()=>i.break())}}function f(e,n){return(0,t._)`!${e} || !${e}[${n}]`}function p(e,n){let r=[];for(let i in e)e[i]===!0&&r.push((0,t._)`${n} !== ${i}`);return(0,t.and)(...r)}}}})),Qb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();e.default={keyword:`unevaluatedItems`,type:`array`,schemaType:[`boolean`,`object`],error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e,s=o.items||0;if(s===!0)return;let c=r.const(`len`,(0,t._)`${a}.length`);if(i===!1)e.setParams({len:s}),e.fail((0,t._)`${c} > ${s}`);else if(typeof i==`object`&&!(0,n.alwaysValidSchema)(o,i)){let n=r.var(`valid`,(0,t._)`${c} <= ${s}`);r.if((0,t.not)(n),()=>l(n,s)),e.ok(n)}o.items=!0;function l(i,a){r.forRange(`i`,a,c,a=>{e.subschema({keyword:`unevaluatedItems`,dataProp:a,dataPropType:n.Type.Num},i),o.allErrors||r.if((0,t.not)(i),()=>r.break())})}}}})),$b=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Zb(),n=Qb();e.default=[t.default,n.default]})),ex=r({$id:()=>nx,$recursiveAnchor:()=>!0,$schema:()=>tx,$vocabulary:()=>rx,allOf:()=>ax,default:()=>cx,properties:()=>sx,title:()=>ix,type:()=>ox}),tx,nx,rx,ix,ax,ox,sx,cx,lx=n((()=>{tx=`https://json-schema.org/draft/2019-09/schema`,nx=`https://json-schema.org/draft/2019-09/schema`,rx={"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},ix=`Core and Validation specifications meta-schema`,ax=[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format`},{$ref:`meta/content`}],ox=[`object`,`boolean`],sx={definitions:{$comment:`While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.`,type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},dependencies:{$comment:`"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"`,type:`object`,additionalProperties:{anyOf:[{$recursiveRef:`#`},{$ref:`meta/validation#/$defs/stringArray`}]}}},cx={$schema:tx,$id:nx,$vocabulary:rx,$recursiveAnchor:!0,title:ix,allOf:ax,type:ox,properties:sx}})),ux=r({$defs:()=>_x,$id:()=>fx,$recursiveAnchor:()=>!0,$schema:()=>dx,$vocabulary:()=>px,default:()=>vx,properties:()=>gx,title:()=>mx,type:()=>hx}),dx,fx,px,mx,hx,gx,_x,vx,yx=n((()=>{dx=`https://json-schema.org/draft/2019-09/schema`,fx=`https://json-schema.org/draft/2019-09/meta/applicator`,px={"https://json-schema.org/draft/2019-09/vocab/applicator":!0},mx=`Applicator vocabulary meta-schema`,hx=[`object`,`boolean`],gx={additionalItems:{$recursiveRef:`#`},unevaluatedItems:{$recursiveRef:`#`},items:{anyOf:[{$recursiveRef:`#`},{$ref:`#/$defs/schemaArray`}]},contains:{$recursiveRef:`#`},additionalProperties:{$recursiveRef:`#`},unevaluatedProperties:{$recursiveRef:`#`},properties:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$recursiveRef:`#`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$recursiveRef:`#`}},propertyNames:{$recursiveRef:`#`},if:{$recursiveRef:`#`},then:{$recursiveRef:`#`},else:{$recursiveRef:`#`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$recursiveRef:`#`}},_x={schemaArray:{type:`array`,minItems:1,items:{$recursiveRef:`#`}}},vx={$schema:dx,$id:fx,$vocabulary:px,$recursiveAnchor:!0,title:mx,type:hx,properties:gx,$defs:_x}})),bx=r({$id:()=>Sx,$recursiveAnchor:()=>!0,$schema:()=>xx,$vocabulary:()=>Cx,default:()=>Dx,properties:()=>Ex,title:()=>wx,type:()=>Tx}),xx,Sx,Cx,wx,Tx,Ex,Dx,Ox=n((()=>{xx=`https://json-schema.org/draft/2019-09/schema`,Sx=`https://json-schema.org/draft/2019-09/meta/content`,Cx={"https://json-schema.org/draft/2019-09/vocab/content":!0},wx=`Content vocabulary meta-schema`,Tx=[`object`,`boolean`],Ex={contentMediaType:{type:`string`},contentEncoding:{type:`string`},contentSchema:{$recursiveRef:`#`}},Dx={$schema:xx,$id:Sx,$vocabulary:Cx,$recursiveAnchor:!0,title:wx,type:Tx,properties:Ex}})),kx=r({$id:()=>jx,$recursiveAnchor:()=>!0,$schema:()=>Ax,$vocabulary:()=>Mx,default:()=>Ix,properties:()=>Fx,title:()=>Nx,type:()=>Px}),Ax,jx,Mx,Nx,Px,Fx,Ix,Lx=n((()=>{Ax=`https://json-schema.org/draft/2019-09/schema`,jx=`https://json-schema.org/draft/2019-09/meta/core`,Mx={"https://json-schema.org/draft/2019-09/vocab/core":!0},Nx=`Core vocabulary meta-schema`,Px=[`object`,`boolean`],Fx={$id:{type:`string`,format:`uri-reference`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{type:`string`,format:`uri`},$anchor:{type:`string`,pattern:`^[A-Za-z][-A-Za-z0-9.:_]*$`},$ref:{type:`string`,format:`uri-reference`},$recursiveRef:{type:`string`,format:`uri-reference`},$recursiveAnchor:{type:`boolean`,default:!1},$vocabulary:{type:`object`,propertyNames:{type:`string`,format:`uri`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}}},Ix={$schema:Ax,$id:jx,$vocabulary:Mx,$recursiveAnchor:!0,title:Nx,type:Px,properties:Fx}})),Rx=r({$id:()=>Bx,$recursiveAnchor:()=>!0,$schema:()=>zx,$vocabulary:()=>Vx,default:()=>Gx,properties:()=>Wx,title:()=>Hx,type:()=>Ux}),zx,Bx,Vx,Hx,Ux,Wx,Gx,Kx=n((()=>{zx=`https://json-schema.org/draft/2019-09/schema`,Bx=`https://json-schema.org/draft/2019-09/meta/format`,Vx={"https://json-schema.org/draft/2019-09/vocab/format":!0},Hx=`Format vocabulary meta-schema`,Ux=[`object`,`boolean`],Wx={format:{type:`string`}},Gx={$schema:zx,$id:Bx,$vocabulary:Vx,$recursiveAnchor:!0,title:Hx,type:Ux,properties:Wx}})),qx=r({$id:()=>Yx,$recursiveAnchor:()=>!0,$schema:()=>Jx,$vocabulary:()=>Xx,default:()=>eS,properties:()=>$x,title:()=>Zx,type:()=>Qx}),Jx,Yx,Xx,Zx,Qx,$x,eS,tS=n((()=>{Jx=`https://json-schema.org/draft/2019-09/schema`,Yx=`https://json-schema.org/draft/2019-09/meta/meta-data`,Xx={"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},Zx=`Meta-data vocabulary meta-schema`,Qx=[`object`,`boolean`],$x={title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}},eS={$schema:Jx,$id:Yx,$vocabulary:Xx,$recursiveAnchor:!0,title:Zx,type:Qx,properties:$x}})),nS=r({$defs:()=>lS,$id:()=>iS,$recursiveAnchor:()=>!0,$schema:()=>rS,$vocabulary:()=>aS,default:()=>uS,properties:()=>cS,title:()=>oS,type:()=>sS}),rS,iS,aS,oS,sS,cS,lS,uS,dS=n((()=>{rS=`https://json-schema.org/draft/2019-09/schema`,iS=`https://json-schema.org/draft/2019-09/meta/validation`,aS={"https://json-schema.org/draft/2019-09/vocab/validation":!0},oS=`Validation vocabulary meta-schema`,sS=[`object`,`boolean`],cS={multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}},const:!0,enum:{type:`array`,items:!0},type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]}},lS={nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},uS={$schema:rS,$id:iS,$vocabulary:aS,$recursiveAnchor:!0,title:oS,type:sS,properties:cS,$defs:lS}})),fS=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var n=(lx(),t(ex).default),r=(yx(),t(ux).default),i=(Ox(),t(bx).default),a=(Lx(),t(kx).default),o=(Kx(),t(Rx).default),s=(tS(),t(qx).default),c=(dS(),t(nS).default),l=[`/properties`];function u(e){return[n,r,i,a,t(this,o),s,t(this,c)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function t(t,n){return e?t.$dataMetaSchema(n,l):n}}e.default=u})),pS=i(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2019=void 0;var n=Ky(),r=kb(),i=Kb(),a=Xb(),o=$b(),s=jb(),c=fS(),l=`https://json-schema.org/draft/2019-09/schema`,u=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(i.default),r.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(a.default),this.addVocabulary(o.default),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(c.default.call(this,e),this.refs[`http://json-schema.org/schema`]=l)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}};e.Ajv2019=u,t.exports=e=u,t.exports.Ajv2019=u,Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var d=Ay();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return d.KeywordCxt}});var f=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return f._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return f.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return f.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return f.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return f.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return f.CodeGen}});var p=jy();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return p.default}});var m=My();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})),mS=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Yy(),n=cb(),r=Tb(),i=Kb(),a=Xb(),o=$b(),s=Db(),c=Ob();e.default=[i.default,t.default,n.default,(0,r.default)(!0),s.default,c.metadataVocabulary,c.contentVocabulary,a.default,o.default]})),hS=r({$comment:()=>CS,$dynamicAnchor:()=>yS,$id:()=>_S,$schema:()=>gS,$vocabulary:()=>vS,allOf:()=>xS,default:()=>TS,properties:()=>wS,title:()=>bS,type:()=>SS}),gS,_S,vS,yS,bS,xS,SS,CS,wS,TS,ES=n((()=>{gS=`https://json-schema.org/draft/2020-12/schema`,_S=`https://json-schema.org/draft/2020-12/schema`,vS={"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},yS=`meta`,bS=`Core and Validation specifications meta-schema`,xS=[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/unevaluated`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format-annotation`},{$ref:`meta/content`}],SS=[`object`,`boolean`],CS=`This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.`,wS={definitions:{$comment:`"definitions" has been replaced by "$defs".`,type:`object`,additionalProperties:{$dynamicRef:`#meta`},deprecated:!0,default:{}},dependencies:{$comment:`"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.`,type:`object`,additionalProperties:{anyOf:[{$dynamicRef:`#meta`},{$ref:`meta/validation#/$defs/stringArray`}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:`"$recursiveAnchor" has been replaced by "$dynamicAnchor".`,$ref:`meta/core#/$defs/anchorString`,deprecated:!0},$recursiveRef:{$comment:`"$recursiveRef" has been replaced by "$dynamicRef".`,$ref:`meta/core#/$defs/uriReferenceString`,deprecated:!0}},TS={$schema:gS,$id:_S,$vocabulary:vS,$dynamicAnchor:yS,title:bS,allOf:xS,type:SS,$comment:CS,properties:wS}})),DS=r({$defs:()=>FS,$dynamicAnchor:()=>jS,$id:()=>kS,$schema:()=>OS,$vocabulary:()=>AS,default:()=>IS,properties:()=>PS,title:()=>MS,type:()=>NS}),OS,kS,AS,jS,MS,NS,PS,FS,IS,LS=n((()=>{OS=`https://json-schema.org/draft/2020-12/schema`,kS=`https://json-schema.org/draft/2020-12/meta/applicator`,AS={"https://json-schema.org/draft/2020-12/vocab/applicator":!0},jS=`meta`,MS=`Applicator vocabulary meta-schema`,NS=[`object`,`boolean`],PS={prefixItems:{$ref:`#/$defs/schemaArray`},items:{$dynamicRef:`#meta`},contains:{$dynamicRef:`#meta`},additionalProperties:{$dynamicRef:`#meta`},properties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},patternProperties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},propertyNames:{$dynamicRef:`#meta`},if:{$dynamicRef:`#meta`},then:{$dynamicRef:`#meta`},else:{$dynamicRef:`#meta`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$dynamicRef:`#meta`}},FS={schemaArray:{type:`array`,minItems:1,items:{$dynamicRef:`#meta`}}},IS={$schema:OS,$id:kS,$vocabulary:AS,$dynamicAnchor:jS,title:MS,type:NS,properties:PS,$defs:FS}})),RS=r({$dynamicAnchor:()=>HS,$id:()=>BS,$schema:()=>zS,$vocabulary:()=>VS,default:()=>KS,properties:()=>GS,title:()=>US,type:()=>WS}),zS,BS,VS,HS,US,WS,GS,KS,qS=n((()=>{zS=`https://json-schema.org/draft/2020-12/schema`,BS=`https://json-schema.org/draft/2020-12/meta/unevaluated`,VS={"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},HS=`meta`,US=`Unevaluated applicator vocabulary meta-schema`,WS=[`object`,`boolean`],GS={unevaluatedItems:{$dynamicRef:`#meta`},unevaluatedProperties:{$dynamicRef:`#meta`}},KS={$schema:zS,$id:BS,$vocabulary:VS,$dynamicAnchor:HS,title:US,type:WS,properties:GS}})),JS=r({$dynamicAnchor:()=>QS,$id:()=>XS,$schema:()=>YS,$vocabulary:()=>ZS,default:()=>nC,properties:()=>tC,title:()=>$S,type:()=>eC}),YS,XS,ZS,QS,$S,eC,tC,nC,rC=n((()=>{YS=`https://json-schema.org/draft/2020-12/schema`,XS=`https://json-schema.org/draft/2020-12/meta/content`,ZS={"https://json-schema.org/draft/2020-12/vocab/content":!0},QS=`meta`,$S=`Content vocabulary meta-schema`,eC=[`object`,`boolean`],tC={contentEncoding:{type:`string`},contentMediaType:{type:`string`},contentSchema:{$dynamicRef:`#meta`}},nC={$schema:YS,$id:XS,$vocabulary:ZS,$dynamicAnchor:QS,title:$S,type:eC,properties:tC}})),iC=r({$defs:()=>fC,$dynamicAnchor:()=>cC,$id:()=>oC,$schema:()=>aC,$vocabulary:()=>sC,default:()=>pC,properties:()=>dC,title:()=>lC,type:()=>uC}),aC,oC,sC,cC,lC,uC,dC,fC,pC,mC=n((()=>{aC=`https://json-schema.org/draft/2020-12/schema`,oC=`https://json-schema.org/draft/2020-12/meta/core`,sC={"https://json-schema.org/draft/2020-12/vocab/core":!0},cC=`meta`,lC=`Core vocabulary meta-schema`,uC=[`object`,`boolean`],dC={$id:{$ref:`#/$defs/uriReferenceString`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{$ref:`#/$defs/uriString`},$ref:{$ref:`#/$defs/uriReferenceString`},$anchor:{$ref:`#/$defs/anchorString`},$dynamicRef:{$ref:`#/$defs/uriReferenceString`},$dynamicAnchor:{$ref:`#/$defs/anchorString`},$vocabulary:{type:`object`,propertyNames:{$ref:`#/$defs/uriString`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$dynamicRef:`#meta`}}},fC={anchorString:{type:`string`,pattern:`^[A-Za-z_][-A-Za-z0-9._]*$`},uriString:{type:`string`,format:`uri`},uriReferenceString:{type:`string`,format:`uri-reference`}},pC={$schema:aC,$id:oC,$vocabulary:sC,$dynamicAnchor:cC,title:lC,type:uC,properties:dC,$defs:fC}})),hC=r({$dynamicAnchor:()=>yC,$id:()=>_C,$schema:()=>gC,$vocabulary:()=>vC,default:()=>CC,properties:()=>SC,title:()=>bC,type:()=>xC}),gC,_C,vC,yC,bC,xC,SC,CC,wC=n((()=>{gC=`https://json-schema.org/draft/2020-12/schema`,_C=`https://json-schema.org/draft/2020-12/meta/format-annotation`,vC={"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},yC=`meta`,bC=`Format vocabulary meta-schema for annotation results`,xC=[`object`,`boolean`],SC={format:{type:`string`}},CC={$schema:gC,$id:_C,$vocabulary:vC,$dynamicAnchor:yC,title:bC,type:xC,properties:SC}})),TC=r({$dynamicAnchor:()=>kC,$id:()=>DC,$schema:()=>EC,$vocabulary:()=>OC,default:()=>NC,properties:()=>MC,title:()=>AC,type:()=>jC}),EC,DC,OC,kC,AC,jC,MC,NC,PC=n((()=>{EC=`https://json-schema.org/draft/2020-12/schema`,DC=`https://json-schema.org/draft/2020-12/meta/meta-data`,OC={"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},kC=`meta`,AC=`Meta-data vocabulary meta-schema`,jC=[`object`,`boolean`],MC={title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}},NC={$schema:EC,$id:DC,$vocabulary:OC,$dynamicAnchor:kC,title:AC,type:jC,properties:MC}})),FC=r({$defs:()=>UC,$dynamicAnchor:()=>zC,$id:()=>LC,$schema:()=>IC,$vocabulary:()=>RC,default:()=>WC,properties:()=>HC,title:()=>BC,type:()=>VC}),IC,LC,RC,zC,BC,VC,HC,UC,WC,GC=n((()=>{IC=`https://json-schema.org/draft/2020-12/schema`,LC=`https://json-schema.org/draft/2020-12/meta/validation`,RC={"https://json-schema.org/draft/2020-12/vocab/validation":!0},zC=`meta`,BC=`Validation vocabulary meta-schema`,VC=[`object`,`boolean`],HC={type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}}},UC={nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},WC={$schema:IC,$id:LC,$vocabulary:RC,$dynamicAnchor:zC,title:BC,type:VC,properties:HC,$defs:UC}})),KC=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var n=(ES(),t(hS).default),r=(LS(),t(DS).default),i=(qS(),t(RS).default),a=(rC(),t(JS).default),o=(mC(),t(iC).default),s=(wC(),t(hC).default),c=(PC(),t(TC).default),l=(GC(),t(FC).default),u=[`/properties`];function d(e){return[n,r,i,a,o,t(this,s),c,t(this,l)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function t(t,n){return e?t.$dataMetaSchema(n,u):n}}e.default=d})),qC=i(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2020=void 0;var n=Ky(),r=mS(),i=jb(),a=KC(),o=`https://json-schema.org/draft/2020-12/schema`,s=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(a.default.call(this,e),this.refs[`http://json-schema.org/schema`]=o)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}};e.Ajv2020=s,t.exports=e=s,t.exports.Ajv2020=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s;var c=Ay();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var l=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return l._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return l.CodeGen}});var u=jy();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=My();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})),JC=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:E,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:y,int32:{type:`number`,validate:S},int64:{type:`number`,validate:C},float:{type:`number`,validate:w},double:{type:`number`,validate:w},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-+(d<0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}var d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}var h=/\/|:/,g=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _(e){return h.test(e)&&g.test(e)}var v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}var b=-(2**31),x=2**31-1;function S(e){return Number.isInteger(e)&&e<=x&&e>=b}function C(e){return Number.isInteger(e)}function w(){return!0}var T=/[^\\]\\Z/;function E(e){if(T.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),YC=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;var t=Vb(),n=X(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),XC=i(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=JC(),r=YC(),i=X(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s})),ZC=Vb(),QC=pS(),$C=qC(),ew=e(XC(),1),tw=[`example`,`externalDocs`,`xml`,`markdownDescription`,`enumDescriptions`,`enumNames`,`enumTitles`];function nw(e,t=new Set){if(e&&typeof e==`object`)for(let[n,r]of Object.entries(e))n.startsWith(`x-`)&&t.add(n),nw(r,t);return t}function rw(e,t){let n=new e({strict:!0,strictTypes:!1,strictTuples:!1,strictRequired:!1,allowUnionTypes:!0,allErrors:!0});(0,ew.default)(n);for(let e of[...tw,...nw(t)])n.addKeyword({keyword:e,valid:!0});return n}var iw=new Map;function aw(e){let t=JSON.stringify(e),n=iw.get(t);if(n)return n;let r=typeof e==`object`?e.$schema:void 0,i=rw(typeof r==`string`&&r.includes(`draft-07`)?ZC.Ajv:typeof r==`string`&&r.includes(`2019-09`)?QC.Ajv2019:$C.Ajv2020,e);try{let n=i.compile(e);if(`$async`in n)throw Error(`Asynchronous schemas are not supported`);return iw.size>=200&&iw.clear(),iw.set(t,n),n}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`MCP JSON Schema cannot be validated: ${t}. Reconfigure the tool schema (supported dialects: draft-07, 2019-09, 2020-12). No validation was skipped.`)}}function ow(e,t){let n=aw(e);if(!n(t))throw Error(`MCP schema validation failed: `+(n.errors??[]).map(e=>`${e.instancePath||`/`} ${e.keyword}`).join(`; `))}function sw(e,t){if(!t.length||typeof e==`boolean`)return e;let[n,...r]=t,i=e.properties,a=i&&typeof i==`object`&&!Array.isArray(i)?i[n]:void 0;return a!==void 0&&(typeof a==`boolean`||a&&typeof a==`object`&&!Array.isArray(a))?sw(a,r):!0}function cw(e){for(let t of[`inputSchema`,`outputSchema`]){let n=e[t];if(n!==void 0)try{aw(n)}catch(n){throw Error(`MCP tool ${JSON.stringify(e.toolName)} ${t}: ${n instanceof Error?n.message:String(n)}`)}}}var lw=my();Y({structuredContent:lw,content:kv(Y({type:J()}).catchall(lw))}).strict();function uw(e){return typeof e==`string`&&/^[A-Za-z_][A-Za-z0-9_-]{0,127}$/.test(e)&&![`__proto__`,`constructor`,`prototype`].includes(e)}var dw=class{nodes=[{variable:1/0,choices:[]},{variable:1/0,choices:[]}];unique=new Map;cache=new Map;outcome(e,t){return this.node(e,Array.from({length:5},(e,n)=>Number(n===t)))}and(e,t){return this.apply(`and`,e,t)}or(e,t){return this.apply(`or`,e,t)}not(e){if(e<2)return 1-e;let t=`not:${e}`,n=this.cache.get(t);if(n!==void 0)return n;let r=this.nodes[e],i=this.node(r.variable,r.choices.map(e=>this.not(e)));return this.cache.set(t,i),i}implies(e,t){return this.and(e,this.not(t))===0}node(e,t){if(t.every(e=>e===t[0]))return t[0];let n=`${e}:${t.join(`,`)}`,r=this.unique.get(n);if(r!==void 0)return r;let i=this.nodes.length;return this.nodes.push({variable:e,choices:t}),this.unique.set(n,i),i}apply(e,t,n){if(t===n)return t;if(e===`and`){if(t===0||n===0)return 0;if(t===1)return n;if(n===1)return t}else{if(t===1||n===1)return 1;if(t===0)return n;if(n===0)return t}let r=`${e}:${Math.min(t,n)}:${Math.max(t,n)}`,i=this.cache.get(r);if(i!==void 0)return i;let a=this.nodes[t],o=this.nodes[n],s=Math.min(a.variable,o.variable),c=this.node(s,Array.from({length:5},(r,i)=>this.apply(e,a.variable===s?a.choices[i]:t,o.variable===s?o.choices[i]:n)));return this.cache.set(r,c),c}};function fw(e){let t=e.steps.map(e=>e.id),n=new Set(t);if(n.size!==t.length)throw Error(`Step IDs must be unique`);if(new Set(e.edges.map(e=>e.id)).size!==e.edges.length)throw Error(`Edge IDs must be unique`);let r=new Map(t.map(e=>[e,[]])),i=new Map(t.map(e=>[e,[]]));for(let t of e.edges){if(!n.has(t.from)||!n.has(t.to))throw Error(`Unknown edge endpoint`);r.get(t.to).push(t),i.get(t.from).push(t)}let a=t.filter(e=>!r.get(e).length),o=new Set(a),s=[...a];for(let e=0;e<s.length;e++)for(let t of i.get(s[e]))o.has(t.to)||(o.add(t.to),s.push(t.to));if(o.size!==n.size)throw Error(`Workflow cycle has no entry from a root`);let c=new Map(t.map(e=>[e,new Set(a.includes(e)?[e]:t)])),l=!0;for(;l;){l=!1;for(let e of s){let t=r.get(e);if(!t.length)continue;let n=new Set([...c.get(t[0].from)].filter(e=>t.every(t=>c.get(t.from).has(e))));n.add(e);let i=c.get(e);(n.size!==i.size||[...n].some(e=>!i.has(e)))&&(c.set(e,n),l=!0)}}let u=e.edges.filter(e=>c.get(e.from).has(e.to)),d=new Set(u.map(e=>e.id)),f=new Map;for(let e of u){let t=f.get(e.to)??new Set([e.to]),n=[e.from];for(;n.length;){let e=n.pop();t.has(e)||(t.add(e),n.push(...r.get(e).map(e=>e.from)))}f.set(e.to,t)}let p=[...f].map(([n,r])=>({headerId:n,memberIds:t.filter(e=>r.has(e)),backEdgeIds:u.filter(e=>e.to===n).map(e=>e.id),entryEdgeIds:e.edges.filter(e=>!r.has(e.from)&&r.has(e.to)).map(e=>e.id),exitEdgeIds:e.edges.filter(e=>r.has(e.from)&&!r.has(e.to)).map(e=>e.id)}));for(let t of p){let n=f.get(t.headerId);if(e.edges.some(e=>!n.has(e.from)&&n.has(e.to)&&e.to!==t.headerId))throw Error(`Workflow loop has multiple entry steps`);let r=[];for(let e of p){if(e===t)continue;let i=f.get(e.headerId),a=t.memberIds.filter(e=>i.has(e)).length;if(a){if(a===n.size&&n.size<i.size)r.push(e);else if(a!==i.size||n.size===i.size)throw Error(`Workflow loops overlap without strict nesting`)}}r.sort((e,t)=>e.memberIds.length-t.memberIds.length),r[0]&&(t.parentHeaderId=r[0].headerId)}let m=[],h=new Set(t);for(;h.size;){let e=[...h].filter(e=>r.get(e).every(e=>d.has(e.id)||!h.has(e.from)));if(!e.length)throw Error(`Workflow contains an irreducible or multiple-entry cycle`);for(let t of e)m.push(t),h.delete(t)}return p.sort((e,n)=>n.memberIds.length-e.memberIds.length||t.indexOf(e.headerId)-t.indexOf(n.headerId)),{loops:p,order:m}}var pw=J().refine(e=>![`__proto__`,`constructor`,`prototype`].includes(e),`Reserved dictionary key`);function mw(e){return Tv().superRefine((e,t)=>{if(e&&typeof e==`object`)for(let n of Object.keys(e))pw.safeParse(n).success||t.addIssue({code:`custom`,message:`Reserved dictionary key`,path:[n]})}).pipe(Rv(pw,e))}var hw=uy(()=>Mv([Cv(),xv(),_v(),J(),kv(hw),Rv(J(),hw)])),gw=uy(()=>Pv(`type`,[Y({type:Hv(`null`)}).strict(),Y({type:Hv(`json`),schema:Mv([xv(),Rv(J(),hw)]).optional()}).strict(),Y({type:Hv(`string`)}).strict(),Y({type:Hv(`number`),integer:xv().optional()}).strict(),Y({type:Hv(`boolean`)}).strict(),Y({type:Hv(`enum`),values:kv(J()).min(1).refine(e=>new Set(e).size===e.length)}).strict(),Y({type:Hv(`array`),items:gw}).strict(),Y({type:Hv(`union`),variants:kv(gw).min(2)}).strict(),Y({type:Hv(`object`),fields:mw(Y({schema:gw,required:xv().optional(),default:hw.optional()}).strict())}).strict()]));function _w(e){switch(e.type){case`null`:return Cv();case`json`:return e.schema!==void 0&&aw(e.schema),hw.superRefine((t,n)=>{try{e.schema!==void 0&&ow(e.schema,t)}catch(e){n.addIssue({code:`custom`,message:e.message})}});case`string`:return J();case`number`:return e.integer?_v().int():_v();case`boolean`:return xv();case`enum`:return Bv(e.values);case`array`:return kv(_w(e.items));case`union`:return Mv(e.variants.map(_w));case`object`:return Y(Object.fromEntries(Object.entries(e.fields).map(([e,t])=>{let n=_w(t.schema);return t.default===void 0?t.required||(n=n.optional()):n=n.default(vw(t.schema,t.default)),[e,n]}))).strict()}}function vw(e,t){return hw.parse(_w(e).parse(t))}function yw(e){gw.parse(e),_w(e)}function bw(e){switch(e.type){case`json`:return`unknown`;case`enum`:return e.values.map(e=>JSON.stringify(e)).join(` | `);case`array`:return`Array<${bw(e.items)}>`;case`union`:return e.variants.map(bw).join(` | `);case`object`:return`{ ${Object.entries(e.fields).map(([e,t])=>`${JSON.stringify(e)}${t.required||t.default!==void 0?``:`?`}: ${bw(t.schema)}`).join(`; `)} }`;default:return e.type}}var xw={type:`object`,fields:{exitCode:{schema:{type:`number`,integer:!0},required:!0},stdout:{schema:{type:`string`},required:!0},stderr:{schema:{type:`string`},required:!0}}};function Sw(e){if(e.kind===`workflow`)return e.contract.outputSchema;if(e.kind===`mcp`)return{type:`object`,fields:{structuredContent:{required:!0,schema:{type:`json`,...e.tool.outputSchema===void 0?{}:{schema:e.tool.outputSchema}}},content:{required:!0,schema:{type:`array`,items:{type:`json`}}}}};if(e.kind===`shell`)return xw;if(e.kind===`branch`)return{type:`boolean`};if(e.kind!==`join`)return e.outputSchema}function Cw(e,t){if(!t.length)return{schema:e,optional:!1};if(e.type===`json`)return{schema:{type:`json`,schema:sw(e.schema??!0,t)},optional:!1};if(e.type===`null`)return{schema:{type:`json`},optional:!1};if(e.type===`union`){let n=e.variants.map(e=>Cw(e,t));return{schema:Ew(n.map(e=>e.schema)),optional:n.some(e=>e.optional)}}let[n,...r]=t;if(e.type===`object`){let t=Object.hasOwn(e.fields,n)?e.fields[n]:void 0;if(!t)throw Error(`Unknown field: ${n}`);let i=Cw(t.schema,r);return{schema:i.schema,optional:i.optional||!t.required&&t.default===void 0}}if(e.type===`array`&&/^(0|[1-9]\d*)$/.test(n))return{schema:Cw(e.items,r).schema,optional:!0};throw Error(`Invalid field path: ${n}`)}function ww(e,t){return t.type===`json`||e.type===`json`?!0:e.type===`union`?e.variants.every(e=>ww(e,t)):t.type===`union`?t.variants.some(t=>ww(e,t)):e.type===`enum`?t.type===`string`||t.type===`enum`&&e.values.every(e=>t.values.includes(e)):e.type===t.type?e.type===`number`&&t.type===`number`?!t.integer||!!e.integer:e.type===`array`&&t.type===`array`?ww(e.items,t.items):e.type===`object`&&t.type===`object`?Object.keys(e.fields).every(e=>Object.hasOwn(t.fields,e))&&Object.entries(t.fields).every(([t,n])=>{let r=Object.hasOwn(e.fields,t)?e.fields[t]:void 0,i=n.required&&n.default===void 0;return r?(!i||r.required||r.default!==void 0)&&ww(r.schema,n.schema):!i}):!0:!1}function Tw(e){return e.type===`object`?{type:`object`,fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,{schema:Tw(t.schema)}]))}:e.type===`array`?{type:`array`,items:Tw(e.items)}:e.type===`union`?Ew(e.variants.map(Tw)):e}function Ew(e){let t=[...new Map(e.map(e=>[JSON.stringify(e),e])).values()];return t.length===1?t[0]:{type:`union`,variants:t}}var Dw=Pv(`source`,[Y({source:Hv(`input`),path:kv(J())}).strict(),Y({source:Hv(`step`),stepId:J(),path:kv(J())}).strict()]),Ow=uy(()=>Pv(`kind`,[Y({kind:Hv(`literal`),value:my()}).strict(),Y({kind:Hv(`reference`),reference:Dw}).strict(),Y({kind:Hv(`object`),fields:mw(Ow)}).strict(),Y({kind:Hv(`array`),items:kv(Ow)}).strict()])),kw=Mv([xv(),Rv(J(),my())]),Aw=Pv(`kind`,[Y({kind:Hv(`template`),template:Ow}).strict(),Y({kind:Hv(`reference`),reference:Dw}).strict(),Y({kind:Hv(`object`),fields:mw(Dw)}).strict()]),jw={id:pw.min(1),name:pw.min(1),inputSchema:gw.optional(),mapping:Aw.optional(),repeatMapping:Aw.optional(),permission:Bv([`ask`,`auto-accept`]).optional(),timeoutMs:_v().int().positive().max(2147483647).optional(),secrets:mw(J().refine(uw,`Invalid secret reference`)).optional(),position:Y({x:_v(),y:_v()}).strict().optional()},Mw=Pv(`operator`,[Y({operator:Hv(`truthy`),path:kv(J())}).strict(),Y({operator:Bv([`equals`,`not-equals`]),path:kv(J()),value:my()}).strict(),Y({operator:Bv([`greater-than`,`less-than`]),path:kv(J()),value:_v()}).strict()]),Nw=Y({version:Hv(1),id:J().regex(/^[a-zA-Z0-9_-]{1,128}$/),name:J().min(1),backend:J().min(1),projectId:J().optional(),permission:Bv([`ask`,`auto-accept`]).optional(),inputSchema:gw.refine(e=>e.type===`object`),steps:kv(Pv(`kind`,[Y({...jw,kind:Hv(`agent`),instructions:J(),model:J().min(1),effort:Bv([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),outputSchema:gw}).strict(),Y({...jw,kind:Hv(`shell`),command:J(),acceptedExitCodes:kv(_v().int()).min(1).optional()}).strict(),Y({...jw,kind:Hv(`typescript`),code:J(),outputSchema:gw}).strict(),Y({...jw,kind:Hv(`branch`),condition:Mw}).strict(),Y({...jw,kind:Hv(`join`)}).strict(),Y({...jw,kind:Hv(`workflow`),workflowId:J().regex(/^[a-zA-Z0-9_-]{1,128}$/),contract:Y({inputSchema:gw.refine(e=>e.type===`object`),outputSchema:gw}).strict()}).strict(),Y({...jw,kind:Hv(`mcp`),tool:Y({connectionId:J().min(1),connectionName:J(),identity:J().regex(/^[a-f0-9]{64}$/),serverIdentity:J().regex(/^[a-f0-9]{64}$/),toolName:J().min(1),inputSchema:kw,outputSchema:kw.optional()}).strict()}).strict()])).min(1),loopSettings:mw(Y({maxTries:_v().int().min(1).max(100)}).strict()).optional(),edges:kv(Y({id:J().min(1),from:J(),to:J(),outcome:Bv([`success`,`failure`,`timeout`,`true`,`false`])}).strict())}).strict();function Pw(e){return Iw(e)}function Fw(e){return Iw(e,!0)}function Iw(e,t=!1){let n=Nw.parse(e),r=n.steps.find(e=>e.kind===`agent`&&Fo(e.instructions));if(r&&!n.projectId)throw Error(`Workflow Step ${JSON.stringify(r.name)} invokes a Skill and requires a Project binding`);yw(n.inputSchema);let i=new Map(n.steps.map(e=>[e.id,e]));if(i.size!==n.steps.length||new Set(n.steps.map(e=>e.name)).size!==i.size)throw Error(`Step IDs and names must be unique`);if(new Set(n.edges.map(e=>e.id)).size!==n.edges.length)throw Error(`Edge IDs must be unique`);let a=new Map(n.steps.map(e=>[e.id,[]])),o=new Map(n.steps.map(e=>[e.id,[]])),s=new Set;for(let e of n.edges){let t=i.get(e.from);if(!t||!i.has(e.to))throw Error(`Unknown edge endpoint`);let n=JSON.stringify([e.from,e.to,e.outcome]);if(s.has(n))throw Error(`Duplicate connection`);if(s.add(n),t.kind===`branch`?![`true`,`false`,`failure`,`timeout`].includes(e.outcome):[`true`,`false`].includes(e.outcome))throw Error(`Invalid edge outcome`);a.get(e.to).push(e),o.get(e.from).push(e)}let c=fw(n),l=c.loops.map(e=>({...e,maxTries:n.loopSettings?.[e.headerId]?.maxTries??3})),u=new Map(l.map(e=>[e.headerId,e]));for(let e of Object.keys(n.loopSettings??{}))if(!u.has(e))throw Error(`Loop settings require a loop header`);for(let e of i.values())if(e.repeatMapping&&!u.has(e.id))throw Error(`Repeat mapping requires a loop header`);let d=new Set(l.flatMap(e=>e.backEdgeIds)),f=new Map([...a].map(([e,t])=>[e,t.filter(e=>!d.has(e.id))])),p=c.order.map(e=>i.get(e)),m=new dw,h=new Map,g=new Map,_=new Map,v=new Map,y=e=>e.reduce((e,t)=>m.or(e,t),0),b=new Map,x=new Map,S=new Map,C=new Map,w=new Map,T=new Map,E={definition:n,order:p,incoming:a,outgoing:o,forwardIncoming:f,loops:l,outputSchemas:x,inputSchemas:S,firstInputSchemas:C,repeatInputSchemas:w};for(let e of p){let t=f.get(e.id),n=y(t.map(e=>v.get(e.id))),r=m.and(t.length?y(t.map(e=>_.get(e.id))):1,m.not(n)),i=m.or(y(t.map(e=>m.and(_.get(e.id),e.outcome===`failure`||e.outcome===`timeout`?1:g.get(e.from)))),u.has(e.id)?m.and(r,m.outcome(p.length+p.indexOf(e),1)):0);T.set(e.id,r),g.set(e.id,i);let a=p.indexOf(e),s=m.outcome(a,1),c=m.outcome(a,2),l=m.not(m.or(s,c));h.set(e.id,m.and(r,l));let d={success:l,failure:s,timeout:c,true:y([m.outcome(a,0),m.outcome(a,3)]),false:m.outcome(a,4)},x=o.get(e.id),S=m.or(m.and(s,x.some(e=>e.outcome===`failure`)?i:1),m.and(c,x.some(e=>e.outcome===`timeout`)?i:1));for(let e of x){let t=e.outcome===`failure`||e.outcome===`timeout`;_.set(e.id,m.and(r,m.and(d[e.outcome],t?m.not(i):1))),v.set(e.id,m.or(n,t?0:m.and(r,S)))}b.set(e.id,new Set(t.flatMap(e=>[e.from,...b.get(e.from)])))}for(let e of l){let t=y(e.backEdgeIds.map(e=>_.get(e))),n=e.memberIds.map(e=>{let t=y(o.get(e).map(e=>_.get(e.id)));return m.and(h.get(e),m.not(t))}),r=y([...e.exitEdgeIds.map(e=>_.get(e)),...n]);if(m.and(t,r)!==0)throw Error(`Loop ${e.headerId} can select exit and repeat together`)}let D=new Set,O=e=>{let t=x.get(e);if(t)return t;let n=i.get(e),r=Sw(n)??n.inputSchema??A(e);return yw(r),x.set(e,r),r},k=(e,r)=>{let o=u.get(e.id),s=r?a.get(e.id).filter(e=>o.backEdgeIds.includes(e.id)):f.get(e.id),c=r?y(s.map(e=>_.get(e.id))):T.get(e.id),l=r?new Set(s.flatMap(e=>[e.from,...b.get(e.from)])):b.get(e.id),d=r?e.repeatMapping:e.mapping,p=e=>{if(e.source===`input`)return Cw(n.inputSchema,e.path);let t=i.get(e.stepId);if(!t||!l.has(e.stepId))throw Error(`Mapping must reference an earlier step`);if(!m.implies(c,h.get(t.id)))throw Error(`Output is not guaranteed: ${t.name}`);return Cw(O(t.id),e.path)};if(e.kind===`join`&&d)throw Error(`Joins collect selected incoming outputs without mappings`);let g;if(d?.kind===`template`){let n=e=>{e.kind===`reference`&&p(e.reference),e.kind===`object`&&Object.values(e.fields).forEach(n),e.kind===`array`&&e.items.forEach(n)};n(d.template);let r=e=>{if(e.kind===`reference`)return p(e.reference).schema;if(e.kind===`object`)return{type:`object`,fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,{schema:r(t),required:!0}]))};if(e.kind===`array`)return{type:`array`,items:e.items.length?Ew(e.items.map(r)):{type:`json`}};let t=e=>e===null?{type:`null`}:typeof e==`string`?{type:`enum`,values:[e]}:typeof e==`number`?{type:`number`,integer:Number.isInteger(e)}:typeof e==`boolean`?{type:`boolean`}:Array.isArray(e)?{type:`array`,items:e.length?Ew(e.map(t)):{type:`json`}}:{type:`object`,fields:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,{schema:t(n),required:!0}]))};return t(e.value)};g=e.kind===`workflow`?r(d.template):{type:`json`},e.kind===`workflow`&&!t&&d.template.kind===`literal`&&vw(e.contract.inputSchema,d.template.value)}else if(d?.kind===`reference`){let e=p(d.reference);if(e.optional)throw Error(`A direct input reference must be required or have a default`);g=e.schema}else if(d?.kind===`object`)g={type:`object`,fields:Object.fromEntries(Object.entries(d.fields).map(([e,t])=>{let n=p(t);return[e,{schema:n.schema,required:!n.optional}]}))};else if(!s.length)g=n.inputSchema;else{let t=[...new Set(s.map(e=>e.from))],n=Object.fromEntries(t.map(e=>{let t=i.get(e),n=s.filter(t=>t.from===e),r=Ew(n.map(t=>t.outcome===`failure`||t.outcome===`timeout`?Lw(i.get(e).inputSchema??A(e),O(e)):O(e)));return[t.name,{schema:r,required:m.implies(c,y(n.map(e=>_.get(e.id))))}]})),r={type:`object`,fields:n},a=Object.values(n).filter(e=>e.required).length;g=e.kind===`join`||a>1?r:Ew([...Object.values(n).map(e=>e.schema),...t.length>1?[r]:[]])}if(e.inputSchema&&(yw(e.inputSchema),!(t&&e.kind===`workflow`)&&!ww(g,e.inputSchema)))throw Error(`Input does not match the declared input schema`);if(e.kind===`workflow`){if(yw(e.contract.inputSchema),yw(e.contract.outputSchema),!t&&(!ww(g,e.contract.inputSchema)||e.inputSchema&&!ww(e.inputSchema,e.contract.inputSchema)))throw Error(`Input does not match the Workflow call input contract`);return e.contract.inputSchema}return e.inputSchema??g},A=e=>{let t=S.get(e);if(t)return t;if(D.has(e))throw Error(`Cyclic input schema at ${e}; declare a loop header inputSchema`);D.add(e);let n=i.get(e),r=k(n,!1);C.set(e,r);let a=r;if(u.has(e)){let t=k(n,!0);w.set(e,t),a=Ew([r,t])}return S.set(e,a),D.delete(e),a};for(let e of p){e.kind===`mcp`&&cw(e.tool);let t=A(e.id);if(e.kind===`branch`){let n=Cw(e.inputSchema??t,e.condition.path),r=e.condition.operator===`truthy`?`boolean`:[`greater-than`,`less-than`].includes(e.condition.operator)?`number`:void 0;if(r&&(n.optional||!ww(n.schema,{type:r})))throw Error(`Branch condition requires a required ${r}`)}O(e.id)}let j=p.map(e=>m.and(h.get(e.id),m.not(y(o.get(e.id).map(e=>_.get(e.id)))))),M=1;for(let e of p){let t=y(o.get(e.id).filter(e=>e.outcome===`failure`||e.outcome===`timeout`).map(e=>_.get(e.id)));M=m.and(M,m.or(m.not(T.get(e.id)),m.or(h.get(e.id),t))),l.length&&(M=m.and(M,m.not(y(o.get(e.id).filter(e=>d.has(e.id)).map(e=>_.get(e.id))))))}let N=p.map((e,t)=>({step:e,condition:j[t]})).filter(({condition:e})=>m.and(M,e)!==0),P=[],F=1,I=0,L=0;for(let{condition:e}of N)L=m.or(L,m.and(I,e)),I=m.or(m.and(I,m.not(e)),m.and(F,e)),F=m.and(F,m.not(e));if(l.length||n.edges.some(e=>e.outcome===`failure`||e.outcome===`timeout`)){let e=p.filter(e=>e.kind===`branch`?[`true`,`false`].some(t=>!o.get(e.id).some(e=>e.outcome===t)):!o.get(e.id).some(e=>e.outcome===`success`));P.push(...e.map(e=>O(e.id))),e.length>1&&P.push({type:`object`,fields:Object.fromEntries(e.map(e=>[e.name,{schema:O(e.id)}]))})}else{for(let{step:e,condition:t}of N)m.and(M,m.and(I,t))!==0&&P.push(O(e.id));let e=m.and(M,L);e!==0&&P.push({type:`object`,fields:Object.fromEntries(N.filter(({condition:t})=>m.and(e,t)!==0).map(({step:t,condition:n})=>[t.name,{schema:O(t.id),required:m.implies(e,n)}]))}),m.and(M,F)!==0&&P.push({type:`object`,fields:{}})}return{...E,resultSchema:P.length?Ew(P):{type:`json`}}}function Lw(e,t){return{type:`object`,fields:{input:{schema:e,required:!0},error:{required:!0,schema:{type:`object`,fields:{message:{schema:{type:`string`},required:!0},kind:{schema:{type:`enum`,values:[`failure`,`timeout`,`interrupted`]},required:!0}}}},partialOutput:{schema:Tw(t)}}}}function Rw(e,t){let n=1;for(;e.steps.some(e=>e.name===`${t}_${n}`);)n++;return`${t}_${n}`}function zw(e){return e&&typeof e==`object`&&`issues`in e&&Array.isArray(e.issues)?e.issues.map(e=>`${e.path?.map(String).join(`.`)||`Workflow`}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function Bw(e,t=[]){return[t,...e.type===`json`&&typeof e.schema==`object`&&e.schema.properties&&typeof e.schema.properties==`object`&&!Array.isArray(e.schema.properties)?Object.entries(e.schema.properties).flatMap(([e,n])=>Bw({type:`json`,schema:n},[...t,e])):[],...e.type===`object`?Object.entries(e.fields).flatMap(([e,n])=>Bw(n.schema,[...t,e])):[]]}function Vw(e,t,n=`reference`,r=`mapping`){if(!e.steps.find(e=>e.id===t))return[];let i={...e,steps:e.steps.map(e=>{if(e.id!==t)return e;let n={...e};return delete n[r],delete n.inputSchema,n})},a;try{a=Fw(i)}catch{let t=new Set(fw(e).loops.map(e=>e.headerId));i={...e,loopSettings:{},steps:e.steps.map(e=>{let n={...e};return delete n.inputSchema,n.mapping={kind:`reference`,reference:{source:`input`,path:[]}},t.has(e.id)?n.repeatMapping=n.mapping:delete n.repeatMapping,n.kind===`branch`&&(n.condition={operator:`equals`,path:[],value:null}),n.kind===`agent`&&!n.model&&(n.model=`unselected`),n.kind===`join`&&(delete n.mapping,delete n.repeatMapping),n})},a=Fw(i)}let o=Bw(e.inputSchema).map(e=>({label:`Workflow input${e.length?`.`+e.join(`.`):``}`,reference:{source:`input`,path:e}})),s=o.splice(0);for(let n of e.steps){if(n.id===t&&r===`mapping`)continue;let e=a.outputSchemas.get(n.id);if(e)for(let t of Bw(e)){let e={source:`step`,stepId:n.id,path:t};s.push({label:`${n.name}${t.length?`.`+t.join(`.`):``}`,reference:e})}}for(let e of s){let{reference:a}=e;try{Fw({...i,steps:i.steps.map(e=>e.id===t?{...e,[r]:n===`object`?{kind:`object`,fields:{value:a}}:{kind:`reference`,reference:a}}:e)}),o.push(e)}catch{}}return o}function Hw(e,t,n){let r=e.steps.find(e=>e.id===t),i=Pw(e),a=r?.kind===`mcp`?{type:`json`,schema:r.tool.inputSchema}:i.inputSchemas.get(t);if(!a)throw Error(`Select a step`);return vw(a,n)}function Uw(e,t,n){if(n)return`The workflow slot is occupied`;if(e.backend!==t)return`Requires Backend Adapter ${e.backend}`;try{Pw(e)}catch(e){return zw(e)}}function Ww(e,t,n){if(!t||[`__proto__`,`constructor`,`prototype`].includes(t))throw Error(`Invalid field name`);return{...e,mapping:{kind:`object`,fields:{...e.mapping?.kind===`object`?e.mapping.fields:{},[t]:n}}}}var Gw=e=>typeof e==`boolean`||typeof e==`object`&&e&&!Array.isArray(e)?e:!0;function Kw(e,t,n=new Set){if(typeof e==`boolean`)return{};let r={...e};if(typeof e.$ref==`string`&&e.$ref.startsWith(`#/`)&&!n.has(e.$ref)){n.add(e.$ref);let i=t;for(let t of e.$ref.slice(2).split(`/`).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)))i=i&&typeof i==`object`&&!Array.isArray(i)?i[t]??!0:!0;r={...Kw(Gw(i),t,n),...r}}for(let i of Array.isArray(e.allOf)?e.allOf:[]){let e=Kw(Gw(i),t,new Set(n));r={...e,...r,properties:{...qw(e),...qw(r)},required:[...new Set([...Array.isArray(e.required)?e.required:[],...Array.isArray(r.required)?r.required:[]])]}}return r}function qw(e){return e.properties&&typeof e.properties==`object`&&!Array.isArray(e.properties)?e.properties:{}}function Jw(e){if(e.kind===`reference`)return;if(e.kind===`literal`)return e.value;if(e.kind===`array`){let t=e.items.map(Jw);return t.some(e=>e===void 0)?void 0:t}let t=Object.entries(e.fields).map(([e,t])=>[e,Jw(t)]);return t.some(([,e])=>e===void 0)?void 0:Object.fromEntries(t)}function Yw(e){return Array.isArray(e)?{kind:`array`,items:e.map(Yw)}:e&&typeof e==`object`?{kind:`object`,fields:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Yw(t)]))}:{kind:`literal`,value:e}}function Xw(e,t=e){let n=Kw(e,t);return n.default!==void 0||n.const!==void 0?Yw(n.default??n.const??null):Array.isArray(n.enum)&&n.enum.length?Yw(n.enum[0]):n.type===`object`||n.properties?{kind:`object`,fields:{}}:n.type===`array`?{kind:`array`,items:[]}:{kind:`literal`,value:n.type===`null`?null:n.type===`boolean`?!1:n.type===`number`||n.type===`integer`?0:``}}function Zw(e,t,n){let r=[],i=n&&typeof n==`object`&&!Array.isArray(n)?n:{};if(e.if!==void 0&&n!==void 0){let i=!1;try{let r=Gw(e.if);ow(typeof r==`boolean`?r:{...typeof t==`object`&&t.$defs?{$defs:t.$defs}:{},...typeof t==`object`&&t.definitions?{definitions:t.definitions}:{},...r},n),i=!0}catch{}r.push(Gw(i?e.then:e.else))}for(let t of[`dependentSchemas`,`dependencies`]){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))for(let[e,t]of Object.entries(n))Object.hasOwn(i,e)&&!Array.isArray(t)&&r.push(Gw(t))}return r.reduce((e,n)=>{let r=Kw(n,t);return{...e,...r,properties:{...qw(e),...qw(r)},required:[...new Set([...Array.isArray(e.required)?e.required:[],...Array.isArray(r.required)?r.required:[]])]}},e)}function Qw(e,t){return Gw(Array.isArray(e.prefixItems)?e.prefixItems[t]??e.items:Array.isArray(e.items)?e.items[t]??e.additionalItems:e.items)}function $w({schema:e,root:t=e,template:n,onChange:r,choices:i=[],label:a=`Arguments`,depth:o=0}){let[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(0),d=Zw(Kw(e,t),t,Jw(n)),f=Array.isArray(d.oneOf)?d.oneOf:Array.isArray(d.anyOf)?d.anyOf:Array.isArray(d.type)?d.type.map(e=>({type:e})):[],p=f.length?Kw(Gw(f[l]),t):{},m={...d,...p,properties:{...qw(d),...qw(p)}},h=qw(m),g=Jw(n),_=n.kind===`object`?`object`:n.kind===`array`?`array`:g===null?`null`:typeof g,v=(e,n,r,a)=>(0,U.jsx)($w,{schema:e,root:t,template:n,onChange:r,choices:i,label:a,depth:o+1});return(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:a}),typeof m.description==`string`&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m.description}),i.length>0&&(0,U.jsxs)(Rt,{value:n.kind===`reference`?JSON.stringify(n.reference):`literal`,onValueChange:n=>{if(n===`literal`)r(Xw(e,t));else{let e=i.find(e=>JSON.stringify(e.reference)===n);e&&r({kind:`reference`,reference:e.reference})}},children:[(0,U.jsx)(jt,{"aria-label":`${a} source`,children:(0,U.jsx)(It,{children:n.kind===`reference`?i.find(e=>JSON.stringify(e.reference)===JSON.stringify(n.reference))?.label??`Unavailable reference`:`Literal value`})}),(0,U.jsxs)(At,{children:[(0,U.jsx)(Ct,{value:`literal`,children:`Literal value`}),i.map(e=>(0,U.jsx)(Ct,{value:JSON.stringify(e.reference),children:e.label},e.label))]})]}),n.kind!==`reference`&&(0,U.jsxs)(U.Fragment,{children:[f.length>0&&(0,U.jsxs)(Rt,{value:l,onValueChange:e=>{e!==null&&(u(e),r(Xw(Gw(f[e]),t)))},children:[(0,U.jsx)(jt,{"aria-label":`${a} variant`,children:(0,U.jsxs)(It,{children:[`Variant `,l+1]})}),(0,U.jsx)(At,{children:f.map((e,t)=>(0,U.jsxs)(Ct,{value:t,children:[`Variant `,t+1]},t))})]}),(0,U.jsxs)(Rt,{value:_,onValueChange:e=>{e&&r(Xw({type:e}))},children:[(0,U.jsx)(jt,{"aria-label":`${a} JSON type`,children:(0,U.jsx)(It,{children:_})}),(0,U.jsx)(At,{children:[`object`,`array`,`string`,`number`,`boolean`,`null`].map(e=>(0,U.jsx)(Ct,{value:e,children:e},e))})]}),Array.isArray(m.enum)&&(0,U.jsxs)(Rt,{value:JSON.stringify(g),onValueChange:e=>{e&&r(Yw(JSON.parse(e)))},children:[(0,U.jsx)(jt,{"aria-label":`${a} enum`,children:(0,U.jsx)(It,{children:JSON.stringify(g)})}),(0,U.jsx)(At,{children:m.enum.map((e,t)=>(0,U.jsx)(Ct,{value:JSON.stringify(e),children:JSON.stringify(e)},t))})]}),n.kind===`object`&&(0,U.jsxs)(U.Fragment,{children:[[...new Set([...Object.keys(h),...Object.keys(n.fields)])].map(e=>{let i=Object.hasOwn(n.fields,e)?n.fields[e]:void 0,o=m.patternProperties&&typeof m.patternProperties==`object`&&!Array.isArray(m.patternProperties)?Object.entries(m.patternProperties).filter(([t])=>{try{return new RegExp(t).test(e)}catch{return!1}}).map(([,e])=>e):[],s=Gw(Object.hasOwn(h,e)?h[e]:o.length?{allOf:o}:m.additionalProperties);return(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{"aria-label":`Include ${a}.${e}`,checked:!!i,onCheckedChange:i=>{let a={...n.fields};i?a[e]=Xw(s,t):delete a[e],r({kind:`object`,fields:a})}}),e,Array.isArray(m.required)&&m.required.includes(e)?` *`:``]}),i&&v(s,i,t=>r({kind:`object`,fields:{...n.fields,[e]:t}}),`${a}.${e}`)]},e)}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(he,{"aria-label":`${a} new property`,placeholder:`Additional property name`,value:s,onChange:e=>c(e.target.value)}),(0,U.jsx)(O,{variant:`outline`,size:`sm`,disabled:!s||[`__proto__`,`constructor`,`prototype`].includes(s),onClick:()=>{r({kind:`object`,fields:{...n.fields,[s]:Xw(Gw(m.additionalProperties),t)}}),c(``)},children:`Add property`})]})]}),n.kind===`array`&&(0,U.jsxs)(U.Fragment,{children:[n.items.map((e,t)=>(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[v(Qw(m,t),e,e=>r({kind:`array`,items:n.items.map((n,r)=>r===t?e:n)}),`${a}[${t}]`),(0,U.jsx)(O,{size:`sm`,variant:`outline`,onClick:()=>r({kind:`array`,items:n.items.filter((e,n)=>n!==t)}),children:`Remove item`})]},t)),(0,U.jsx)(O,{size:`sm`,variant:`outline`,onClick:()=>{let e=n.items.length;r({kind:`array`,items:[...n.items,Xw(Qw(m,e),t)]})},children:`Add item`})]}),n.kind===`literal`&&_===`boolean`&&(0,U.jsx)(dt,{"aria-label":a,checked:g===!0,onCheckedChange:e=>r({kind:`literal`,value:e})}),n.kind===`literal`&&(_===`string`||_===`number`)&&(0,U.jsx)(he,{"aria-label":a,type:_===`number`?`number`:`text`,value:g,onChange:e=>r({kind:`literal`,value:_===`number`?Number(e.target.value):e.target.value})})]}),(0,U.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,U.jsx)(`summary`,{children:`Original schema and constraints`}),(0,U.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap`,children:JSON.stringify(e,null,2)})]})]})}function eT({schema:e,value:t,onChange:n,label:r}){return(0,U.jsx)($w,{schema:e,template:Yw(t),label:r,onChange:e=>{let t=Jw(e);t!==void 0&&n(t)}})}function tT(e){return e===`object`?{type:e,fields:{}}:e===`array`?{type:e,items:{type:`string`}}:e===`enum`?{type:e,values:[`value`]}:e===`union`?{type:e,variants:[{type:`string`}]}:{type:e}}function nT(e){switch(e.type){case`json`:return{};case`null`:return null;case`object`:return Object.fromEntries(Object.entries(e.fields).filter(([,e])=>e.required||e.default!==void 0).map(([e,t])=>[e,t.default??nT(t.schema)]));case`array`:return[];case`number`:return 0;case`boolean`:return!1;case`enum`:return e.values[0]??``;case`union`:return nT(e.variants[0]);default:return``}}function rT({schema:e,value:t,onChange:n,onClear:r,label:i=`Value`}){let[a,o]=(0,H.useState)(0);if(e.type===`json`)return(0,U.jsx)(eT,{schema:e.schema??!0,value:t??null,label:i,onChange:n});if(e.type===`null`)return(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`null`});if(e.type===`object`){let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{};return(0,U.jsx)(`div`,{className:`grid gap-3`,children:Object.entries(e.fields).map(([e,t])=>(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`span`,{className:`text-sm font-medium`,children:[e,t.required?` *`:``]}),!t.required&&(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{"aria-label":`Include ${e}`,checked:Object.hasOwn(r,e),onCheckedChange:i=>{let a={...r};i?a[e]=t.default??nT(t.schema):delete a[e],n(a)}}),`Include`]}),(0,U.jsx)(rT,{schema:t.schema,label:i===`Value`?e:`${i}.${e}`,value:r[e]??t.default,onClear:()=>{let t={...r};delete t[e],n(t)},onChange:t=>n({...r,[e]:t})})]},e))})}return e.type===`array`?(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(Array.isArray(t)?t:[]).map((r,a)=>(0,U.jsxs)(`div`,{className:`grid gap-2 rounded-lg border p-3`,children:[(0,U.jsx)(rT,{schema:e.items,label:`${i} item ${a+1}`,value:r,onChange:e=>n(t.map((t,n)=>n===a?e:t))}),(0,U.jsx)(O,{size:`sm`,variant:`destructive`,className:`justify-self-start`,onClick:()=>n(t.filter((e,t)=>t!==a)),children:`Remove item`})]},a)),(0,U.jsx)(O,{size:`sm`,variant:`outline`,className:`justify-self-start`,onClick:()=>n([...Array.isArray(t)?t:[],nT(e.items)]),children:`Add item`})]}):e.type===`union`?(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(Rt,{value:a,onValueChange:t=>{t!==null&&(o(t),n(nT(e.variants[t])))},children:[(0,U.jsx)(jt,{className:`w-full`,"aria-label":i===`Value`?`Input variant`:`${i} variant`,children:(0,U.jsx)(It,{children:`Variant ${a+1}: ${e.variants[a]?.type??``}`})}),(0,U.jsx)(At,{children:e.variants.map((e,t)=>(0,U.jsxs)(Ct,{value:t,children:[`Variant `,t+1,`: `,e.type]},t))})]}),(0,U.jsx)(rT,{schema:e.variants[a]??e.variants[0],label:i,value:t,onChange:n})]}):e.type===`boolean`?(0,U.jsx)(dt,{"aria-label":i,checked:t===!0,onCheckedChange:n}):e.type===`enum`?(0,U.jsxs)(Rt,{value:typeof t==`string`?t:``,onValueChange:e=>{e!==null&&n(e)},children:[(0,U.jsx)(jt,{className:`w-full`,"aria-label":i,children:(0,U.jsx)(It,{children:typeof t==`string`&&t?t:`Select`})}),(0,U.jsxs)(At,{children:[!e.values.includes(``)&&(0,U.jsx)(Ct,{value:``,children:`Select`}),e.values.map(e=>(0,U.jsx)(Ct,{value:e,children:e||`Empty string`},e))]})]}):(0,U.jsx)(he,{"aria-label":i,type:e.type===`number`?`number`:`text`,value:typeof t==`string`||typeof t==`number`?t:``,onChange:t=>e.type===`number`&&t.target.value===``&&r?r():n(e.type===`number`?t.target.value===``?null:Number(t.target.value):t.target.value)})}function iT({schema:e,onChange:t,root:n=!1}){return(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:`Schema`}),!n&&(0,U.jsxs)(Rt,{value:e.type,onValueChange:e=>{e!==null&&t(tT(e))},children:[(0,U.jsx)(jt,{className:`w-full`,"aria-label":`Schema type`,children:(0,U.jsx)(It,{children:e.type})}),(0,U.jsx)(At,{children:[`object`,`array`,`string`,`number`,`boolean`,`enum`,`json`,`null`].map(e=>(0,U.jsx)(Ct,{value:e,children:e},e))})]}),e.type===`enum`&&(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`Values (one per line)`}),(0,U.jsx)(Ho,{value:e.values.join(`
|
|
142
|
+
`),onChange:n=>t({...e,values:n.target.value.split(`
|
|
143
|
+
`)})})]}),e.type===`array`&&(0,U.jsx)(iT,{schema:e.items,onChange:n=>t({...e,items:n})}),e.type===`object`&&(0,U.jsxs)(U.Fragment,{children:[Object.entries(e.fields).map(([n,r])=>(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:n}),(0,U.jsx)(O,{size:`sm`,variant:`destructive`,className:`justify-self-start`,onClick:()=>t({...e,fields:Object.fromEntries(Object.entries(e.fields).filter(([e])=>e!==n))}),children:`Remove field`}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{checked:!!r.required,onCheckedChange:i=>t({...e,fields:{...e.fields,[n]:{...r,required:i}}})}),`Required`]}),(0,U.jsx)(iT,{schema:r.schema,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,schema:i}}})}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{checked:r.default!==void 0,onCheckedChange:i=>{let a={...r};i?a.default=nT(r.schema):delete a.default,t({...e,fields:{...e.fields,[n]:a}})}}),`Default`]}),r.default!==void 0&&(0,U.jsx)(rT,{schema:r.schema,value:r.default,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,default:i}}})})]},n)),(0,U.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault();let r=n.currentTarget,i=String(new FormData(r).get(`field`));i&&![`__proto__`,`constructor`,`prototype`].includes(i)&&!e.fields[i]&&(t({...e,fields:{...e.fields,[i]:{schema:{type:`string`}}}}),r.reset())},children:[(0,U.jsx)(he,{className:`min-w-0 flex-1`,name:`field`,"aria-label":`New field name`,placeholder:`Field name`,required:!0}),(0,U.jsx)(O,{type:`submit`,size:`sm`,variant:`outline`,children:`Add field`})]})]})]})}function aT(e,t){return{...e,workflowId:t.id,contract:structuredClone(t.contract)}}function oT(e,t){let n=[],r=new Set;for(let i=t||void 0;i!==void 0;){let t=e.invocations?.[i];if(!t||r.has(i))break;r.add(i);let a=t.parentInvocationId?e.invocations?.[t.parentInvocationId]:void 0,o=a?e.retainedDefinitions?.[a.definitionId]:e.definition;n.unshift({id:i,name:e.retainedDefinitions?.[t.definitionId]?.name??t.definitionId,call:o?.steps.find(e=>e.id===t.callStepId)?.name??t.callStepId,attempt:t.callAttempt}),i=t.parentInvocationId}return n}function sT(e,t,n,r){return`stepId=${encodeURIComponent(e)}${n?``:`&attempt=${t}`}${r?`&invocationId=${encodeURIComponent(r)}`:``}`}var cT=e(ve(),1);function lT(e){return{x:e%3*286,y:Math.floor(e/3)*270}}function uT(e){let t;try{t=new Set(fw(e).loops.map(e=>e.headerId))}catch{t=new Set(e.steps.filter(t=>{let n=e.edges.filter(e=>e.from===t.id).map(e=>e.to),r=new Set;for(;n.length;){let i=n.pop();if(i===t.id)return!0;r.has(i)||(r.add(i),n.push(...e.edges.filter(e=>e.from===i).map(e=>e.to)))}return!1}).map(e=>e.id))}return{...e,loopSettings:Object.fromEntries(Object.entries(e.loopSettings??{}).filter(([e])=>t.has(e))),steps:e.steps.map(e=>{if(t.has(e.id)||!e.repeatMapping)return e;let n={...e};return delete n.repeatMapping,n})}}function dT(e,{orientation:t=`horizontal`}={}){let n=fw(e).loops,r=new Map(e.steps.map((e,t)=>[e.id,e.position??lT(t)])),i=new Map;for(let e of[...n].reverse()){let a=n.filter(t=>t.parentHeaderId===e.headerId),o=[...e.memberIds.filter(e=>!a.some(t=>t.memberIds.includes(e))).map(e=>({...r.get(e),width:208,height:192})),...a.map(e=>i.get(e.headerId))],s=Math.min(...o.map(e=>e.x)),c=Math.min(...o.map(e=>e.y)),l=Math.max(...o.map(e=>e.x+e.width)),u=Math.max(...o.map(e=>e.y+e.height)),d=t===`vertical`,f=s-(d?264:24),p=c-(d?24:112);i.set(e.headerId,{x:f,y:p,width:d?l+24-f:Math.max(360,l+24-f),height:u+24-p})}let a=`loop:`;for(;e.steps.some(e=>e.id.startsWith(a));)a+=`:`;let o=e=>`${a}${e}`,s=(e,t)=>{let n=t?i.get(t):{x:0,y:0};return{x:e.x-n.x,y:e.y-n.y}};return[...n.map(e=>({id:o(e.headerId),type:`loop`,...e.parentHeaderId?{parentId:o(e.parentHeaderId)}:{},position:s(i.get(e.headerId),e.parentHeaderId),style:{width:i.get(e.headerId).width,height:i.get(e.headerId).height},selectable:!1,deletable:!1,draggable:!1,connectable:!1,zIndex:1,data:{headerId:e.headerId,orientation:t}})),...e.steps.map(e=>{let t=[...n].reverse().find(t=>t.memberIds.includes(e.id));return{id:e.id,type:`workflow`,...t?{parentId:o(t.headerId)}:{},position:s(r.get(e.id),t?.headerId),zIndex:2,data:{step:e}}})]}function fT(e,t){let n=t.find(t=>t.id===e.parentId),r=n?fT(n,t):{x:0,y:0};return{x:e.position.x+r.x,y:e.position.y+r.y}}function pT(e,t){let n=t+e.grants.filter(t=>t.activation===e.activation).length,r=e.try;return`${e.phase===`inactive`?`Not started`:`Try ${r} of ${n}`} · ${e.phase===`limit`?`Loop limit reached`:e.phase}`}function mT(e){return Object.entries(e.loops??{}).filter(([,e])=>e.phase===`limit`)}function hT(e,t){if(t===void 0)return`In progress`;let n=Math.max(0,Math.floor((t-e)/1e3));return[[Math.floor(n/3600),`h`],[Math.floor(n/60)%60,`m`],[n%60,`s`]].filter(([e])=>e!==0).map(([e,t])=>`${e}${t}`).join(` `)||`0s`}var gT=.1,_T=.05;function vT(e,t){let n=fw(e),r=new Set(n.loops.flatMap(e=>e.backEdgeIds)),i=new Map(e.steps.map(e=>[e.id,[]]));for(let t of e.edges)r.has(t.id)||i.get(t.to).push(t.from);let a=new Map,o=new Map(e.edges.map(e=>[e.id,e]));for(let e of n.loops)for(let t of e.exitEdgeIds){if(r.has(t))continue;let n=o.get(t)?.to;n&&a.set(n,[...a.get(n)??[],e])}let s=new Map,c=!0;for(;c;){c=!1;for(let e of n.order){let t=Math.max(-1,...i.get(e).map(e=>s.get(e)??-1),...(a.get(e)??[]).flatMap(e=>e.memberIds.map(e=>s.get(e)??-1)))+1;(s.get(e)??-1)<t&&(s.set(e,t),c=!0)}}let l=new Map(n.loops.map(e=>[e.headerId,e])),u=e=>{let t=0,r=[...n.loops].reverse().find(t=>t.memberIds.includes(e));for(;r;)t++,r=r.parentHeaderId?l.get(r.parentHeaderId):void 0;return t},d=Math.max(0,...e.steps.map(e=>u(e.id))),f=new Map,p=(t,r)=>{let i=n.loops.filter(e=>e.parentHeaderId===t),a=new Set(i.flatMap(e=>e.memberIds)),o=t?l.get(t):void 0,c=e.steps.filter(e=>(o?o.memberIds.includes(e.id):u(e.id)===0)&&!a.has(e.id)),d=new Map;for(let e of c){let t=s.get(e.id)??0,n=d.get(t)??0;f.set(e.id,r+n),d.set(t,n+1)}let m=r+Math.max(1,...d.values());for(let e of i)m+=p(e.headerId,m);return m-r};p(void 0,0);let m=t?310+d*288:270+d*136,h=t?220+d*2*24:350+d*2*24;return{...e,steps:e.steps.map(e=>{let n=s.get(e.id)??0,r=f.get(e.id)??0;return{...e,position:t?{x:r*m,y:n*h}:{x:n*h,y:r*m}}})}}function yT(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=yT(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var bT={value:()=>{}};function xT(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new ST(n)}function ST(e){this._=e}function CT(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}ST.prototype=xT.prototype={constructor:ST,on:function(e,t){var n=this._,r=CT(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=wT(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=TT(n[i],e.name,t);else if(t==null)for(i in n)n[i]=TT(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ST(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function wT(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function TT(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=bT,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ET={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function DT(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),ET.hasOwnProperty(t)?{space:ET[t],local:e}:e}function OT(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function kT(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function AT(e){var t=DT(e);return(t.local?kT:OT)(t)}function jT(){}function MT(e){return e==null?jT:function(){return this.querySelector(e)}}function NT(e){typeof e!=`function`&&(e=MT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new xD(r,this._parents)}function PT(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function FT(){return[]}function IT(e){return e==null?FT:function(){return this.querySelectorAll(e)}}function LT(e){return function(){return PT(e.apply(this,arguments))}}function RT(e){e=typeof e==`function`?LT(e):IT(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new xD(r,i)}function zT(e){return function(){return this.matches(e)}}function BT(e){return function(t){return t.matches(e)}}var VT=Array.prototype.find;function HT(e){return function(){return VT.call(this.children,e)}}function UT(){return this.firstElementChild}function WT(e){return this.select(e==null?UT:HT(typeof e==`function`?e:BT(e)))}var GT=Array.prototype.filter;function KT(){return Array.from(this.children)}function qT(e){return function(){return GT.call(this.children,e)}}function JT(e){return this.selectAll(e==null?KT:qT(typeof e==`function`?e:BT(e)))}function YT(e){typeof e!=`function`&&(e=zT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new xD(r,this._parents)}function XT(e){return Array(e.length)}function ZT(){return new xD(this._enter||this._groups.map(XT),this._parents)}function QT(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}QT.prototype={constructor:QT,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function $T(e){return function(){return e}}function eE(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new QT(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function tE(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new QT(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function nE(e){return e.__data__}function rE(e,t){if(!arguments.length)return Array.from(this,nE);var n=t?tE:eE,r=this._parents,i=this._groups;typeof e!=`function`&&(e=$T(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=iE(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new xD(o,r),o._enter=s,o._exit=c,o}function iE(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function aE(){return new xD(this._exit||this._groups.map(XT),this._parents)}function oE(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function sE(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new xD(s,this._parents)}function cE(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function lE(e){e||=uE;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new xD(i,this._parents).order()}function uE(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function dE(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function fE(){return Array.from(this)}function pE(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function mE(){let e=0;for(let t of this)++e;return e}function hE(){return!this.node()}function gE(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function _E(e){return function(){this.removeAttribute(e)}}function vE(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yE(e,t){return function(){this.setAttribute(e,t)}}function bE(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function xE(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function SE(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function CE(e,t){var n=DT(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?vE:_E:typeof t==`function`?n.local?SE:xE:n.local?bE:yE)(n,t))}function wE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function TE(e){return function(){this.style.removeProperty(e)}}function EE(e,t,n){return function(){this.style.setProperty(e,t,n)}}function DE(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function OE(e,t,n){return arguments.length>1?this.each((t==null?TE:typeof t==`function`?DE:EE)(e,t,n??``)):kE(this.node(),e)}function kE(e,t){return e.style.getPropertyValue(t)||wE(e).getComputedStyle(e,null).getPropertyValue(t)}function AE(e){return function(){delete this[e]}}function jE(e,t){return function(){this[e]=t}}function ME(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function NE(e,t){return arguments.length>1?this.each((t==null?AE:typeof t==`function`?ME:jE)(e,t)):this.node()[e]}function PE(e){return e.trim().split(/^|\s+/)}function FE(e){return e.classList||new IE(e)}function IE(e){this._node=e,this._names=PE(e.getAttribute(`class`)||``)}IE.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function LE(e,t){for(var n=FE(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function RE(e,t){for(var n=FE(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function zE(e){return function(){LE(this,e)}}function BE(e){return function(){RE(this,e)}}function VE(e,t){return function(){(t.apply(this,arguments)?LE:RE)(this,e)}}function HE(e,t){var n=PE(e+``);if(arguments.length<2){for(var r=FE(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?VE:t?zE:BE)(n,t))}function UE(){this.textContent=``}function WE(e){return function(){this.textContent=e}}function GE(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function KE(e){return arguments.length?this.each(e==null?UE:(typeof e==`function`?GE:WE)(e)):this.node().textContent}function qE(){this.innerHTML=``}function JE(e){return function(){this.innerHTML=e}}function YE(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function XE(e){return arguments.length?this.each(e==null?qE:(typeof e==`function`?YE:JE)(e)):this.node().innerHTML}function ZE(){this.nextSibling&&this.parentNode.appendChild(this)}function QE(){return this.each(ZE)}function $E(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function eD(){return this.each($E)}function tD(e){var t=typeof e==`function`?e:AT(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function nD(){return null}function rD(e,t){var n=typeof e==`function`?e:AT(e),r=t==null?nD:typeof t==`function`?t:MT(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function iD(){var e=this.parentNode;e&&e.removeChild(this)}function aD(){return this.each(iD)}function oD(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function sD(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function cD(e){return this.select(e?sD:oD)}function lD(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function uD(e){return function(t){e.call(this,t,this.__data__)}}function dD(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function fD(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function pD(e,t,n){return function(){var r=this.__on,i,a=uD(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function mD(e,t,n){var r=dD(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?pD:fD,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function hD(e,t,n){var r=wE(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function gD(e,t){return function(){return hD(this,e,t)}}function _D(e,t){return function(){return hD(this,e,t.apply(this,arguments))}}function vD(e,t){return this.each((typeof t==`function`?_D:gD)(e,t))}function*yD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var bD=[null];function xD(e,t){this._groups=e,this._parents=t}function SD(){return new xD([[document.documentElement]],bD)}function CD(){return this}xD.prototype=SD.prototype={constructor:xD,select:NT,selectAll:RT,selectChild:WT,selectChildren:JT,filter:YT,data:rE,enter:ZT,exit:aE,join:oE,merge:sE,selection:CD,order:cE,sort:lE,call:dE,nodes:fE,node:pE,size:mE,empty:hE,each:gE,attr:CE,style:OE,property:NE,classed:HE,text:KE,html:XE,raise:QE,lower:eD,append:tD,insert:rD,remove:aD,clone:cD,datum:lD,on:mD,dispatch:vD,[Symbol.iterator]:yD};function wD(e){return typeof e==`string`?new xD([[document.querySelector(e)]],[document.documentElement]):new xD([[e]],bD)}function TD(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ED(e,t){if(e=TD(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var DD={passive:!1},OD={capture:!0,passive:!1};function kD(e){e.stopImmediatePropagation()}function AD(e){e.preventDefault(),e.stopImmediatePropagation()}function jD(e){var t=e.document.documentElement,n=wD(e).on(`dragstart.drag`,AD,OD);`onselectstart`in t?n.on(`selectstart.drag`,AD,OD):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function MD(e,t){var n=e.document.documentElement,r=wD(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,AD,OD),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var ND=e=>()=>e;function PD(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}PD.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function FD(e){return!e.ctrlKey&&!e.button}function ID(){return this.parentNode}function LD(e,t){return t??{x:e.x,y:e.y}}function RD(){return navigator.maxTouchPoints||`ontouchstart`in this}function zD(){var e=FD,t=ID,n=LD,r=RD,i={},a=xT(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,DD).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(wD(n.view).on(`mousemove.drag`,m,OD).on(`mouseup.drag`,h,OD),jD(n.view),kD(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(AD(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){wD(e.view).on(`mousemove.drag mouseup.drag`,null),MD(e.view,l),AD(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(kD(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(AD(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(kD(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=ED(l||r,t),p,m,h;if((h=n.call(e,new PD(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=ED(l||a,t),_=o}u.call(r,e,new PD(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:ND(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:ND(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:ND(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:ND(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function BD(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function VD(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function HD(){}var UD=.7,WD=1/UD,GD=`\\s*([+-]?\\d+)\\s*`,KD=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,qD=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,JD=/^#([0-9a-f]{3,8})$/,YD=RegExp(`^rgb\\(${GD},${GD},${GD}\\)$`),XD=RegExp(`^rgb\\(${qD},${qD},${qD}\\)$`),ZD=RegExp(`^rgba\\(${GD},${GD},${GD},${KD}\\)$`),QD=RegExp(`^rgba\\(${qD},${qD},${qD},${KD}\\)$`),$D=RegExp(`^hsl\\(${KD},${qD},${qD}\\)$`),eO=RegExp(`^hsla\\(${KD},${qD},${qD},${KD}\\)$`),tO={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};BD(HD,oO,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:nO,formatHex:nO,formatHex8:rO,formatHsl:iO,formatRgb:aO,toString:aO});function nO(){return this.rgb().formatHex()}function rO(){return this.rgb().formatHex8()}function iO(){return yO(this).formatHsl()}function aO(){return this.rgb().formatRgb()}function oO(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=JD.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?sO(t):n===3?new dO(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?cO(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?cO(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=YD.exec(e))?new dO(t[1],t[2],t[3],1):(t=XD.exec(e))?new dO(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ZD.exec(e))?cO(t[1],t[2],t[3],t[4]):(t=QD.exec(e))?cO(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=$D.exec(e))?vO(t[1],t[2]/100,t[3]/100,1):(t=eO.exec(e))?vO(t[1],t[2]/100,t[3]/100,t[4]):tO.hasOwnProperty(e)?sO(tO[e]):e===`transparent`?new dO(NaN,NaN,NaN,0):null}function sO(e){return new dO(e>>16&255,e>>8&255,e&255,1)}function cO(e,t,n,r){return r<=0&&(e=t=n=NaN),new dO(e,t,n,r)}function lO(e){return e instanceof HD||(e=oO(e)),e?(e=e.rgb(),new dO(e.r,e.g,e.b,e.opacity)):new dO}function uO(e,t,n,r){return arguments.length===1?lO(e):new dO(e,t,n,r??1)}function dO(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}BD(dO,uO,VD(HD,{brighter(e){return e=e==null?WD:WD**+e,new dO(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?UD:UD**+e,new dO(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new dO(gO(this.r),gO(this.g),gO(this.b),hO(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:fO,formatHex:fO,formatHex8:pO,formatRgb:mO,toString:mO}));function fO(){return`#${_O(this.r)}${_O(this.g)}${_O(this.b)}`}function pO(){return`#${_O(this.r)}${_O(this.g)}${_O(this.b)}${_O((isNaN(this.opacity)?1:this.opacity)*255)}`}function mO(){let e=hO(this.opacity);return`${e===1?`rgb(`:`rgba(`}${gO(this.r)}, ${gO(this.g)}, ${gO(this.b)}${e===1?`)`:`, ${e})`}`}function hO(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function gO(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function _O(e){return e=gO(e),(e<16?`0`:``)+e.toString(16)}function vO(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new xO(e,t,n,r)}function yO(e){if(e instanceof xO)return new xO(e.h,e.s,e.l,e.opacity);if(e instanceof HD||(e=oO(e)),!e)return new xO;if(e instanceof xO)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new xO(o,s,c,e.opacity)}function bO(e,t,n,r){return arguments.length===1?yO(e):new xO(e,t,n,r??1)}function xO(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}BD(xO,bO,VD(HD,{brighter(e){return e=e==null?WD:WD**+e,new xO(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?UD:UD**+e,new xO(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new dO(wO(e>=240?e-240:e+120,i,r),wO(e,i,r),wO(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new xO(SO(this.h),CO(this.s),CO(this.l),hO(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=hO(this.opacity);return`${e===1?`hsl(`:`hsla(`}${SO(this.h)}, ${CO(this.s)*100}%, ${CO(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function SO(e){return e=(e||0)%360,e<0?e+360:e}function CO(e){return Math.max(0,Math.min(1,e||0))}function wO(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var TO=e=>()=>e;function EO(e,t){return function(n){return e+n*t}}function DO(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function OO(e){return(e=+e)==1?kO:function(t,n){return n-t?DO(t,n,e):TO(isNaN(t)?n:t)}}function kO(e,t){var n=t-e;return n?EO(e,n):TO(isNaN(e)?t:e)}var AO=(function e(t){var n=OO(t);function r(e,t){var r=n((e=uO(e)).r,(t=uO(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=kO(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function jO(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function MO(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function NO(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=HO(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function PO(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function FO(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function IO(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=HO(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var LO=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,RO=new RegExp(LO.source,`g`);function zO(e){return function(){return e}}function BO(e){return function(t){return e(t)+``}}function VO(e,t){var n=LO.lastIndex=RO.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=LO.exec(e))&&(i=RO.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:FO(r,i)})),n=RO.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?BO(c[0].x):zO(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function HO(e,t){var n=typeof t,r;return t==null||n===`boolean`?TO(t):(n===`number`?FO:n===`string`?(r=oO(t))?(t=r,AO):VO:t instanceof oO?AO:t instanceof Date?PO:MO(t)?jO:Array.isArray(t)?NO:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?IO:FO)(e,t)}var UO=180/Math.PI,WO={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function GO(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*UO,skewX:Math.atan(c)*UO,scaleX:o,scaleY:s}}var KO;function qO(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?WO:GO(t.a,t.b,t.c,t.d,t.e,t.f)}function JO(e){return e==null||(KO||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),KO.setAttribute(`transform`,e),!(e=KO.transform.baseVal.consolidate()))?WO:(e=e.matrix,GO(e.a,e.b,e.c,e.d,e.e,e.f))}function YO(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:FO(e,i)},{i:c-2,x:FO(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:FO(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:FO(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:FO(e,n)},{i:s-2,x:FO(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var XO=YO(qO,`px, `,`px)`,`deg)`),ZO=YO(JO,`, `,`)`,`)`),QO=1e-12;function $O(e){return((e=Math.exp(e))+1/e)/2}function ek(e){return((e=Math.exp(e))-1/e)/2}function tk(e){return((e=Math.exp(2*e))-1)/(e+1)}var nk=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<QO)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=$O(y),c=s/(n*g)*(i*tk(t*r+y)-ek(y));return[a+c*d,o+c*f,s*i/$O(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),rk=0,ik=0,ak=0,ok=1e3,sk,ck,lk=0,uk=0,dk=0,fk=typeof performance==`object`&&performance.now?performance:Date,pk=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mk(){return uk||=(pk(hk),fk.now()+dk)}function hk(){uk=0}function gk(){this._call=this._time=this._next=null}gk.prototype=_k.prototype={constructor:gk,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?mk():+n)+(t==null?0:+t),!this._next&&ck!==this&&(ck?ck._next=this:sk=this,ck=this),this._call=e,this._time=n,Sk()},stop:function(){this._call&&(this._call=null,this._time=1/0,Sk())}};function _k(e,t,n){var r=new gk;return r.restart(e,t,n),r}function vk(){mk(),++rk;for(var e=sk,t;e;)(t=uk-e._time)>=0&&e._call.call(void 0,t),e=e._next;--rk}function yk(){uk=(lk=fk.now())+dk,rk=ik=0;try{vk()}finally{rk=0,xk(),uk=0}}function bk(){var e=fk.now(),t=e-lk;t>ok&&(dk-=t,lk=e)}function xk(){for(var e,t=sk,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:sk=n);ck=e,Sk(r)}function Sk(e){rk||(ik&&=clearTimeout(ik),e-uk>24?(e<1/0&&(ik=setTimeout(yk,e-fk.now()-dk)),ak&&=clearInterval(ak)):(ak||=(lk=fk.now(),setInterval(bk,ok)),rk=1,pk(yk)))}function Ck(e,t,n){var r=new gk;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var wk=xT(`start`,`end`,`cancel`,`interrupt`),Tk=[];function Ek(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Ak(e,n,{name:t,index:r,group:i,on:wk,tween:Tk,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Dk(e,t){var n=kk(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Ok(e,t){var n=kk(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function kk(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Ak(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=_k(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Ck(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(Ck(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function jk(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Mk(e){return this.each(function(){jk(this,e)})}function Nk(e,t){var n,r;return function(){var i=Ok(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function Pk(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=Ok(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function Fk(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=kk(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Nk:Pk)(n,e,t))}function Ik(e,t,n){var r=e._id;return e.each(function(){var e=Ok(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return kk(e,r).value[t]}}function Lk(e,t){var n;return(typeof t==`number`?FO:t instanceof oO?AO:(n=oO(t))?(t=n,AO):VO)(e,t)}function Rk(e){return function(){this.removeAttribute(e)}}function zk(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Bk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function Vk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function Hk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Uk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Wk(e,t){var n=DT(e),r=n===`transform`?ZO:Lk;return this.attrTween(e,typeof t==`function`?(n.local?Uk:Hk)(n,r,Ik(this,`attr.`+e,t)):t==null?(n.local?zk:Rk)(n):(n.local?Vk:Bk)(n,r,t))}function Gk(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Kk(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function qk(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Kk(e,i)),n}return i._value=t,i}function Jk(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Gk(e,i)),n}return i._value=t,i}function Yk(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=DT(e);return this.tween(n,(r.local?qk:Jk)(r,t))}function Xk(e,t){return function(){Dk(this,e).delay=+t.apply(this,arguments)}}function Zk(e,t){return t=+t,function(){Dk(this,e).delay=t}}function Qk(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Xk:Zk)(t,e)):kk(this.node(),t).delay}function $k(e,t){return function(){Ok(this,e).duration=+t.apply(this,arguments)}}function eA(e,t){return t=+t,function(){Ok(this,e).duration=t}}function tA(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?$k:eA)(t,e)):kk(this.node(),t).duration}function nA(e,t){if(typeof t!=`function`)throw Error();return function(){Ok(this,e).ease=t}}function rA(e){var t=this._id;return arguments.length?this.each(nA(t,e)):kk(this.node(),t).ease}function iA(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();Ok(this,e).ease=n}}function aA(e){if(typeof e!=`function`)throw Error();return this.each(iA(this._id,e))}function oA(e){typeof e!=`function`&&(e=zT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new FA(r,this._parents,this._name,this._id)}function sA(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new FA(o,this._parents,this._name,this._id)}function cA(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function lA(e,t,n){var r,i,a=cA(t)?Dk:Ok;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function uA(e,t){var n=this._id;return arguments.length<2?kk(this.node(),n).on.on(e):this.each(lA(n,e,t))}function dA(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function fA(){return this.on(`end.remove`,dA(this._id))}function pA(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=MT(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,Ek(l[f],t,n,f,l,kk(u,n)));return new FA(a,this._parents,t,n)}function mA(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=IT(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=kk(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&Ek(p,t,n,h,f,m);a.push(f),o.push(u)}return new FA(a,o,t,n)}var hA=SD.prototype.constructor;function gA(){return new hA(this._groups,this._parents)}function _A(e,t){var n,r,i;return function(){var a=kE(this,e),o=(this.style.removeProperty(e),kE(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function vA(e){return function(){this.style.removeProperty(e)}}function yA(e,t,n){var r,i=n+``,a;return function(){var o=kE(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function bA(e,t,n){var r,i,a;return function(){var o=kE(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),kE(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function xA(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=Ok(this,e),l=c.on,u=c.value[a]==null?s||=vA(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function SA(e,t,n){var r=(e+=``)==`transform`?XO:Lk;return t==null?this.styleTween(e,_A(e,r)).on(`end.style.`+e,vA(e)):typeof t==`function`?this.styleTween(e,bA(e,r,Ik(this,`style.`+e,t))).each(xA(this._id,e)):this.styleTween(e,yA(e,r,t),n).on(`end.style.`+e,null)}function CA(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function wA(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&CA(e,a,n)),r}return a._value=t,a}function TA(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,wA(e,t,n??``))}function EA(e){return function(){this.textContent=e}}function DA(e){return function(){var t=e(this);this.textContent=t??``}}function OA(e){return this.tween(`text`,typeof e==`function`?DA(Ik(this,`text`,e)):EA(e==null?``:e+``))}function kA(e){return function(t){this.textContent=e.call(this,t)}}function AA(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&kA(r)),t}return r._value=e,r}function jA(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,AA(e))}function MA(){for(var e=this._name,t=this._id,n=IA(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=kk(c,t);Ek(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new FA(r,this._parents,e,n)}function NA(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=Ok(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var PA=0;function FA(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function IA(){return++PA}var LA=SD.prototype;FA.prototype={constructor:FA,select:pA,selectAll:mA,selectChild:LA.selectChild,selectChildren:LA.selectChildren,filter:oA,merge:sA,selection:gA,transition:MA,call:LA.call,nodes:LA.nodes,node:LA.node,size:LA.size,empty:LA.empty,each:LA.each,on:uA,attr:Wk,attrTween:Yk,style:SA,styleTween:TA,text:OA,textTween:jA,remove:fA,tween:Fk,delay:Qk,duration:tA,ease:rA,easeVarying:aA,end:NA,[Symbol.iterator]:LA[Symbol.iterator]};function RA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zA={time:null,delay:0,duration:250,ease:RA};function BA(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function VA(e){var t,n;e instanceof FA?(t=e._id,e=e._name):(t=IA(),(n=zA).time=mk(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Ek(c,e,t,l,o,n||BA(c,t));return new FA(r,this._parents,e,t)}SD.prototype.interrupt=Mk,SD.prototype.transition=VA;var HA=e=>()=>e;function UA(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function WA(e,t,n){this.k=e,this.x=t,this.y=n}WA.prototype={constructor:WA,scale:function(e){return e===1?this:new WA(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new WA(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var GA=new WA(1,0,0);KA.prototype=WA.prototype;function KA(e){for(;!e.__zoom;)if(!(e=e.parentNode))return GA;return e.__zoom}function qA(e){e.stopImmediatePropagation()}function JA(e){e.preventDefault(),e.stopImmediatePropagation()}function YA(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function XA(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function ZA(){return this.__zoom||GA}function QA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $A(){return navigator.maxTouchPoints||`ontouchstart`in this}function ej(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function tj(){var e=YA,t=XA,n=ej,r=QA,i=$A,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=nk,l=xT(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,ZA).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,ZA),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(GA.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new WA(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new WA(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new WA(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=wD(this.that).datum();l.call(e,this.that,new UA(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=ED(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],jk(this),s.start();JA(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=wD(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=ED(t,i),l=t.clientX,u=t.clientY;jD(t.view),qA(t),a.mouse=[c,this.__zoom.invert(c)],jk(this),a.start();function d(e){if(JA(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=ED(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),MD(e.view,a.moved),JA(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=ED(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);JA(r),s>0?wD(this).transition().duration(s).call(x,d,c,r):wD(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(qA(t),s=0;s<i;++s)c=r[s],l=ED(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),jk(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(JA(e),s=0;s<a;++s)c=i[s],l=ED(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(qA(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=ED(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=wD(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:HA(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:HA(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:HA(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:HA([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var nj={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rj=[[-1/0,-1/0],[1/0,1/0]],ij=[`Enter`,` `,`Escape`],aj={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},oj;(function(e){e.Strict=`strict`,e.Loose=`loose`})(oj||={});var sj;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(sj||={});var cj;(function(e){e.Partial=`partial`,e.Full=`full`})(cj||={});var lj={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},uj;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(uj||={});var dj;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(dj||={});var Q;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Q||={});var fj={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top},pj=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,mj=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),hj=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),gj=(e,t=[0,0])=>{let{width:n,height:r}=Xj(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},_j=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):hj(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,Aj(e,Pj(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Mj(r):{x:0,y:0,width:0,height:0}},vj=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Aj(n,Pj(e)),r=!0)}),r?Mj(n):{x:0,y:0,width:0,height:0}},yj=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=Ij(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},bj=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function xj(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=Xj(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function Sj({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=qj(vj(xj(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function Cj({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,nj.error005());else{let{width:e,height:t}=Xj(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&Yj(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Yj(d)?Ej(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,nj.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function wj({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=bj(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var Tj=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ej=(e={x:0,y:0},t,n)=>({x:Tj(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Tj(e.y,t[0][1],t[1][1]-(n?.height??0))});function Dj(e,t,n){let{width:r,height:i}=Xj(n),{x:a,y:o}=n.internals.positionAbsolute;return Ej(e,[[a,o],[a+r,o+i]],t)}var Oj=(e,t,n)=>e<t?Tj(Math.abs(e-t),1,t)/t:e>n?-Tj(Math.abs(e-n),1,t)/t:0,kj=(e,t,n=15,r=40)=>[Oj(e.x,r,t.width-r)*n,Oj(e.y,r,t.height-r)*n],Aj=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),jj=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Mj=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Nj=(e,t=[0,0])=>{let{x:n,y:r}=hj(e)?e.internals.positionAbsolute:gj(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Pj=(e,t=[0,0])=>{let{x:n,y:r}=hj(e)?e.internals.positionAbsolute:gj(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Fj=(e,t)=>Mj(Aj(jj(e),jj(t))),Ij=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},Lj=(e,t)=>Ij(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Rj=e=>zj(e.width)&&zj(e.height)&&zj(e.x)&&zj(e.y),zj=e=>!isNaN(e)&&isFinite(e),Bj=(e,t)=>(e,t)=>{},Vj=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Hj=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Vj(s,o):s},Uj=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Wj(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Gj(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Wj(e,n),i=Wj(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Wj(e.top??e.y??0,n),i=Wj(e.bottom??e.y??0,n),a=Wj(e.left??e.x??0,t),o=Wj(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Kj(e,t,n,r,i,a){let{x:o,y:s}=Uj(e,[t,n,r]),{x:c,y:l}=Uj({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var qj=(e,t,n,r,i,a)=>{let o=Gj(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=Tj(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=Kj(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},Jj=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Yj(e){return e!=null&&e!==`parent`}function Xj(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Zj(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Qj(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function $j(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function eM(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function tM(e){return{...aj,...e||{}}}function nM(e){return e===null?null:e?`valid`:`invalid`}function rM(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=lM(e),s=Hj({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Vj(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var iM=e=>({width:e.offsetWidth,height:e.offsetHeight}),aM=e=>e?.getRootNode?.()||window?.document,oM=[`INPUT`,`SELECT`,`TEXTAREA`];function sM(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?oM.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var cM=e=>`clientX`in e,lM=(e,t)=>{let n=cM(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},uM=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...iM(t)}})};function dM({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function fM(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function pM({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Q.Left:return[t-fM(t-r,a),n];case Q.Right:return[t+fM(r-t,a),n];case Q.Top:return[t,n-fM(n-i,a)];case Q.Bottom:return[t,n+fM(i-n,a)]}}function mM({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top,curvature:o=.25}){let[s,c]=pM({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=pM({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=dM({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function hM({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function gM({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function _M({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Aj(Pj(e),Pj(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),Lj({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Mj(a))>0}var vM=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,yM=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),bM=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,nj.error006()),t;let r=n.getEdgeId||vM,i;return i=pj(e)?{...e}:{...e,id:r(e)},yM(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function xM({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=hM({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var SM={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},CM=({source:e,sourcePosition:t=Q.Bottom,target:n})=>t===Q.Left||t===Q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},wM=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function TM({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:i,offset:a,stepPosition:o}){let s=SM[t],c=SM[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=CM({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=hM({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function EM(e,t,n,r){let i=Math.min(wM(e,t)/2,wM(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function DM({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=TM({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=EM(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function OM(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function kM(e){let{sourceNode:t,targetNode:n}=e;if(!OM(t)||!OM(n))return null;let r=t.internals.handleBounds||AM(t.handles),i=n.internals.handleBounds||AM(n.handles),a=MM(r?.source??[],e.sourceHandle),o=MM(e.connectionMode===oj.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,nj.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||Q.Bottom,c=o?.position||Q.Top,l=jM(t,a,s),u=jM(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function AM(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function jM(e,t,n=Q.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??Xj(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case Q.Top:return{x:i+o/2,y:a};case Q.Right:return{x:i+o,y:a+s/2};case Q.Bottom:return{x:i+o/2,y:a+s};case Q.Left:return{x:i,y:a+s/2}}}function MM(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function NM(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function PM(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=NM(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var FM=1e3,IM=10,LM={nodeOrigin:[0,0],nodeExtent:rj,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},RM={...LM,checkEquality:!0};function zM(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function BM(e,t,n){let r=zM(LM,n);for(let n of e.values())if(n.parentId)GM(n,e,t,r);else{let e=Ej(gj(n,r.nodeOrigin),Yj(n.extent)?n.extent:r.nodeExtent,Xj(n));n.internals.positionAbsolute=e}}function VM(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function HM(e){return e===`manual`}function UM(e,t,n,r={}){let i=zM(RM,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!HM(i.zIndexMode)?FM:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=Ej(gj(u,i.nodeOrigin),Yj(u.extent)?u.extent:i.nodeExtent,Xj(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:VM(u,e),z:KM(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&GM(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function WM(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function GM(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=zM(LM,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}WM(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*IM),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=qM(e,u,o,s,a&&!HM(c)?FM:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function KM(e,t,n){let r=zj(e.zIndex)?e.zIndex:0;return HM(n)?r:r+(e.selected?t:0)}function qM(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Xj(e),l=gj(e,n),u=Yj(e.extent)?Ej(l,e.extent,c):l,d=Ej({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Dj(d,c,t));let f=KM(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function JM(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Fj(a.get(n.parentId)?.expandedRect??Nj(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=Xj(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function YM(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=iM(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=Yj(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=Dj(h,s,n))}else m&&(h=Ej(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:uM(`source`,r.nodeElement,p,d,e.id),target:uM(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&GM(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:Nj(g,i)}))}}if(f.length>0){let e=JM(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function XM({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function ZM(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function QM(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;ZM(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),ZM(`target`,s,c,e,i,o),t.set(r.id,r)}}function $M(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:$M(n,t):!1}function eN(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function tN(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!$M(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function nN({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function rN({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=Vj(a,t);return{x:o.x-a.x,y:o.y-a.y}}function iN({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=wD(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?jj(vj(s)):null,x=v&&l?rN({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:Vj(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=Cj({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=nN({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=kj(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=rM(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=tN(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=nN({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=zD().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=rM(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=lM(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=rM(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=lM(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=lM(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=nN({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!eN(t,`.${g}`,v))&&(!_||eN(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function aN(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Lj(i,Nj(e))>0&&r.push(e);return r}var oN=250;function sN(e,t,n,r){let i=[],a=1/0,o=aN(e,n,t+oN);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=jM(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function cN(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...jM(o,c,c.position,!0)}:c}function lN(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function uN(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var dN=()=>!0;function fN(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=dN,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=aM(e.target),E=0,D,{x:O,y:k}=lM(e),A=lN(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=cN(i,A,r,c,t);if(!N)return;let P=lM(e,j),F=!1,I=null,L=!1,R=null;function ee(){if(!u||!j)return;let[e,t]=kj(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ee)}let z={...N,nodeId:i,type:A,position:N.position},B=c.get(i),te={inProgress:!0,isValid:null,from:jM(B,z,Q.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:B,to:P,toHandle:null,toPosition:fj[z.position],toNode:null,pointer:P};function V(){M=!0,y(te),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&V();function ne(e){if(!M){let{x:t,y:n}=lM(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;V()}if(!x()||!z){re(e);return}let a=b();P=lM(e,j),D=sN(Hj(P,a,!1,[1,1]),n,c,z),F||=(ee(),!0);let s=pN(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=uN(!!D,s.isValid);let u=c.get(i),f=u?jM(u,z,Q.Left,!0):te.from,p={...te,from:f,isValid:L,to:s.toHandle&&L?Uj({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:fj[z.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),te=p}function re(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=te,r={...n,toPosition:te.toHandle?te.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,ne),T.removeEventListener(`mouseup`,re),T.removeEventListener(`touchmove`,ne),T.removeEventListener(`touchend`,re)}}T.addEventListener(`mousemove`,ne),T.addEventListener(`mouseup`,re),T.addEventListener(`touchmove`,ne),T.addEventListener(`touchend`,re)}function pN(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=dN,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=lM(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=lN(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===oj.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=cN(t,e,a,u,n,!0)}return _}var mN={onPointerDown:fN,isValid:pN};function hN({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=wD(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&Jj()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=tj().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:ED}}var gN=e=>({x:e.x,y:e.y,zoom:e.k}),_N=({x:e,y:t,zoom:n})=>GA.translate(e,t).scale(n),vN=(e,t)=>e.target.closest(`.${t}`),yN=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),bN=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,xN=(e,t=0,n=bN,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},SN=e=>{let t=e.ctrlKey&&Jj()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function CN({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(vN(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=ED(u),t=d*2**SN(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===sj.Vertical?0:u.deltaX*f,m=i===sj.Horizontal?0:u.deltaY*f;!Jj()&&u.shiftKey&&i!==sj.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=gN(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function wN({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=vN(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function TN({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=gN(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function EN({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&yN(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,gN(a.transform))}}function DN({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&yN(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=gN(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function ON({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(vN(f,`${u}-flow__node`)||vN(f,`${u}-flow__edge`)||vN(f,`${u}-flow__selection`)||vN(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||vN(f,c)&&h||vN(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function kN({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=tj().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=wD(e).call(f);y({x:i.x,y:i.y,zoom:Tj(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(SN);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?HO:nk).transform(xN(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,panActivationKeyPressed:S=!1,zoomActivationKeyPressed:C,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&v();let k=i&&!C&&!r;f.clickDistance(O?1/0:!zj(D)||D<0?0:D);let A=k?CN({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):wN({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,A,{passive:!1});let j=TN({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,j);let M=EN({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});f.on(`zoom`,M);let N=DN({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,N);let P=ON({panActivationKeyPressed:S,zoomActivationKeyPressed:C,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});f.filter(P),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=_N(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=_N(e);return await g(n,t),n}function x(e){if(p){let t=_N(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?KA(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?HO:nk).scaleTo(xN(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?HO:nk).scaleBy(xN(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!zj(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var AN;(function(e){e.Line=`line`,e.Handle=`handle`})(AN||={});function jN({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function MN(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function NN(e,t){return Math.max(0,t-e)}function PN(e,t){return Math.max(0,e-t)}function FN(e,t,n){return Math.max(0,t-e,e-n)}function IN(e,t){return e?!t:t}function LN(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=FN(E,h,g),j=FN(D,_,v);if(o){let e=0,t=0;c&&w<0?e=NN(y+w+O,o[0][0]):!c&&w>0&&(e=PN(y+E+O,o[1][0])),l&&T<0?t=NN(b+T+k,o[0][1]):!l&&T>0&&(t=PN(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=PN(y+w,s[0][0]):!c&&w<0&&(e=NN(y+E,s[1][0])),l&&T>0?t=PN(b+T,s[0][1]):!l&&T<0&&(t=NN(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=FN(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?PN(b+k+E/C,o[1][1])*C:NN(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?NN(b+E/C,s[1][1])*C:PN(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=FN(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?PN(y+D*C+O,o[1][0])/C:NN(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?NN(y+D*C,s[1][0])/C:PN(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(IN(c,l)?-w:w)/C:w=(IN(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var RN={width:0,height:0,x:0,y:0},zN={...RN,pointerX:0,pointerY:0,aspectRatio:1};function BN(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function VN({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=wD(e),o={controlDirection:MN(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...RN},h={...zN};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:MN(e)};let g,_=null,v=[],y,b,x,S=!1,C=zD().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=rM(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=Yj(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=BN(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=rM(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=LN(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=jN({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var HN=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},UN=e=>e?HN(e):HN,{useDebugValue:WN}=H.default,{useSyncExternalStoreWithSelector:GN}=cT.default,KN=e=>e;function qN(e,t=KN,n){let r=GN(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return WN(r),r}var JN=(e,t)=>{let n=UN(e),r=(e,r=t)=>qN(n,e,r);return Object.assign(r,n),r},YN=(e,t)=>e?JN(e,t):JN;function XN(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var ZN=(0,H.createContext)(null),QN=ZN.Provider,$N=nj.error001(`react`);function $(e,t){let n=(0,H.useContext)(ZN);if(n===null)throw Error($N);return qN(n,e,t)}function eP(){let e=(0,H.useContext)(ZN);if(e===null)throw Error($N);return(0,H.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var tP={display:`none`},nP={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},rP=`react-flow__node-desc`,iP=`react-flow__edge-desc`,aP=`react-flow__aria-live`,oP=e=>e.ariaLiveMessage,sP=e=>e.ariaLabelConfig;function cP({rfId:e}){let t=$(oP);return(0,U.jsx)(`div`,{id:`${aP}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:nP,children:t})}function lP({rfId:e,disableKeyboardA11y:t}){let n=$(sP);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{id:`${rP}-${e}`,style:tP,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,U.jsx)(`div`,{id:`${iP}-${e}`,style:tP,children:n[`edge.a11yDescription.default`]}),!t&&(0,U.jsx)(cP,{rfId:e})]})}var uP=(0,H.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,U.jsx)(`div`,{className:yT([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});uP.displayName=`Panel`;var dP=`https://reactflow.dev?utm_source=attribution`;function fP({proOptions:e,position:t=`bottom-right`}){return(0,H.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,U.jsx)(uP,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${dP}`,children:(0,U.jsx)(`a`,{href:dP,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var pP=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},mP=e=>e.id;function hP(e,t){return XN(e.selectedNodes.map(mP),t.selectedNodes.map(mP))&&XN(e.selectedEdges.map(mP),t.selectedEdges.map(mP))}function gP({onSelectionChange:e}){let t=eP(),{selectedNodes:n,selectedEdges:r}=$(pP,hP);return(0,H.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var _P=e=>!!e.onSelectionChangeHandlers;function vP({onSelectionChange:e}){let t=$(_P);return e||t?(0,U.jsx)(gP,{onSelectionChange:e}):null}var yP=[0,0],bP={x:0,y:0,zoom:1},xP=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],SP=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),CP={translateExtent:rj,nodeOrigin:yP,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function wP(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=$(SP,XN),l=eP();(0,H.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=CP,s()}),[]);let u=(0,H.useRef)(CP);return(0,H.useEffect)(()=>{for(let s of xP){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:tM(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},xP.map(t=>e[t])),null}function TP(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function EP(e){let[t,n]=(0,H.useState)(e===`system`?null:e);return(0,H.useEffect)(()=>{if(e!==`system`){n(e);return}let t=TP(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?TP()?.matches?`dark`:`light`:t}var DP=typeof document<`u`?document:null;function OP(e=null,t={target:DP,actInsideInputWithModifier:!0}){let[n,r]=(0,H.useState)(!1),i=(0,H.useRef)(!1),a=(0,H.useRef)(new Set([])),[o,s]=(0,H.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
|
|
144
|
+
`).replace(`
|
|
145
|
+
|
|
146
|
+
`,`
|
|
147
|
+
+`).split(`
|
|
148
|
+
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,H.useEffect)(()=>{let n=t?.target??DP,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&sM(e))return!1;let n=AP(e.code,s);if(a.current.add(e[n]),kP(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=AP(e.code,s);kP(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function kP(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function AP(e,t){return t.includes(e)?`code`:`key`}var jP=()=>{let e=eP();return(0,H.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=qj(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return Hj(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Uj(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function MP(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)NP(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function NP(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function PP(e,t){return MP(e,t)}function FP(e,t){return MP(e,t)}function IP(e,t){return{id:e,type:`select`,selected:t}}function LP(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(IP(a.id,e)))}return r}function RP({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function zP(e){return{id:e.id,type:`remove`}}var BP=Bj(`React Flow`,`https://reactflow.dev/`);function VP(e,t,n={}){return bM(e,t,{...n,onError:n.onError??BP})}var HP=e=>mj(e),UP=e=>pj(e);function WP(e){return(0,H.forwardRef)(e)}var GP=typeof window<`u`?H.useLayoutEffect:H.useEffect;function KP(e){let[t,n]=(0,H.useState)(BigInt(0)),[r]=(0,H.useState)(()=>qP(()=>n(e=>e+BigInt(1))));return GP(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function qP(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var JP=(0,H.createContext)(null);function YP({children:e}){let t=eP(),n=KP((0,H.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=RP({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=KP((0,H.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(RP({items:s,lookup:o}))},[])),i=(0,H.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,U.jsx)(JP.Provider,{value:i,children:e})}function XP(){let e=(0,H.useContext)(JP);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var ZP=e=>!!e.panZoom;function QP(){let e=jP(),t=eP(),n=XP(),r=$(ZP),i=(0,H.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=HP(e)?e:n.get(e.id),a=i.parentId?Qj(i.position,i.measured,i.parentId,n,r):i.position;return Nj({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&HP(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&UP(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await wj({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(zP);o?.(f),c(e)}if(m){let e=d.map(zP);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Rj(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=Nj(s?r:a),l=Lj(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=Rj(e)?e:a(e);if(!r)return!1;let i=Lj(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return _j(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??eM();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,H.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var $P=e=>e.selected,eF=typeof window<`u`?window:void 0;function tF({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=eP(),{deleteElements:r}=QP(),i=OP(e,{actInsideInputWithModifier:!1}),a=OP(t,{target:eF});(0,H.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter($P),edges:e.filter($P)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,H.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function nF(e){let t=eP();(0,H.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=iM(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,nj.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var rF={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},iF=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function aF({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=sj.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:h,noWheelClassName:g,noPanClassName:_,onViewportChange:v,isControlledViewport:y,paneClickDistance:b,selectionOnDrag:x}){let S=eP(),C=(0,H.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=$(iF,XN),D=OP(p),O=(0,H.useRef)();nF(C);let k=(0,H.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[v,y]);return(0,H.useEffect)(()=>{if(C.current){O.current=kN({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:e=>S.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=S.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=S.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=S.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[e,t,n],domNode:C.current.closest(`.react-flow`)}),()=>{O.current?.destroy()}}},[]),(0,H.useEffect)(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:D,preventScrolling:m,noPanClassName:_,userSelectionActive:w,noWheelClassName:g,lib:T,onTransformChange:k,connectionInProgress:E,selectionOnDrag:x,paneClickDistance:b})},[e,t,n,r,i,a,o,s,c,D,m,_,w,g,T,k,E,x,b]),(0,U.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:rF,children:h})}var oF=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function sF(){let{userSelectionActive:e,userSelectionRect:t}=$(oF,XN);return e&&t?(0,U.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var cF=(e,t)=>n=>{n.target===t.current&&e?.(n)},lF=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function uF({isSelecting:e,selectionKeyPressed:t,selectionMode:n=cj.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,H.useRef)(0),_=eP(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=$(lF,XN),C=y&&(e||v),w=(0,H.useRef)(null),T=(0,H.useRef)(),E=(0,H.useRef)(new Set),D=(0,H.useRef)(new Set),O=(0,H.useRef)(!1),k=(0,H.useRef)(!1),A=(0,H.useRef)({x:0,y:0}),j=(0,H.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{if(n.pointerType===`touch`&&r!==!1&&!t)return;let{domNode:i,transform:a}=_.getState();if(T.current=i?.getBoundingClientRect(),!T.current)return;let s=n.target===w.current;if(!s&&n.target.closest(`.nokey`)||!e||!(o&&s||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:c,y:l}=lM(n.nativeEvent,T.current),u=Hj({x:c,y:l},a);_.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:c,y:l}}),s||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=Uj(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(yj(a,m,i,n===cj.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}$j(h,E.current)||c(LP(a,E.current,!0)),$j(g,D.current)||l(LP(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!i||!T.current)return;let[e,t]=kj(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(R);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(R)})}let ee=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,H.useEffect)(()=>()=>ee(),[]);let z=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=lM(e.nativeEvent,T.current);A.current={x:o,y:c};let l=Uj({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(R(),!0),L(o,c)},B=e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),ee())},te=e=>{e.target?.releasePointerCapture?.(e.pointerId),ee()},V=r===!0||Array.isArray(r)&&r.includes(0);return(0,U.jsxs)(`div`,{className:yT([`react-flow__pane`,{draggable:V,dragging:b,selection:e}]),onClick:C?void 0:cF(M,w),onContextMenu:cF(N,w),onWheel:cF(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?z:p,onPointerUp:B,onPointerCancel:C?te:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:rF,children:[h,(0,U.jsx)(sF,{})]})}function dF({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,nj.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function fF({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=eP(),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)();return(0,H.useEffect)(()=>{if(!t)return u.current=iN({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{dF({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,H.useEffect)(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var pF=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function mF(){let e=eP();return(0,H.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=pF(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=Vj(t,i));let{position:a,positionAbsolute:s}=Cj({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var hF=(0,H.createContext)(null),gF=hF.Provider;hF.Consumer;var _F=()=>(0,H.useContext)(hF),vF=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),yF=(0,H.createContext)(null);function bF({children:e}){let t=$(vF,XN);return(0,U.jsx)(yF.Provider,{value:t,children:e})}function xF(){let e=(0,H.useContext)(yF);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var SF={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},CF=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return SF;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===oj.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function wF({type:e=`source`,position:t=Q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=eP(),_=_F(),{connectOnClick:v,noPanClassName:y,rfId:b}=xF(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=$(CF(_,m,e),XN);_||g.getState().onError?.(`010`,nj.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(VP(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=cM(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();mN.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,U.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:yT([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=aM(t.target),h=n||c,{connection:v,isValid:y}=mN.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var TF=(0,H.memo)(WP(wF));function EF({data:e,isConnectable:t,sourcePosition:n=Q.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[e?.label,(0,U.jsx)(TF,{type:`source`,position:n,isConnectable:t})]})}function DF({data:e,isConnectable:t,targetPosition:n=Q.Top,sourcePosition:r=Q.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TF,{type:`target`,position:n,isConnectable:t}),e?.label,(0,U.jsx)(TF,{type:`source`,position:r,isConnectable:t})]})}function OF(){return null}function kF({data:e,isConnectable:t,targetPosition:n=Q.Top}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TF,{type:`target`,position:n,isConnectable:t}),e?.label]})}var AF={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},jF={input:EF,default:DF,output:kF,group:OF};function MF(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var NF=e=>{let{width:t,height:n,x:r,y:i}=vj(e.nodeLookup,{filter:e=>!!e.selected});return{width:zj(t)?t:null,height:zj(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function PF({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=eP(),{width:i,height:a,transformString:o,userSelectionActive:s}=$(NF,XN),c=mF(),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(fF({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,U.jsx)(`div`,{className:yT([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,U.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(AF,e.key)&&(e.preventDefault(),c({direction:AF[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var FF=typeof window<`u`?window:void 0,IF=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function LF({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=$(IF,XN),ee=OP(l,{target:FF}),z=OP(h,{target:FF}),B=z||w,te=z||b,V=u&&B!==!0,ne=ee||R||V;return tF({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,U.jsx)(aF,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:te,panActivationKeyPressed:z,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!ee&&B,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:V,children:(0,U.jsxs)(uF,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:B,autoPanOnSelection:T,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:ee,paneClickDistance:s,selectionOnDrag:V,children:[e,L&&(0,U.jsx)(PF,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}LF.displayName=`FlowRenderer`;var RF=(0,H.memo)(LF),zF=e=>t=>e?yj(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function BF(e){return $((0,H.useCallback)(zF(e),[e]),XN)}var VF=e=>e.updateNodeInternals;function HF(){let e=$(VF),[t]=(0,H.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,H.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function UF({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=eP(),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(e.sourcePosition),c=(0,H.useRef)(e.targetPosition),l=(0,H.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,H.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,H.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,H.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function WF({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=$(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},XN),S=y.type||`default`,C=g?.[S]||jF[S];C===void 0&&(v?.(`003`,nj.error003(S)),S=`default`,C=g?.default||jF.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=eP(),k=Zj(y),A=UF({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=fF({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=mF();if(y.hidden)return null;let N=Xj(y),P=MF(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,ee=a?e=>a(e,{...b.userNode}):void 0,z=o?e=>o(e,{...b.userNode}):void 0,B=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&dF({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},te=t=>{if(!(sM(t.nativeEvent)||m)){if(ij.includes(t.key)&&T){let n=t.key===`Escape`;dF({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(AF,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:AF[t.key],factor:t.shiftKey?4:1})}}},V=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(yj(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,U.jsx)(`div`,{className:yT([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:ee,onClick:B,onDoubleClick:z,onKeyDown:D?te:void 0,tabIndex:D?0:void 0,onFocus:D?V:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${rP}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,U.jsx)(gF,{value:e,children:(0,U.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var GF=(0,H.memo)(WF),KF=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function qF(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=$(KF,XN),a=BF(e.onlyRenderVisibleElements),o=HF();return(0,U.jsx)(`div`,{className:`react-flow__nodes`,style:rF,children:a.map(a=>(0,U.jsx)(GF,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}qF.displayName=`NodeRenderer`;var JF=(0,H.memo)(qF);function YF(e){return $((0,H.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&_M({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),XN)}var XF=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,U.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},ZF=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,U.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},QF={[dj.Arrow]:XF,[dj.ArrowClosed]:ZF};function $F(e){let t=eP();return(0,H.useMemo)(()=>Object.prototype.hasOwnProperty.call(QF,e)?QF[e]:(t.getState().onError?.(`009`,nj.error009(e)),null),[e])}var eI=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=$F(t);return c?(0,U.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,U.jsx)(c,{color:n,strokeWidth:o})}):null},tI=({defaultColor:e,rfId:t})=>{let n=$(e=>e.edges),r=$(e=>e.defaultEdgeOptions),i=(0,H.useMemo)(()=>PM(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,U.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,U.jsx)(`defs`,{children:i.map(e=>(0,U.jsx)(eI,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};tI.displayName=`MarkerDefinitions`;var nI=(0,H.memo)(tI);function rI({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,H.useState)({x:1,y:0,width:0,height:0}),p=yT([`react-flow__edge-textwrapper`,l]),m=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,U.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,U.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,U.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}rI.displayName=`EdgeText`;var iI=(0,H.memo)(rI);function aI({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{...u,d:e,fill:`none`,className:yT([`react-flow__edge-path`,u.className])}),l?(0,U.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&zj(t)&&zj(n)?(0,U.jsx)(iI,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function oI({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Q.Left||e===Q.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function sI({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top}){let[o,s]=oI({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=oI({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=dM({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function cI(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=sI({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,U.jsx)(aI,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var lI=cI({isInternal:!1}),uI=cI({isInternal:!0});lI.displayName=`SimpleBezierEdge`,uI.displayName=`SimpleBezierEdgeInternal`;function dI(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Q.Bottom,targetPosition:m=Q.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=DM({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,U.jsx)(aI,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var fI=dI({isInternal:!1}),pI=dI({isInternal:!0});fI.displayName=`SmoothStepEdge`,pI.displayName=`SmoothStepEdgeInternal`;function mI(e){return(0,H.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,U.jsx)(fI,{...n,id:r,pathOptions:(0,H.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var hI=mI({isInternal:!1}),gI=mI({isInternal:!0});hI.displayName=`StepEdge`,gI.displayName=`StepEdgeInternal`;function _I(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=xM({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,U.jsx)(aI,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var vI=_I({isInternal:!1}),yI=_I({isInternal:!0});vI.displayName=`StraightEdge`,yI.displayName=`StraightEdgeInternal`;function bI(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Q.Bottom,targetPosition:s=Q.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=mM({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,U.jsx)(aI,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var xI=bI({isInternal:!1}),SI=bI({isInternal:!0});xI.displayName=`BezierEdge`,SI.displayName=`BezierEdgeInternal`;var CI={default:SI,straight:yI,step:gI,smoothstep:pI,simplebezier:uI},wI={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},TI=(e,t,n)=>n===Q.Left?e-t:n===Q.Right?e+t:e,EI=(e,t,n)=>n===Q.Top?e-t:n===Q.Bottom?e+t:e,DI=`react-flow__edgeupdater`;function OI({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,U.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:yT([DI,`${DI}-${s}`]),cx:TI(t,r,e),cy:EI(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function kI({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=eP(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;mN.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,U.jsxs)(U.Fragment,{children:[(e===!0||e===`source`)&&(0,U.jsx)(OI,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,U.jsx)(OI,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function AI({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=$(t=>t.edgeLookup.get(e)),b=$(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||CI[x];S===void 0&&(_?.(`011`,nj.error011(x)),x=`default`,S=h?.default||CI.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,H.useRef)(null),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(!1),j=eP(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=$((0,H.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return wI;let i=kM({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=gM({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||wI,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex,_]),XN),ee=(0,H.useMemo)(()=>y.markerStart?`url('#${NM(y.markerStart,m)}')`:void 0,[y.markerStart,m]),z=(0,H.useMemo)(()=>y.markerEnd?`url('#${NM(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let B=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},te=a?e=>{a(e,{...y})}:void 0,V=o?e=>{o(e,{...y})}:void 0,ne=s?e=>{s(e,{...y})}:void 0,re=c?e=>{c(e,{...y})}:void 0,ie=l?e=>{l(e,{...y})}:void 0;return(0,U.jsx)(`svg`,{style:{zIndex:M},children:(0,U.jsxs)(`g`,{className:yT([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:B,onDoubleClick:te,onContextMenu:V,onMouseEnter:ne,onMouseMove:re,onMouseLeave:ie,onKeyDown:C?t=>{if(!v&&ij.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${iP}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,U.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:ee,markerEnd:z,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,U.jsx)(kI,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var jI=(0,H.memo)(AI),MI=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function NI({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=$(MI,XN),b=YF(t);return(0,U.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,U.jsx)(nI,{defaultColor:e,rfId:n}),b.map(e=>(0,U.jsx)(jI,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}NI.displayName=`EdgeRenderer`;var PI=(0,H.memo)(NI),FI=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function II({children:e}){let t=eP(),n=(0,H.useRef)(null),[r]=(0,H.useState)(()=>t.getState().transform);return GP(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=FI(r)))};return r(),t.subscribe(r)},[t]),(0,U.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:FI(r)},children:e})}function LI(e){let t=QP(),n=(0,H.useRef)(!1);(0,H.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var RI=e=>e.panZoom?.syncViewport;function zI(e){let t=$(RI),n=eP();return(0,H.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function BI(e){return e.connection.inProgress?{...e.connection,to:Hj(e.connection.to,e.transform)}:{...e.connection}}function VI(e){return e?t=>e(BI(t)):BI}function HI(e){return $(VI(e),XN)}var UI=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function WI({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=$(UI,XN);return a&&i&&c?(0,U.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,U.jsx)(`g`,{className:yT([`react-flow__connection`,nM(s)]),children:(0,U.jsx)(GI,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var GI=({style:e,type:t=uj.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=HI();if(!i)return;if(n)return(0,U.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:nM(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case uj.Bezier:[m]=mM(h);break;case uj.SimpleBezier:[m]=sI(h);break;case uj.Step:[m]=DM({...h,borderRadius:0});break;case uj.SmoothStep:[m]=DM(h);break;default:[m]=xM(h)}return(0,U.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};GI.displayName=`ConnectionLine`;var KI={};function qI(e=KI){(0,H.useRef)(e),eP(),(0,H.useEffect)(()=>{},[e])}function JI(){eP(),(0,H.useRef)(!1),(0,H.useEffect)(()=>{},[])}function YI({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:ee,autoPanOnSelection:z,onPaneClick:B,onPaneMouseEnter:te,onPaneMouseMove:V,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:ie,paneClickDistance:ae,nodeClickDistance:oe,onEdgeContextMenu:se,onEdgeMouseEnter:ce,onEdgeMouseMove:le,onEdgeMouseLeave:ue,reconnectRadius:de,onReconnect:fe,onReconnectStart:pe,onReconnectEnd:me,noDragClassName:he,noWheelClassName:ge,noPanClassName:_e,disableKeyboardA11y:ve,nodeExtent:ye,rfId:be,viewport:xe,onViewportChange:Se,nodesDraggable:Ce}){return qI(e),qI(t),JI(),LI(n),zI(xe),(0,U.jsx)(RF,{onPaneClick:B,onPaneMouseEnter:te,onPaneMouseMove:V,onPaneMouseLeave:ne,onPaneContextMenu:ie,onPaneScroll:re,paneClickDistance:ae,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:ee,autoPanOnSelection:z,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:he,noWheelClassName:ge,noPanClassName:_e,disableKeyboardA11y:ve,onViewportChange:Se,isControlledViewport:!!xe,children:(0,U.jsxs)(II,{children:[(0,U.jsx)(PI,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:fe,onReconnectStart:pe,onReconnectEnd:me,onlyRenderVisibleElements:T,onEdgeContextMenu:se,onEdgeMouseEnter:ce,onEdgeMouseMove:le,onEdgeMouseLeave:ue,reconnectRadius:de,defaultMarkerColor:M,noPanClassName:_e,disableKeyboardA11y:ve,rfId:be}),(0,U.jsx)(WI,{style:h,type:m,component:g,containerStyle:_}),(0,U.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,U.jsx)(JF,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:oe,onlyRenderVisibleElements:T,noPanClassName:_e,noDragClassName:he,disableKeyboardA11y:ve,nodeExtent:ye,rfId:be,nodesDraggable:Ce}),(0,U.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}YI.displayName=`GraphView`;var XI=(0,H.memo)(YI),ZI=Bj(`React Flow`,`https://reactflow.dev/`),QI=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??rj;QM(h,g,_);let{nodesInitialized:x}=UM(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=qj(vj(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:rj,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:oj.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...lj},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ZI,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:aj,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},$I=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>YN((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await Sj({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...QI({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,fitViewQueued:o,zIndexMode:s,nodesSelectionActive:c}=m(),{nodesInitialized:l,hasSelectedNodes:u}=UM(e,t,n,{nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:s}),d=c&&u;o&&l?(h(),p({nodes:e,nodesInitialized:l,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):p({nodes:e,nodesInitialized:l,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();QM(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=YM(e,n,r,i,a,o,l);d&&(BM(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=jM(e,o.fromHandle,Q.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=JM(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(PP(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(FP(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>IP(e,!0)));return}i(LP(r,new Set([...e]),!0)),a(LP(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>IP(e,!0)));return}a(LP(n,new Set([...e]))),i(LP(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(IP(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(IP(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,IP(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,IP(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(UM(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return XM({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...lj}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...QI()})}},Object.is);function eL({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,H.useState)(()=>$I({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,U.jsx)(QN,{value:m,children:(0,U.jsx)(YP,{children:(0,U.jsx)(bF,{children:p})})})}function tL({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,H.useContext)(ZN)?(0,U.jsx)(U.Fragment,{children:e}):(0,U.jsx)(eL,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var nL={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function rL({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=uj.Bezier,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:te=`Backspace`,selectionKeyCode:V=`Shift`,selectionOnDrag:ne=!1,selectionMode:re=cj.Full,panActivationKeyCode:ie=`Space`,multiSelectionKeyCode:ae=Jj()?`Meta`:`Control`,zoomActivationKeyCode:oe=Jj()?`Meta`:`Control`,snapToGrid:se,snapGrid:ce,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ue,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,nodeOrigin:he=yP,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve=!0,defaultViewport:ye=bP,minZoom:be=.5,maxZoom:xe=2,translateExtent:Se=rj,preventScrolling:Ce=!0,nodeExtent:we,defaultMarkerColor:Te=`#b1b1b7`,zoomOnScroll:Ee=!0,zoomOnPinch:De=!0,panOnScroll:Oe=!1,panOnScrollSpeed:ke=.5,panOnScrollMode:Ae=sj.Free,zoomOnDoubleClick:je=!0,panOnDrag:Me=!0,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze=1,nodeClickDistance:Be=0,children:Ve,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe=10,onNodesChange:Ze,onEdgesChange:Qe,noDragClassName:$e=`nodrag`,noWheelClassName:et=`nowheel`,noPanClassName:tt=`nopan`,fitView:nt,fitViewOptions:rt,connectOnClick:it,attributionPosition:at,proOptions:ot,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanOnSelection:pt=!0,autoPanSpeed:mt,connectionRadius:ht,isValidConnection:gt,onError:_t,style:vt,id:yt,nodeDragThreshold:bt,connectionDragThreshold:xt,viewport:St,onViewportChange:Ct,width:wt,height:Tt,colorMode:Et=`light`,debug:Dt,onScroll:Ot,ariaLabelConfig:kt,zIndexMode:At=`basic`,...jt},Mt){let Nt=yt||`1`,Pt=EP(Et),Ft=(0,H.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Ot?.(e)},[Ot]);return(0,U.jsx)(`div`,{"data-testid":`rf__wrapper`,...jt,onScroll:Ft,style:{...vt,...nL},ref:Mt,className:yT([`react-flow`,i,Pt]),id:yt,role:`application`,children:(0,U.jsxs)(tL,{nodes:e,edges:t,width:wt,height:Tt,fitView:nt,fitViewOptions:rt,minZoom:be,maxZoom:xe,nodeOrigin:he,nodeExtent:we,zIndexMode:At,children:[(0,U.jsx)(wP,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:be,maxZoom:xe,nodeExtent:we,onNodesChange:Ze,onEdgesChange:Qe,snapToGrid:se,snapGrid:ce,connectionMode:L,translateExtent:Se,connectOnClick:it,defaultEdgeOptions:st,fitView:nt,fitViewOptions:rt,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:tt,nodeOrigin:he,rfId:Nt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:mt,onError:_t,connectionRadius:ht,isValidConnection:gt,selectNodesOnDrag:ue,nodeDragThreshold:bt,connectionDragThreshold:xt,onBeforeDelete:I,debug:Dt,ariaLabelConfig:kt,zIndexMode:At}),(0,U.jsx)(XI,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:V,selectionOnDrag:ne,selectionMode:re,deleteKeyCode:te,multiSelectionKeyCode:ae,panActivationKeyCode:ie,zoomActivationKeyCode:oe,onlyRenderVisibleElements:le,defaultViewport:ye,translateExtent:Se,minZoom:be,maxZoom:xe,preventScrolling:Ce,zoomOnScroll:Ee,zoomOnPinch:De,zoomOnDoubleClick:je,panOnScroll:Oe,panOnScrollSpeed:ke,panOnScrollMode:Ae,panOnDrag:Me,autoPanOnSelection:pt,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze,nodeClickDistance:Be,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe,defaultMarkerColor:Te,noDragClassName:$e,noWheelClassName:et,noPanClassName:tt,rfId:Nt,disableKeyboardA11y:ut,nodeExtent:we,viewport:St,onViewportChange:Ct,nodesDraggable:de}),(0,U.jsx)(vP,{onSelectionChange:k}),Ve,(0,U.jsx)(fP,{proOptions:ot,position:at}),(0,U.jsx)(lP,{rfId:Nt,disableKeyboardA11y:ut})]})})}var iL=WP(rL);nj.error014();function aL({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,U.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:yT([`react-flow__background-pattern`,n,r])})}function oL({radius:e,className:t}){return(0,U.jsx)(`circle`,{cx:e,cy:e,r:e,className:yT([`react-flow__background-pattern`,`dots`,t])})}var sL;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(sL||={});var cL={[sL.Dots]:1,[sL.Lines]:1,[sL.Cross]:6},lL=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function uL({id:e,variant:t=sL.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,H.useRef)(null),{transform:f,patternId:p}=$(lL,XN),m=r||cL[t],h=t===sL.Dots,g=t===sL.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]+x[0]/2,b[1]*f[2]+x[1]/2],C=`${p}${e||``}`;return(0,U.jsxs)(`svg`,{className:yT([`react-flow__background`,l]),style:{...c,...rF,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,U.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,U.jsx)(oL,{radius:y/2,className:u}):(0,U.jsx)(aL,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,U.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}uL.displayName=`Background`;var dL=(0,H.memo)(uL);function fL(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,U.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function pL(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,U.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function mL(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,U.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function hL(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function gL(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function _L({children:e,className:t,...n}){return(0,U.jsx)(`button`,{type:`button`,className:yT([`react-flow__controls-button`,t]),...n,children:e})}var vL=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function yL({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=eP(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=$(vL,XN),{zoomIn:y,zoomOut:b,fitView:x}=QP();return(0,U.jsxs)(uP,{className:yT([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(_L,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,U.jsx)(fL,{})}),(0,U.jsx)(_L,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,U.jsx)(pL,{})})]}),n&&(0,U.jsx)(_L,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,U.jsx)(mL,{})}),r&&(0,U.jsx)(_L,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,U.jsx)(gL,{}):(0,U.jsx)(hL,{})}),u]})}yL.displayName=`Controls`;var bL=(0,H.memo)(yL);function xL({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,U.jsx)(`rect`,{className:yT([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var SL=(0,H.memo)(xL),CL=e=>e.nodes.map(e=>e.id),wL=e=>e instanceof Function?e:()=>e;function TL({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=SL,onClick:o}){let s=$(CL,XN),c=wL(t),l=wL(e),u=wL(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,U.jsx)(U.Fragment,{children:s.map(e=>(0,U.jsx)(DL,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function EL({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=$(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=Xj(r);return{node:r,x:i,y:a,width:o,height:s}},XN);return!l||l.hidden||!Zj(l)?null:(0,U.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var DL=(0,H.memo)(EL),OL=(0,H.memo)(TL),kL=200,AL=150,jL=e=>!e.hidden,ML=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?Fj(vj(e.nodeLookup,{filter:jL}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},NL=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,PL=(e,t)=>NL(e.viewBB,t.viewBB)&&NL(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,FL=`react-flow__minimap-desc`;function IL({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=eP(),S=(0,H.useRef)(null),{boundingRect:C,panZoom:w,viewBB:T,rfId:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=$(ML,PL),j=e?.width??kL,M=e?.height??AL,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,ee=C.x-(I-C.width)/2-R,z=C.y-(L-C.height)/2-R,B=I+R*2,te=L+R*2,V=`${FL}-${E}`,ne=(0,H.useRef)(0),re=(0,H.useRef)();ne.current=F,(0,H.useEffect)(()=>{let e=x.getState().panZoom;if(S.current&&e)return re.current=hN({domNode:S.current,panZoom:e,getTransform:()=>x.getState().transform,getViewScale:()=>ne.current}),()=>{re.current?.destroy()}},[w]),(0,H.useEffect)(()=>{re.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ie=p?e=>{let[t,n]=re.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ae=(0,H.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m?.(e,n)},[m]),oe=m?ae:void 0,se=_??A[`minimap.ariaLabel`];return(0,U.jsx)(uP,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:yT([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,U.jsxs)(`svg`,{width:j,height:M,viewBox:`${ee} ${z} ${B} ${te}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":V,ref:S,onClick:ie,children:[se&&(0,U.jsx)(`title`,{id:V,children:se}),(0,U.jsx)(OL,{onClick:oe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,U.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${ee-R},${z-R}h${B+R*2}v${te+R*2}h${-B-R*2}z
|
|
149
|
+
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}IL.displayName=`MiniMap`,(0,H.memo)(IL);var LL=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,RL={[AN.Line]:`right`,[AN.Handle]:`bottom-right`};function zL({nodeId:e,position:t,variant:n=AN.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=_F(),y=typeof e==`string`?e:v,b=eP(),x=(0,H.useRef)(null),S=n===AN.Handle,C=$((0,H.useCallback)(LL(S&&p),[S,p]),XN),w=(0,H.useRef)(null),T=t??RL[n];(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=VN({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=JM([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...Qj({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,U.jsx)(`div`,{className:yT([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(zL);var BL={workflow:KL,loop:GL},VL=[],HL={padding:.08,maxZoom:1},UL=[`true`,`false`,`failure`,`timeout`],WL=[`success`,`failure`,`timeout`];function GL({data:e}){return(0,U.jsx)(`div`,{className:`workflow-loop h-full rounded-lg border border-primary/40 bg-primary/5 p-3 text-xs`,"data-orientation":e.orientation,children:(0,U.jsxs)(`div`,{className:`workflow-loop__summary`,children:[(0,U.jsxs)(`div`,{className:`workflow-loop__heading nodrag nopan`,children:[(0,U.jsxs)(`strong`,{title:e.title,className:`line-clamp-2 min-w-0 text-sm`,children:[`Loop · `,e.title]}),(0,U.jsx)(`span`,{className:`shrink-0`,children:`Max tries`}),(0,U.jsxs)(Rt,{value:e.maxTries,disabled:!e.change,onValueChange:t=>t!==null&&e.change?.(t),children:[(0,U.jsx)(jt,{size:`sm`,"aria-label":`Max tries · ${e.title}`,children:(0,U.jsx)(It,{children:e.maxTries})}),(0,U.jsx)(At,{children:Array.from({length:100},(e,t)=>(0,U.jsx)(Ct,{value:t+1,children:t+1},t+1))})]})]}),(0,U.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:e.progress??`First check included. Inner limits reset on each outer try.`})]})})}function KL({data:e}){let{step:t}=e,n=t.kind===`branch`?UL:WL,r=e.vertical?Q.Bottom:Q.Right;return(0,U.jsxs)(`div`,{"data-status":e.status,"data-orientation":e.vertical?`vertical`:`horizontal`,className:`workflow-step relative rounded-lg border bg-card p-3 text-xs text-card-foreground`,style:{width:208,height:192},children:[(0,U.jsx)(TF,{type:`target`,position:e.vertical?Q.Top:Q.Left}),(0,U.jsx)(`strong`,{title:t.name,className:`block text-sm font-semibold ${e.execution?`line-clamp-2 whitespace-normal`:`truncate`}`,children:t.name}),(0,U.jsxs)(`div`,{className:`text-muted-foreground`,children:[t.kind,` · `,e.permission]}),e.status&&(0,U.jsx)(`div`,{children:e.status.replaceAll(`-`,` `)}),(0,U.jsx)(`div`,{className:`workflow-step__outcomes ${e.vertical?`workflow-step__outcomes--vertical`:`workflow-step__outcomes--horizontal`}`,children:n.map(e=>(0,U.jsxs)(`div`,{className:`workflow-step__outcome`,"data-outcome":e,children:[(0,U.jsx)(`span`,{children:e}),(0,U.jsx)(TF,{id:e,type:`source`,position:r})]},e))})]})}function qL({definition:e,onChange:t,onSelect:n,execution:r,awaitingSteps:i=VL,selectedStepId:a,orientation:o=`horizontal`}){let[s,c]=(0,H.useState)([]),[l,u]=(0,H.useState)([]),d=a!==void 0,f=(0,H.useCallback)(({nodes:e})=>{let t=e.find(e=>e.type===`workflow`);t?n(t.id):d||n(``)},[n,d]),p=r?.id??e,m=(0,H.useMemo)(()=>{let t;try{t=dT(r?vT(e,o===`vertical`):e,{orientation:o})}catch{t=e.steps.map((e,t)=>({id:e.id,type:`workflow`,position:e.position??lT(t),data:{step:e}}))}return{layout:t,edges:e.edges.map(e=>({id:e.id,source:e.from,target:e.to,sourceHandle:e.outcome,label:e.outcome,zIndex:0})),steps:new Map(e.steps.map(e=>[e.id,e]))}},[p,e.id,o]);return(0,H.useEffect)(()=>{let n=new Set(i);c(i=>{let s=new Map(i.map(e=>[e.id,e]));return m.layout.map(i=>{if(i.type===`loop`){let n=i.data.headerId,a=e.loopSettings?.[n]?.maxTries??3;return{...i,data:{title:m.steps.get(n).name,maxTries:a,orientation:o,progress:r?.loops?.[n]?pT(r.loops[n],a):void 0,change:t?r=>t({...e,loopSettings:{...e.loopSettings,[n]:{maxTries:r}}}):void 0}}}let c=i.data.step;return{...i,selected:a===void 0?s.get(c.id)?.selected:a===c.id,data:{step:c,vertical:!!r&&o===`vertical`,execution:!!r,permission:c.permission??e.permission??`auto-accept`,status:n.has(c.id)?`awaiting-input`:r?.steps[c.id]?.status}}})})},[m,r,a,i,e,t,o]),(0,H.useEffect)(()=>{u(e=>{let t=new Set(e.filter(e=>e.selected).map(e=>e.id));return m.edges.map(e=>({...e,selected:t.has(e.id)}))})},[m]),(0,U.jsx)(`div`,{className:`workflow-canvas overflow-hidden rounded-lg border`,children:(0,U.jsxs)(iL,{nodes:s,edges:l,nodeTypes:BL,onNodesChange:e=>c(t=>PP(e,t)),onEdgesChange:e=>u(t=>FP(e,t)),onConnect:n=>{n.source&&n.target&&t?.({...e,edges:[...e.edges,{id:crypto.randomUUID(),from:n.source,to:n.target,outcome:n.sourceHandle??`success`}]})},onNodeClick:(e,t)=>t.type===`workflow`&&n(t.id),onPaneClick:t&&d?()=>n(``):void 0,onSelectionChange:r||d?void 0:f,onNodeDragStop:(n,r,i)=>t?.({...e,steps:e.steps.map(e=>{let t=(i.length?i:[r]).find(t=>t.id===e.id);return t?{...e,position:fT(t,s)}:e})}),onDelete:({nodes:n,edges:r})=>t?.(uT({...e,steps:e.steps.filter(e=>!n.some(t=>t.type===`workflow`&&t.id===e.id)),edges:e.edges.filter(e=>!r.some(t=>t.id===e.id)&&!n.some(t=>t.type===`workflow`&&(t.id===e.from||t.id===e.to)))})),nodesDraggable:!!t,nodesConnectable:!!t,deleteKeyCode:t?[`Backspace`,`Delete`]:null,defaultViewport:{x:32,y:e.loopSettings&&Object.keys(e.loopSettings).length?120:24,zoom:1},minZoom:r?_T:gT,fitView:!0,fitViewOptions:HL,zIndexMode:`manual`,children:[(0,U.jsx)(dL,{}),(0,U.jsx)(bL,{fitViewOptions:HL})]})})}export{no as $,tn as $t,Kl as A,ii as At,es as B,Vn as Bt,vw as C,yi as Ct,ow as D,mi as Dt,fw as E,di as Et,pl as F,Gr as Ft,Lo as G,En as Gt,Go as H,zn as Ht,ll as I,Wr as It,Mo as J,Sn as Jt,Fo as K,wn as Kt,ol as L,Ir as Lt,Nl as M,Zr as Mt,Al as N,Xr as Nt,yu as O,oi as Ot,gl as P,Kr as Pt,mo as Q,on as Qt,Hc as R,qn as Rt,Pw as S,xi as St,bw as T,si as Tt,Ho as U,In as Ut,Xo as V,Bn as Vt,Bo as W,Nn as Wt,vo as X,rn as Xt,Do as Y,bn as Yt,_o as Z,cn as Zt,Bw as _,Ni as _t,pT as a,Jt as an,so as at,Ww as b,Ei as bt,sT as c,qt as cn,ga as ct,nT as d,_a as dt,en,io as et,$w as f,Vi as ft,Rw as g,ki as gt,Vw as h,Ai as ht,mT as i,$t as in,co as it,Fl as j,ri as jt,Zl as k,ai as kt,iT as l,va as lt,Jw as m,Ii as mt,hT as n,Zt as nn,lo as nt,oT as o,Kt as on,ro as ot,Xw as p,Bi as pt,Po as q,Cn as qt,uT as r,Qt as rn,oo as rt,aT as s,Gt as sn,Ga as st,qL as t,Xt as tn,ao as tt,rT as u,ha as ut,Uw as v,ji as vt,Cw as w,bi as wt,zw as x,Oi as xt,Hw as y,Di as yt,rs as z,Wn as zt};
|