copperflow 0.3.4 → 0.4.0
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 +107 -13
- package/dist/app/THIRD_PARTY_LICENSES.txt +5 -0
- package/dist/app/assets/NewPartDialog-BBJaZFCo.js +160 -0
- package/dist/app/assets/VerifyPartDialog-BHLqD_WJ.css +1 -0
- package/dist/app/assets/VerifyPartDialog-Ey6xpQ_U.js +2 -0
- package/dist/app/assets/index-BKoIKo22.css +1 -0
- package/dist/app/assets/index-DPmr2dR1.js +20 -0
- package/dist/app/assets/texture-worker-CyI_g_XZ.js +1 -0
- package/dist/app/index.html +2 -2
- package/dist/cli-commands.js +120 -16
- package/dist/cli-commands.js.map +1 -1
- package/dist/cli-impedance.d.ts +4 -0
- package/dist/cli-impedance.js +56 -0
- package/dist/cli-impedance.js.map +1 -0
- package/dist/cli-simulate.d.ts +3 -0
- package/dist/cli-simulate.js +54 -0
- package/dist/cli-simulate.js.map +1 -0
- package/dist/core/analyze.js +5 -2
- package/dist/core/analyze.js.map +1 -1
- package/dist/core/bom.d.ts +6 -1
- package/dist/core/bom.js +23 -4
- package/dist/core/bom.js.map +1 -1
- package/dist/core/case-results.d.ts +4 -0
- package/dist/core/case-results.js +9 -0
- package/dist/core/case-results.js.map +1 -0
- package/dist/core/change-files.d.ts +31 -0
- package/dist/core/change-files.js +67 -0
- package/dist/core/change-files.js.map +1 -0
- package/dist/core/change-render.d.ts +18 -0
- package/dist/core/change-render.js +48 -0
- package/dist/core/change-render.js.map +1 -0
- package/dist/core/change-view.d.ts +33 -0
- package/dist/core/change-view.js +73 -0
- package/dist/core/change-view.js.map +1 -0
- package/dist/core/change-words.d.ts +39 -0
- package/dist/core/change-words.js +214 -0
- package/dist/core/change-words.js.map +1 -0
- package/dist/core/checklist-text.d.ts +21 -0
- package/dist/core/checklist-text.js +59 -0
- package/dist/core/checklist-text.js.map +1 -0
- package/dist/core/edit.js +5 -2
- package/dist/core/edit.js.map +1 -1
- package/dist/core/fabrication.d.ts +9 -2
- package/dist/core/fabrication.js +29 -10
- package/dist/core/fabrication.js.map +1 -1
- package/dist/core/library.d.ts +46 -0
- package/dist/core/library.js +54 -16
- package/dist/core/library.js.map +1 -1
- package/dist/core/modules.d.ts +1 -0
- package/dist/core/modules.js +17 -0
- package/dist/core/modules.js.map +1 -1
- package/dist/core/order-report.d.ts +10 -0
- package/dist/core/order-report.js +93 -0
- package/dist/core/order-report.js.map +1 -0
- package/dist/core/pin-header.d.ts +5 -0
- package/dist/core/pin-header.js +77 -0
- package/dist/core/pin-header.js.map +1 -0
- package/dist/core/pin-map.d.ts +46 -0
- package/dist/core/pin-map.js +101 -0
- package/dist/core/pin-map.js.map +1 -0
- package/dist/core/render.d.ts +24 -4
- package/dist/core/render.js +16 -6
- package/dist/core/render.js.map +1 -1
- package/dist/core/sheet-card.d.ts +4 -0
- package/dist/core/sheet-card.js +46 -1
- package/dist/core/sheet-card.js.map +1 -1
- package/dist/core/sheet-files.js +10 -3
- package/dist/core/sheet-files.js.map +1 -1
- package/dist/core/simulate.d.ts +19 -0
- package/dist/core/simulate.js +72 -0
- package/dist/core/simulate.js.map +1 -0
- package/dist/core/step-export.d.ts +17 -0
- package/dist/core/step-export.js +35 -0
- package/dist/core/step-export.js.map +1 -0
- package/dist/core/supplier-prop.d.ts +6 -0
- package/dist/core/supplier-prop.js +21 -0
- package/dist/core/supplier-prop.js.map +1 -0
- package/dist/core/workspace.d.ts +2 -1
- package/dist/core/workspace.js +2 -1
- package/dist/core/workspace.js.map +1 -1
- package/dist/engine/board.js +3 -1
- package/dist/engine/board.js.map +1 -1
- package/dist/engine/checks/fast-lines.d.ts +60 -0
- package/dist/engine/checks/fast-lines.js +209 -0
- package/dist/engine/checks/fast-lines.js.map +1 -0
- package/dist/engine/checks/index.js +2 -0
- package/dist/engine/checks/index.js.map +1 -1
- package/dist/engine/design-diff.d.ts +120 -0
- package/dist/engine/design-diff.js +249 -0
- package/dist/engine/design-diff.js.map +1 -0
- package/dist/engine/design.d.ts +3 -0
- package/dist/engine/design.js +7 -2
- package/dist/engine/design.js.map +1 -1
- package/dist/engine/fab/export.d.ts +17 -1
- package/dist/engine/fab/export.js +26 -4
- package/dist/engine/fab/export.js.map +1 -1
- package/dist/engine/fab/names.d.ts +2 -2
- package/dist/engine/fab/names.js +4 -2
- package/dist/engine/fab/names.js.map +1 -1
- package/dist/engine/fab/picture/board-picture.d.ts +52 -0
- package/dist/engine/fab/picture/board-picture.js +102 -0
- package/dist/engine/fab/picture/board-picture.js.map +1 -0
- package/dist/engine/fab/picture/board-view.d.ts +20 -0
- package/dist/engine/fab/picture/board-view.js +50 -0
- package/dist/engine/fab/picture/board-view.js.map +1 -0
- package/dist/engine/fab/picture/compose.d.ts +50 -0
- package/dist/engine/fab/picture/compose.js +208 -0
- package/dist/engine/fab/picture/compose.js.map +1 -0
- package/dist/engine/fab/picture/layer-images.d.ts +9 -0
- package/dist/engine/fab/picture/layer-images.js +67 -0
- package/dist/engine/fab/picture/layer-images.js.map +1 -0
- package/dist/engine/fab/picture/looks.d.ts +152 -0
- package/dist/engine/fab/picture/looks.js +53 -0
- package/dist/engine/fab/picture/looks.js.map +1 -0
- package/dist/engine/fab/picture/png.d.ts +31 -0
- package/dist/engine/fab/picture/png.js +47 -0
- package/dist/engine/fab/picture/png.js.map +1 -0
- package/dist/engine/fab/picture/raster.d.ts +46 -0
- package/dist/engine/fab/picture/raster.js +170 -0
- package/dist/engine/fab/picture/raster.js.map +1 -0
- package/dist/engine/fab/zip.d.ts +2 -1
- package/dist/engine/fab/zip.js +1 -1
- package/dist/engine/fab/zip.js.map +1 -1
- package/dist/engine/impedance.d.ts +72 -0
- package/dist/engine/impedance.js +133 -0
- package/dist/engine/impedance.js.map +1 -0
- package/dist/engine/line-length.d.ts +15 -0
- package/dist/engine/line-length.js +116 -0
- package/dist/engine/line-length.js.map +1 -0
- package/dist/engine/model.d.ts +2 -0
- package/dist/engine/model.js.map +1 -1
- package/dist/engine/pcb-place/roles.d.ts +3 -1
- package/dist/engine/pcb-place/roles.js +5 -0
- package/dist/engine/pcb-place/roles.js.map +1 -1
- package/dist/engine/rules/impedance-widths.d.ts +20 -0
- package/dist/engine/rules/impedance-widths.js +57 -0
- package/dist/engine/rules/impedance-widths.js.map +1 -0
- package/dist/engine/rules/load.js +11 -2
- package/dist/engine/rules/load.js.map +1 -1
- package/dist/engine/rules/pairs.d.ts +27 -0
- package/dist/engine/rules/pairs.js +86 -0
- package/dist/engine/rules/pairs.js.map +1 -0
- package/dist/engine/rules/profiles.js +16 -0
- package/dist/engine/rules/profiles.js.map +1 -1
- package/dist/engine/rules/schema.d.ts +44 -0
- package/dist/engine/rules/schema.js +16 -1
- package/dist/engine/rules/schema.js.map +1 -1
- package/dist/engine/sim/answer.d.ts +13 -0
- package/dist/engine/sim/answer.js +101 -0
- package/dist/engine/sim/answer.js.map +1 -0
- package/dist/engine/sim/cases.d.ts +29 -0
- package/dist/engine/sim/cases.js +63 -0
- package/dist/engine/sim/cases.js.map +1 -0
- package/dist/engine/sim/devices.d.ts +109 -0
- package/dist/engine/sim/devices.js +137 -0
- package/dist/engine/sim/devices.js.map +1 -0
- package/dist/engine/sim/elements.d.ts +49 -0
- package/dist/engine/sim/elements.js +2 -0
- package/dist/engine/sim/elements.js.map +1 -0
- package/dist/engine/sim/from-circuit.d.ts +52 -0
- package/dist/engine/sim/from-circuit.js +354 -0
- package/dist/engine/sim/from-circuit.js.map +1 -0
- package/dist/engine/sim/limits.d.ts +12 -0
- package/dist/engine/sim/limits.js +79 -0
- package/dist/engine/sim/limits.js.map +1 -0
- package/dist/engine/sim/linear.d.ts +2 -0
- package/dist/engine/sim/linear.js +49 -0
- package/dist/engine/sim/linear.js.map +1 -0
- package/dist/engine/sim/model-schema.d.ts +246 -0
- package/dist/engine/sim/model-schema.js +115 -0
- package/dist/engine/sim/model-schema.js.map +1 -0
- package/dist/engine/sim/part-models.d.ts +47 -0
- package/dist/engine/sim/part-models.js +102 -0
- package/dist/engine/sim/part-models.js.map +1 -0
- package/dist/engine/sim/run.d.ts +14 -0
- package/dist/engine/sim/run.js +13 -0
- package/dist/engine/sim/run.js.map +1 -0
- package/dist/engine/sim/solve.d.ts +42 -0
- package/dist/engine/sim/solve.js +294 -0
- package/dist/engine/sim/solve.js.map +1 -0
- package/dist/engine/sim/spice.d.ts +5 -0
- package/dist/engine/sim/spice.js +66 -0
- package/dist/engine/sim/spice.js.map +1 -0
- package/dist/engine/sim/values.d.ts +4 -0
- package/dist/engine/sim/values.js +40 -0
- package/dist/engine/sim/values.js.map +1 -0
- package/dist/engine/solid/heights.d.ts +29 -0
- package/dist/engine/solid/heights.js +87 -0
- package/dist/engine/solid/heights.js.map +1 -0
- package/dist/engine/solid/limits.d.ts +7 -0
- package/dist/engine/solid/limits.js +20 -0
- package/dist/engine/solid/limits.js.map +1 -0
- package/dist/engine/solid/model.d.ts +54 -0
- package/dist/engine/solid/model.js +147 -0
- package/dist/engine/solid/model.js.map +1 -0
- package/dist/engine/solid/step.d.ts +5 -0
- package/dist/engine/solid/step.js +164 -0
- package/dist/engine/solid/step.js.map +1 -0
- package/dist/engine/solid/thickness.d.ts +11 -0
- package/dist/engine/solid/thickness.js +10 -0
- package/dist/engine/solid/thickness.js.map +1 -0
- package/dist/library/kicad/board.d.ts +26 -0
- package/dist/library/kicad/board.js +96 -0
- package/dist/library/kicad/board.js.map +1 -0
- package/dist/library/kicad/copper.d.ts +44 -0
- package/dist/library/kicad/copper.js +106 -0
- package/dist/library/kicad/copper.js.map +1 -0
- package/dist/library/kicad/footprints.d.ts +62 -0
- package/dist/library/kicad/footprints.js +184 -0
- package/dist/library/kicad/footprints.js.map +1 -0
- package/dist/library/kicad/geometry.d.ts +36 -0
- package/dist/library/kicad/geometry.js +84 -0
- package/dist/library/kicad/geometry.js.map +1 -0
- package/dist/library/kicad/import.d.ts +58 -0
- package/dist/library/kicad/import.js +240 -0
- package/dist/library/kicad/import.js.map +1 -0
- package/dist/library/kicad/plan.d.ts +40 -0
- package/dist/library/kicad/plan.js +139 -0
- package/dist/library/kicad/plan.js.map +1 -0
- package/dist/library/kicad/read.d.ts +30 -0
- package/dist/library/kicad/read.js +105 -0
- package/dist/library/kicad/read.js.map +1 -0
- package/dist/library/kicad/sexpr.d.ts +36 -0
- package/dist/library/kicad/sexpr.js +153 -0
- package/dist/library/kicad/sexpr.js.map +1 -0
- package/dist/library/kicad/tally.d.ts +32 -0
- package/dist/library/kicad/tally.js +55 -0
- package/dist/library/kicad/tally.js.map +1 -0
- package/dist/library/kicad/write.d.ts +37 -0
- package/dist/library/kicad/write.js +146 -0
- package/dist/library/kicad/write.js.map +1 -0
- package/dist/library/new-part.d.ts +2 -0
- package/dist/library/new-part.js +1 -0
- package/dist/library/new-part.js.map +1 -1
- package/dist/mcp/board-import-tool.d.ts +1 -1
- package/dist/mcp/board-import-tool.js +14 -4
- package/dist/mcp/board-import-tool.js.map +1 -1
- package/dist/mcp/copper-summary.d.ts +2 -0
- package/dist/mcp/copper-summary.js +4 -2
- package/dist/mcp/copper-summary.js.map +1 -1
- package/dist/mcp/create-part.d.ts +23 -0
- package/dist/mcp/create-part.js +1 -0
- package/dist/mcp/create-part.js.map +1 -1
- package/dist/mcp/fast-summary.d.ts +3 -0
- package/dist/mcp/fast-summary.js +46 -0
- package/dist/mcp/fast-summary.js.map +1 -0
- package/dist/mcp/render-tool.d.ts +33 -2
- package/dist/mcp/render-tool.js +21 -5
- package/dist/mcp/render-tool.js.map +1 -1
- package/dist/mcp/server.js +18 -8
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/sheet-card-tools.d.ts +3 -1
- package/dist/mcp/sheet-card-tools.js +3 -1
- package/dist/mcp/sheet-card-tools.js.map +1 -1
- package/dist/mcp/simulate-tool.d.ts +10 -0
- package/dist/mcp/simulate-tool.js +12 -0
- package/dist/mcp/simulate-tool.js.map +1 -0
- package/dist/render/render.js +8113 -108
- package/dist/studio/change-route.d.ts +18 -0
- package/dist/studio/change-route.js +24 -0
- package/dist/studio/change-route.js.map +1 -0
- package/dist/studio/http-error.d.ts +5 -0
- package/dist/studio/http-error.js +9 -0
- package/dist/studio/http-error.js.map +1 -0
- package/dist/studio/live.d.ts +2 -0
- package/dist/studio/live.js.map +1 -1
- package/dist/studio/server.js +43 -15
- package/dist/studio/server.js.map +1 -1
- package/dist/studio/verify-routes.d.ts +42 -0
- package/dist/studio/verify-routes.js +110 -0
- package/dist/studio/verify-routes.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/library/modules/CanNode/CanNode.sheet.tsx +1 -1
- package/library/modules/CanNode/parts/MCP2515-I-SO/MCP2515_I_SO.tsx +1 -0
- package/library/modules/CanNode/parts/MCP2515-I-SO/part.yaml +2 -0
- package/library/modules/CanNode/parts/MCP2515-I-SO/verification.md +2 -1
- package/library/modules/CanNode/parts/TJA1051T-3/TJA1051T_3.tsx +1 -0
- package/library/modules/CanNode/parts/TJA1051T-3/part.yaml +2 -0
- package/library/modules/CanNode/parts/TJA1051T-3/verification.md +2 -1
- package/library/modules/DigitalInput24V/DigitalInput24V.sheet.tsx +7 -7
- package/library/modules/RelayDriver/RelayDriver.sheet.tsx +3 -3
- package/library/modules/RelayDriver/parts/AO3400A/part.yaml +34 -0
- package/library/modules/RelayDriver/parts/AO3400A/verification.md +11 -1
- package/library/modules/RelayDriver/parts/SRD-12VDC-SL-C/SRD_12VDC_SL_C.tsx +1 -0
- package/library/modules/RelayDriver/parts/SRD-12VDC-SL-C/part.yaml +14 -0
- package/library/modules/RelayDriver/parts/SRD-12VDC-SL-C/verification.md +4 -1
- package/package.json +1 -1
- package/skills/copperflow/references/copper.md +8 -0
- package/skills/copperflow/references/design-rules.md +48 -0
- package/skills/copperflow/references/modules.md +26 -0
- package/skills/copperflow/references/writing-circuits.md +3 -0
- package/dist/app/assets/NewPartDialog-C4sKWnGI.js +0 -160
- package/dist/app/assets/index-BgzJedaB.css +0 -1
- package/dist/app/assets/index-C_U9me2P.js +0 -19
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import{d as e,l as t,n,r,t as i,u as a}from"./index-DPmr2dR1.js";var o=e();function s(e,t,n){let r=e.span.max-e.span.min,i=e.terminal.max-e.terminal.min,a=e.width.max-e.width.min,o=e.span.min-2*e.terminal.max,s=e.span.max-2*e.terminal.min,c=Math.sqrt(r**2+2*i**2),l=s-(s-o-c)/2,u=e=>Math.sqrt(e**2+n.fabrication**2+n.placement**2);return{Z:e.span.min+2*t.toe+u(r),G:l-2*t.heel-u(c),X:e.width.min+2*t.side+u(a)}}function c(e,t,n){let r=s(e,t,n),i=e.span.max-e.span.min,a=e.terminal.max-e.terminal.min,o=e.span.min-2*e.terminal.max,c=e.span.max-2*e.terminal.min,l=c-(c-o-Math.sqrt(i**2+2*a**2))/2,u=Math.sqrt(i**2+n.fabrication**2+n.placement**2);return{...r,G:l-2*t.heel-u}}var l=Object.freeze({fabrication:.1,placement:.05});function u(e,t,n){return Object.freeze({goals:Object.freeze(e),roundOff:t,courtyardExcess:n})}var d=u({toe:.35,heel:0,side:0},.05,.25),f=u({toe:.2,heel:0,side:0},.02,.15),p=u({toe:.35,heel:.35,side:.03},.05,.25),m=u({toe:.35,heel:.35,side:-.02},.05,.25);function h(e){return e>.625000001?p:m}var g=u({toe:.3,heel:0,side:-.04},.05,.25),_=u({toe:.15,heel:.5,side:-.05},.05,.25),v=.15;function y(e){return(e.min+e.max)/2<1.599999999?f:d}function ee(e,t,n=p){let r=e.span.min-2*e.terminal.max,i=e.terminal.max-e.terminal.min;return r<=t+1e-9&&i<=.500000001?{...n.goals,heel:v}:{...n.goals}}var b=1e-6;function x(e,t,n){let r=e/t;return n===`up`?Math.ceil(r-b):Math.round(r+b)}function te(e,t){return x(e,t,`up`)/Math.round(1/t)}var ne=.25,re=.25;function ie(e,t){let n=Math.round(1/t),r=x(e.Z,t,`nearest`),i=x(e.G,t,`nearest`),a=x(e.X,t,`nearest`);if(i<=0||r<=i)throw Error(`land pattern has no gap between its pads (Z ${e.Z}, G ${e.G})`);return{length:(r-i)/(2*n),width:a/n,centre:(r+i)/(4*n)}}function ae(e,t){let n=ie(e,t);return[S(`1`,-n.centre,0,n.length,n.width),S(`2`,n.centre,0,n.length,n.width)]}function S(e,t,n,r,i){return{number:e,shape:`roundrect`,x:t,y:n,width:r,height:i,rotation:0,layers:`top`,cornerRadius:Math.min(re,ne*Math.min(r,i))}}var C=.15,oe=1e6;function w(e){return Math.round(e*oe)/oe+0}function se(e,t){return Array.from({length:e},(n,r)=>w((r-(e-1)/2)*t))}function ce(e){return Math.abs(e.rotation%180)===90?{x:e.height/2,y:e.width/2}:{x:e.width/2,y:e.height/2}}function T(e){return e.reduce((e,t)=>{let n=ce(t);return{x:Math.max(e.x,Math.abs(t.x)+n.x),y:Math.max(e.y,Math.abs(t.y)+n.y)}},{x:0,y:0})}function le(e,t){let n=e.map(e=>({pad:e,half:ce(e)}));return n.every((e,r)=>n.slice(r+1).every(n=>{let r=Math.abs(e.pad.x-n.pad.x)-e.half.x-n.half.x,i=Math.abs(e.pad.y-n.pad.y)-e.half.y-n.half.y;return Math.max(r,i)>=t-1e-9}))}function ue(e,t=`x`){return Math.min(...e.map(e=>Math.abs(e[t])-ce(e)[t]))}function de(e){return[{x:-e.x,y:-e.y},{x:e.x,y:-e.y},{x:e.x,y:e.y},{x:-e.x,y:e.y}]}function E(e,t,n){let r=T(e);return de({x:te(Math.max(r.x,t.x)+n.courtyardExcess,n.roundOff),y:te(Math.max(r.y,t.y)+n.courtyardExcess,n.roundOff)})}function fe(e){let t={x:w(e.x),y:w(e.y)};return[...de(t),{x:-t.x,y:-t.y}]}function pe(e){return[fe(e)]}function me(e,t){return w(Math.max(t.y,T(e).y+C))}function he(e,t){let n=me(e,t),r=w(Math.min(t.x,ue(e)));return[[{x:-r,y:n},{x:r,y:n}],[{x:-r,y:-n},{x:r,y:-n}]]}function ge(e,t){let n=ue(e)-C,r=w(n>0?n:T(e).x+C),i=me(e,t);return[{x:r,y:-i},{x:r,y:i}]}function _e(e,t){let[n,r]=he(e,t),[,i]=n;return[[{x:-w(T(e).x),y:i.y},i],r]}function ve(e,t){let n=T(e),r=w(Math.max(t.x,n.x+C)),i=w(Math.min(t.y,ue(e,`y`)));return[[{x:-r,y:-w(n.y)},{x:-r,y:i}],[{x:r,y:-i},{x:r,y:i}]]}function ye(e){let t=ce(e);return Math.abs(e.x)>Math.abs(e.y)?Math.abs(e.y)+t.y:Math.abs(e.x)+t.x}function be(e,t){let n=w(Math.max(...e.map(ye))+C),r=w(Math.max(t.x,n)),i=(e,t)=>[{x:w(e*r),y:w(t*n)},{x:w(e*r),y:w(t*r)},{x:w(e*n),y:w(t*r)}];return[[{x:-r,y:n},{x:-r,y:r}],[{x:-w(T(e).x),y:r},{x:-n,y:r}],i(1,1),i(1,-1),i(-1,-1)]}function xe(e,t,n,r,i=5){let a=Math.max(1,Math.ceil(Math.abs(r-n)/i));return Array.from({length:a+1},(i,o)=>{let s=(n+(r-n)*o/a)*Math.PI/180;return{x:w(e.x+t*Math.cos(s)),y:w(e.y+t*Math.sin(s))}})}function Se(e,t){let n=ce(t);if(t.shape===`circle`)return Math.hypot(e.x-t.x,e.y-t.y)-n.x;let r=Math.max(Math.abs(e.x-t.x)-n.x,0),i=Math.max(Math.abs(e.y-t.y)-n.y,0);return Math.hypot(r,i)}function Ce(e,t){let n=[],r=[];for(let i of e)t.every(e=>Se(i,e)>=.16999999999999998)?r.push(i):(r.length>1&&n.push(r),r=[]);return r.length>1&&n.push(r),n}var we=1;function Te(e,t){return[{x:w(e.x-we/2),y:w(t)},{x:w(e.x+we/2),y:w(t)}]}var D=e=>({refused:e}),Ee=e=>typeof e==`object`&&!!e&&`refused`in e,De=.1,O=e=>String(w(e)),Oe=e=>e.x===e.y?O(e.x):`${O(e.x)}x${O(e.y)}`;function ke(e){return Object.keys(e.params).every(e=>e===`p`)&&e.pairs===void 0}function Ae(e,t){let n=[...Object.keys(e.params),...Object.keys(e.pairs??{})].filter(e=>e!==`p`&&e!==`ep`);if(n.length>0)return D(`a ${t} takes only _p and _ep, not _${n[0]}`);let r=e.params.ep,i=e.pairs?.ep;if(r===!0)return D(`_ep needs the exposed pad's size, such as _ep3.1 or _ep1.6x2.4`);if(typeof r==`number`)return r>0?{x:r,y:r}:D(`the exposed pad needs a size above 0`);if(i)return i[0]>0&&i[1]>0?{x:i[0],y:i[1]}:D(`the exposed pad needs a size above 0`)}function je(e,t){return le(e,.1)?void 0:le(t?e.slice(0,-1):e,.1)?D(`the exposed pad would touch the pins`):D(`the pins would come closer than ${De} mm to each other`)}var Me=`ABCDEFGHJKLMNPRTUVWY`;function Ne(e){let t=``;for(let n=e+1;n>0;n=Math.floor((n-1)/20))t=Me[(n-1)%20]+t;return t}var Pe=new Map([[1.27,.75],[1,.5],[.8,.45],[.65,.35],[.5,.3],[.4,.25]]),Fe=.25,Ie=.2,Le=.05,Re={courtyardExcess:1,roundOff:.05},ze=.3,Be=1,Ve=4096,He=1e-9;function Ue(e){for(let[t,n]of Pe)if(!(Math.abs(t-e)>He))return{ball:n,land:w(Math.round(n*(1-(n>=.5499999990000001?Fe:Ie))/Le+1e-6)*Le)}}function We(e,t){if(t){let[n,r]=t;return Number.isInteger(n)&&Number.isInteger(r)&&n*r===e?{rows:n,columns:r}:D(`_rows${n}x${r} is not a full grid of ${e} balls`)}let n=Math.round(Math.sqrt(e));return n*n===e?{rows:n,columns:n}:D(`${e} balls are no square grid; give _rows<R>x<C>`)}var Ge=[...Pe.keys()].join(`, `);function Ke(e,t,n,r){let i=se(t,n);return[...se(e,n)].reverse().flatMap((e,t)=>i.map((n,i)=>({number:`${Ne(t)}${i+1}`,shape:`circle`,x:n,y:e,width:r,height:r,rotation:0,layers:`top`})))}function qe(e,t){let n=T(e),r={x:w(Math.max(t.x,n.x+C)),y:w(Math.max(t.y,n.y+C))},i=w(-r.x-ze),a=w(r.y+ze);return[fe(r),[{x:i,y:w(a-Be)},{x:i,y:a},{x:w(i+Be),y:a}]]}function Je(e){if(e.kind!==`bga`||e.variant!==void 0||e.cross!==void 0||e.suffix!==void 0)return;let t=e.size,n=e.params.p;if(!t)return D(`a BGA needs its body, such as bga256_17x17_p1`);if(typeof n!=`number`)return D(`a BGA needs its pitch, such as _p1`);let r=[...Object.keys(e.params),...Object.keys(e.pairs??{})].find(e=>e!==`p`&&e!==`rows`);if(r!==void 0)return D(`a BGA takes only _p and _rows, not _${r}`);let i=Number(e.code);if(!Number.isInteger(i)||i<1||i>Ve)return D(`a BGA has 1 to ${Ve} balls`);let a=Ue(n);if(!a)return D(`BGA pitch must be one of ${Ge} mm`);let o=We(i,e.pairs?.rows);if(Ee(o))return o;let[s,c]=t,l=(e,t)=>(e-1)*n+a.land<=t+He;if(!l(o.columns,s)||!l(o.rows,c))return D(`a ${o.rows}×${o.columns} grid at ${O(n)} mm does not fit the body`);let u=Ke(o.rows,o.columns,n,a.land),d={x:s/2,y:c/2},f=o.rows===o.columns;return{name:`bga${i}_${O(s)}x${O(c)}_p${O(n)}${f?``:`_rows${o.rows}x${o.columns}`}`,pads:u,courtyard:E(u,d,Re),silkscreen:qe(u,d),fabrication:[fe(d)],origin:`IPC-7351B nominal, BGA-${i} ${O(s)}×${O(c)} mm, ${O(n)} mm pitch, ${o.rows}×${o.columns} grid, ${O(a.ball)} mm balls on ${O(a.land)} mm lands`}}function k(e,t){let n=e=>Math.round(e*1e6)/1e6;return{min:n(e-t),max:n(e+t)}}var Ye={"0201":{length:k(.6,.03),width:k(.3,.03),terminal:k(.15,.05)},"0402":{length:k(1,.05),width:k(.5,.05),terminal:k(.3,.1)},"0603":{length:k(1.6,.15),width:k(.8,.15),terminal:k(.35,.15)},"0805":{length:k(2,.2),width:k(1.25,.2),terminal:k(.5,.25)},1206:{length:k(3.2,.2),width:k(1.6,.2),terminal:k(.5,.25)},1210:{length:k(3.2,.2),width:k(2.5,.2),terminal:k(.5,.25)},1812:{length:k(4.5,.3),width:k(3.2,.3),terminal:k(.6,.35)}},Xe={2010:{length:k(5,.15),width:k(2.5,.15),terminal:k(.6,.2)},2512:{length:k(6.3,.2),width:k(3.15,.15),terminal:k(.6,.2)}},Ze={...Ye,...Xe};function Qe(e){if(!Object.hasOwn(Ze,e))return;let t=Ze[e],n={span:t.length,terminal:t.terminal,width:t.width},r=y(t.length),i=ae(s(n,r.goals,l),r.roundOff),a={x:t.length.max/2,y:t.width.max/2};return{name:e,pads:i,courtyard:E(i,a,r),silkscreen:he(i,a),fabrication:pe(a),origin:`IPC-7351B nominal, EIA ${e}`}}var A=(e,t)=>({min:e,max:t});function $e(e){return{span:e.span,terminal:e.terminal,width:e.leadWidth}}function et(e){let t=h(e.pitch),n=ee($e(e),e.bodyAcross.max,t);return{row:ie(c($e(e),n,l),t.roundOff),table:t}}function tt(e){return{row:ie(s($e(e),g.goals,l),g.roundOff),table:g}}var nt=1e-6,rt=e=>(e.min+e.max)/2;function it(e,t,n=[]){return Object.entries(e).every(([e,r])=>e===`p`?r!==!0&&Math.abs(r-t.pitch)<nt:e===`w`?r!==!0&&Math.abs(r-rt(t.span))<nt:n.includes(e)&&r===!0)}var at=.2,ot=.05,st=.5,ct=.05,lt={courtyardExcess:.25,roundOff:ct};function ut(e,t){return t?Math.hypot(e.max,t.max):e.max}function dt(e){let t=te(e+at,ct);return{drill:t,pad:te(t+2*ot+st,ct)}}function ft(e,t,n,r,i=!1){return{number:e,shape:i?`rect`:`circle`,x:t,y:n,width:r.pad,height:r.pad,rotation:0,layers:`through`,drill:{width:r.drill,height:r.drill}}}var pt=4.88,mt=A(.4,.46),ht=11.05,gt=4.65,_t=.2,vt=new Map([[void 0,`HC-49/U`],[`s`,`HC-49/S`]]);function yt(){let e=gt/2,t=xe({x:ht/2-e,y:0},e,-90,90,10),n=xe({x:-3.2,y:0},e,90,270,10);return[...t,...n,t[0]]}function bt(e){let t=e.kind===`hc`&&e.code===`49`?vt.get(e.suffix):void 0,n=e.cross===void 0&&e.size===void 0&&e.pairs===void 0&&e.variant===void 0;if(!t||!n||Object.keys(e.params).length>0)return;let r=dt(ut(mt)),i=[ft(`1`,-4.88/2,0,r,!0),ft(`2`,pt/2,0,r)],a=yt(),o=w(-(T(i).y+C+_t));return{name:`hc49${e.suffix??``}`,pads:i,courtyard:E(i,{x:ht/2,y:gt/2},lt),silkscreen:[a,Te(i[0],o)],fabrication:[a],origin:`Through-hole, ${t} crystal: ${r.drill} mm holes, ${r.pad} mm lands (IPC-2222 level B)`}}var xt=(e,t)=>Array.from({length:(t-e)/2+1},(t,n)=>e+2*n),St=[{kind:`soic`,suffix:``,label:e=>`SOIC-${e}`,pins:xt(8,16),lead:{pitch:1.27,span:A(5.8,6.2),terminal:A(.41,1.27),leadWidth:A(.33,.51),bodyAcross:A(3.8,4)},bodyLength:new Map([[8,A(4.8,5)],[14,A(8.55,8.75)],[16,A(9.8,10)]]),overhang:.53,bodyTolerance:.1},{kind:`soic`,suffix:`w`,label:e=>`SOIC-${e} wide`,pins:[16,18,20,24,28],lead:{pitch:1.27,span:A(10,10.65),terminal:A(.4,1.27),leadWidth:A(.31,.51),bodyAcross:A(7.4,7.6)},bodyLength:new Map([[16,A(10.1,10.5)],[18,A(11.35,11.75)],[20,A(12.6,13)],[24,A(15.2,15.6)],[28,A(17.7,18.1)]]),overhang:.6,bodyTolerance:.2},{kind:`sop`,suffix:``,label:e=>`SOP-${e}`,pins:xt(8,16),lead:{pitch:1.27,span:A(7.7,8.1),terminal:A(.51,.8),leadWidth:A(.36,.48),bodyAcross:A(5.18,5.38)},bodyLength:new Map([[8,A(5.18,5.33)]]),overhang:.72,bodyTolerance:.08},{kind:`ssop`,suffix:``,label:e=>`SSOP-${e}`,pins:[14,16,20,24,28],lead:{pitch:.65,span:A(7.4,8.2),terminal:A(.55,.95),leadWidth:A(.22,.38),bodyAcross:A(5,5.6)},bodyLength:new Map([[14,A(5.9,6.5)],[16,A(5.9,6.5)],[20,A(6.9,7.5)],[24,A(7.9,8.5)],[28,A(9.9,10.5)]]),overhang:.7,bodyTolerance:.3},{kind:`tssop`,suffix:``,label:e=>`TSSOP-${e}`,pins:xt(8,28),lead:{pitch:.65,span:A(6.2,6.6),terminal:A(.45,.75),leadWidth:A(.19,.3),bodyAcross:A(4.3,4.5)},bodyLength:new Map([[8,A(2.9,3.1)],[14,A(4.9,5.1)],[16,A(4.9,5.1)],[20,A(6.4,6.6)],[24,A(7.7,7.9)],[28,A(9.6,9.8)]]),overhang:.6,bodyTolerance:.1}],Ct=St.map(e=>({form:`${e.kind}<N>${e.suffix}`,pins:e.pins}));function wt(e,t){let n=e.bodyLength.get(t),r=(t/2-1)*e.lead.pitch+2*e.overhang,i=n??A(r-e.bodyTolerance,r+e.bodyTolerance);return{...e.lead,label:e.label(t),bodyAlong:i}}function Tt(e,t,n){let r=se(e/2,t),i=[...r].reverse().map((e,t)=>S(String(t+1),-n.centre,e,n.length,n.width)),a=r.map((t,r)=>S(String(e/2+r+1),n.centre,t,n.length,n.width));return[...i,...a]}function Et(e,t){if(e.cross!==void 0||e.size!==void 0||e.pairs!==void 0||e.variant!==void 0)return;let n=Number(e.code);return String(n)===e.code&&t.pins.includes(n)?n:void 0}function Dt(e){let t=St.find(t=>t.kind===e.kind&&t.suffix===(e.suffix??``)),n=t&&Et(e,t);if(!t||n===void 0)return;let r=wt(t,n);if(!it(e.params,r))return;let{row:i,table:a}=et(r),o=Tt(n,r.pitch,i),s={x:r.bodyAcross.max/2,y:r.bodyAlong.max/2},c=(n/2-1)/2*r.pitch+r.leadWidth.max/2,l={x:r.span.max/2,y:Math.max(s.y,c)};return{name:`${e.kind}${e.code}${t.suffix}`,pads:o,courtyard:E(o,l,a),silkscreen:_e(o,s),fabrication:pe(s),origin:`IPC-7351B nominal, ${r.label}`}}var Ot=.1,kt=A(.3,.5),At=new Map([[.4,A(.15,.25)],[.5,A(.18,.3)],[.65,A(.25,.35)]]),jt=A(.45,.75),Mt=new Map([[.4,A(.13,.23)],[.5,A(.17,.27)],[.65,A(.22,.38)],[.8,A(.3,.4)]]),Nt=2,Pt=.15,Ft=.25,It=1024,Lt=1,Rt=60,zt=1e-9,Bt=(e,t)=>A(Vt(e-t),Vt(e+t)),Vt=e=>Math.round(e*1e6)/1e6;function Ht(e,t){for(let[n,r]of e)if(Math.abs(n-t)<zt)return r}function Ut(e,t,n){let r=Number(e);return!Number.isInteger(r)||r<=0||r>It?D(`a ${n} has 1 to ${It} pins`):r%t===0?r:D(`a ${n} has a pin count divisible by ${t}`)}var Wt=e=>{let t=[...e.keys()].map(String);return`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]} mm`};function Gt(e,t){return t.every(e=>e>=Lt&&e<=Rt)?void 0:D(`a ${e} body is ${Lt} to ${Rt} mm`)}function Kt(e,t,n,r){return(e-1)*t+n.max<=r+zt?void 0:D(`${e} pins a side at ${t} mm do not fit a ${r} mm side`)}function qt(...e){for(let t of e){let e=t();if(e)return e}}function Jt(e,t,n,r,i){let a=Ut(t,4,e);if(Ee(a))return a;let o=Ht(i,r);if(!o)return D(`${e} pitch must be ${Wt(i)}`);let[s,c]=n;return qt(()=>Math.abs(s-c)>zt?D(`${e} bodies must be square`):void 0,()=>Gt(e,n),()=>Kt(a/4,r,o,s))??{pins:a,side:s,width:o}}function Yt(e,t,n){let r=Jt(`QFN`,e,t,n,At);if(Ee(r))return r;let{pins:i,side:a,width:o}=r,s=Bt(a,Ot);return{label:`QFN-${i} ${a}×${a} mm, ${n} mm pitch`,pitch:n,span:s,terminal:kt,leadWidth:o,bodyAcross:s,bodyAlong:s}}function Xt(e,t,n){let r=Ut(e,2,`DFN`);if(Ee(r))return r;let i=Ht(At,n);if(!i)return D(`DFN pitch must be ${Wt(At)}`);let[a,o]=t,s=qt(()=>Gt(`DFN`,t),()=>Kt(r/2,n,i,o));if(s)return s;let c=Bt(a,Ot);return{label:`DFN-${r} ${a}×${o} mm, ${n} mm pitch`,pitch:n,span:c,terminal:kt,leadWidth:i,bodyAcross:c,bodyAlong:Bt(o,Ot)}}function Zt(e,t,n){let r=Jt(`QFP`,e,t,n,Mt);if(Ee(r))return r;let{pins:i,side:a,width:o}=r,s=a<=10.000000001?Pt:Ft,c=Bt(a,Ot);return{label:`LQFP-${i} ${a}×${a} mm, ${n} mm pitch`,pitch:n,span:Bt(a+Nt,s),terminal:jt,leadWidth:o,bodyAcross:c,bodyAlong:c}}function Qt(e){if(e.kind!==`dfn`||e.variant!==void 0||e.cross!==void 0||e.suffix!==void 0)return;let t=e.size,n=e.params.p;if(!t)return D(`a DFN needs its body, such as dfn8_3x3_p0.65`);if(typeof n!=`number`)return D(`a DFN needs its pitch, such as _p0.65`);let r=Xt(e.code,t,n);if(Ee(r))return r;let i=Ae(e,`DFN`);if(Ee(i))return i;let a=Number(e.code),{row:o,table:s}=tt(r),c=Tt(a,n,o),l=i?[...c,S(String(a+1),0,0,i.x,i.y)]:c,u=je(l,i!==void 0);if(u)return u;let d={x:r.bodyAcross.max/2,y:r.bodyAlong.max/2};return{name:`dfn${a}_${O(t[0])}x${O(t[1])}_p${O(n)}${i?`_ep${Oe(i)}`:``}`,pads:l,courtyard:E(l,d,s),silkscreen:_e(c,d),fabrication:pe(d),origin:`IPC-7351B nominal, ${r.label}${i?` with exposed pad`:``}`}}var $t=2.54,en=A(.36,.56),tn=A(.2,.36),nn=1.27,rn=7.62,an=64,on=.75;function sn(e,t){let n=dt(ut(en,tn)),r=se(e/2,$t),i=[...r].reverse().map((e,r)=>ft(String(r+1),w(-t/2),e,n,r===0)),a=r.map((r,i)=>ft(String(e/2+i+1),w(t/2),r,n));return[...i,...a]}function cn(e,t){let n=Math.min(...e.map(e=>Math.abs(e.x)-e.width/2)),r=w(Math.min(t.x,n-C)),i=w(Math.max(t.y,T(e).y+C)),a=xe({x:0,y:i},on,0,-180,15);return[[{x:-.75,y:i},{x:-r,y:i},{x:-r,y:-i},{x:r,y:-i},{x:r,y:i},...a]]}function ln(e){if(e.kind!==`dip`||!i(e)||e.variant!==void 0)return;let t=Object.keys(e.params).find(e=>e!==`w`);if(t!==void 0)return D(`a DIP takes only _w, not _${t}`);let n=Number(e.code),r=e.params.w??7.62;if(!Number.isInteger(n)||n<4||n>an||n%2!=0)return D(`a DIP has an even pin count from 4 to ${an}`);if(r===!0||r<7.619999999)return D(`DIP rows are at least ${rn} mm apart`);let a=sn(n,r),o={x:(r-nn)/2,y:n/2*($t/2)},s=a[0];return{name:Math.abs(r-7.62)<1e-9?`dip${n}`:`dip${n}_w${O(r)}`,pads:a,courtyard:E(a,o,lt),silkscreen:cn(a,o),fabrication:pe(o),origin:`Through-hole, DIP-${n} with rows ${O(r)} mm apart: ${O(s.drill?.width??0)} mm holes, ${O(s.width)} mm lands (IPC-2222 level B)`}}var un=Symbol.for(`yaml.alias`),dn=Symbol.for(`yaml.document`),fn=Symbol.for(`yaml.map`),pn=Symbol.for(`yaml.pair`),mn=Symbol.for(`yaml.scalar`),hn=Symbol.for(`yaml.seq`),j=Symbol.for(`yaml.node.type`),gn=e=>!!e&&typeof e==`object`&&e[j]===un,_n=e=>!!e&&typeof e==`object`&&e[j]===dn,vn=e=>!!e&&typeof e==`object`&&e[j]===fn,M=e=>!!e&&typeof e==`object`&&e[j]===pn,N=e=>!!e&&typeof e==`object`&&e[j]===mn,yn=e=>!!e&&typeof e==`object`&&e[j]===hn;function P(e){if(e&&typeof e==`object`)switch(e[j]){case fn:case hn:return!0}return!1}function F(e){if(e&&typeof e==`object`)switch(e[j]){case un:case fn:case mn:case hn:return!0}return!1}var bn=e=>(N(e)||P(e))&&!!e.anchor,xn=Symbol(`break visit`),Sn=Symbol(`skip children`),Cn=Symbol(`remove node`);function wn(e,t){let n=En(t);_n(e)?Tn(null,e.contents,n,Object.freeze([e]))===Cn&&(e.contents=null):Tn(null,e,n,Object.freeze([]))}wn.BREAK=xn,wn.SKIP=Sn,wn.REMOVE=Cn;function Tn(e,t,n,r){let i=Dn(e,t,n,r);if(F(i)||M(i))return On(e,r,i),Tn(e,i,n,r);if(typeof i!=`symbol`){if(P(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=Tn(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===xn)return xn;else i===Cn&&(t.items.splice(e,1),--e)}}else if(M(t)){r=Object.freeze(r.concat(t));let e=Tn(`key`,t.key,n,r);if(e===xn)return xn;e===Cn&&(t.key=null);let i=Tn(`value`,t.value,n,r);if(i===xn)return xn;i===Cn&&(t.value=null)}}return i}function En(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Dn(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(vn(t))return n.Map?.(e,t,r);if(yn(t))return n.Seq?.(e,t,r);if(M(t))return n.Pair?.(e,t,r);if(N(t))return n.Scalar?.(e,t,r);if(gn(t))return n.Alias?.(e,t,r)}function On(e,t,n){let r=t[t.length-1];if(P(r))r.items[e]=n;else if(M(r))e===`key`?r.key=n:r.value=n;else if(_n(r))r.contents=n;else{let e=gn(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var kn={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},An=e=>e.replace(/[!,[\]{}]/g,e=>kn[e]),jn=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+An(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&F(e.contents)){let t={};wn(e.contents,(e,n)=>{F(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||e&&!r.some(e=>e.startsWith(a))||t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
2
|
+
`)}};jn.defaultYaml={explicit:!1,version:`1.2`},jn.defaultTags={"!!":`tag:yaml.org,2002:`};function Mn(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Nn(e){let t=new Set;return wn(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function Pn(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function Fn(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=Nn(e);let a=Pn(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(N(t.node)||P(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function In(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=In(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=In(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=In(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=In(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function I(e,t,n){if(Array.isArray(e))return e.map((e,t)=>I(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!bn(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var Ln=class{constructor(e){Object.defineProperty(this,j,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!_n(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=I(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?In(i,{"":o},``,o):o}},Rn=class extends Ln{constructor(e){super(un),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],wn(e,{Node:(e,t)=>{(gn(t)||bn(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(I(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=zn(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(Mn(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function zn(e,t,n){if(gn(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(P(t)){let r=0;for(let i of t.items){let t=zn(e,i,n);t>r&&(r=t)}return r}if(M(t)){let r=zn(e,t.key,n),i=zn(e,t.value,n);return Math.max(r,i)}return 1}var Bn=e=>!e||typeof e!=`function`&&typeof e!=`object`,L=class extends Ln{constructor(e){super(mn),this.value=e}toJSON(e,t){return t?.keep?this.value:I(this.value,e,t)}toString(){return String(this.value)}};L.BLOCK_FOLDED=`BLOCK_FOLDED`,L.BLOCK_LITERAL=`BLOCK_LITERAL`,L.PLAIN=`PLAIN`,L.QUOTE_DOUBLE=`QUOTE_DOUBLE`,L.QUOTE_SINGLE=`QUOTE_SINGLE`;var Vn=`tag:yaml.org,2002:`;function Hn(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Un(e,t,n){if(_n(e)&&(e=e.contents),F(e))return e;if(M(e)){let t=n.schema[fn].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new Rn(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=Vn+t.slice(2));let l=Hn(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new L(e);return c&&(c.node=t),t}l=e instanceof Map?o[fn]:Symbol.iterator in Object(e)?o[hn]:o[fn]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new L(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Wn(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return Un(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var Gn=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,Kn=class extends Ln{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>F(t)||M(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Gn(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(P(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Wn(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(P(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&N(i)?i.value:i:P(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!M(t))return!1;let n=t.value;return n==null||e&&N(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return P(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(P(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Wn(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},qn=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function Jn(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Yn=(e,t,n)=>e.endsWith(`
|
|
3
|
+
`)?Jn(n,t):n.includes(`
|
|
4
|
+
`)?`
|
|
5
|
+
`+Jn(n,t):(e.endsWith(` `)?``:` `)+n,Xn=`flow`,Zn=`block`,Qn=`quoted`;function $n(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=er(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
|
|
6
|
+
`)n===`block`&&(h=er(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
|
|
7
|
+
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
|
|
8
|
+
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function er(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
9
|
+
`);r=t,i=t+1,a=e[i]}return r}var tr=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),nr=e=>/^(%|---|\.\.\.)/m.test(e);function rr(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
10
|
+
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function ir(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(nr(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
|
|
11
|
+
|
|
12
|
+
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
|
|
13
|
+
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:$n(o,a,Qn,tr(t,!1))}function ar(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
14
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return ir(e,t);let n=t.indent||(nr(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:$n(r,n,Xn,tr(t,!1))}function or(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=ir;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?ar:i&&!t?ir:n?ar:ir}return r(e,t)}var sr;try{sr=RegExp(`(^|(?<!
|
|
15
|
+
))
|
|
16
|
+
+(?!
|
|
17
|
+
|$)`,`g`)}catch{sr=/\n+(?!\n|$)/g}function cr({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return or(n,r);let l=r.indent||(r.forceBlockIndent||nr(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===L.BLOCK_FOLDED?!1:t===L.BLOCK_LITERAL||!rr(n,c,l.length);if(!n)return u?`|
|
|
18
|
+
`:`>
|
|
19
|
+
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
|
|
20
|
+
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
|
|
21
|
+
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
22
|
+
`&&(p=p.slice(0,-1)),p.replace(sr,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
|
|
23
|
+
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
|
|
24
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=tr(r,!0);o!==`folded`&&t!==L.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=$n(`${v}${e}${p}`,l,Zn,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function lr(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
|
|
25
|
+
`)||u&&/[[\]{},]/.test(a))return or(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
|
|
26
|
+
`)?or(a,t):cr(e,t,n,r);if(!s&&!u&&i!==L.PLAIN&&a.includes(`
|
|
27
|
+
`))return cr(e,t,n,r);if(nr(a)){if(c===``)return t.forceBlockIndent=!0,cr(e,t,n,r);if(s&&c===l)return or(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return or(a,t)}return s?d:$n(d,c,Xn,tr(t,!1))}function ur(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==L.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=L.QUOTE_DOUBLE);let c=e=>{switch(e){case L.BLOCK_FOLDED:case L.BLOCK_LITERAL:return i||a?or(o.value,t):cr(o,t,n,r);case L.QUOTE_DOUBLE:return ir(o.value,t);case L.QUOTE_SINGLE:return ar(o.value,t);case L.PLAIN:return lr(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function dr(e,t){let n=Object.assign({blockQuote:!0,commentString:qn,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function fr(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(N(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function pr(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(N(e)||P(e))&&e.anchor;a&&Mn(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function mr(e,t,n,r){if(M(e))return e.toString(t,n,r);if(gn(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=F(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=fr(t.doc.schema.tags,a);let o=pr(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):N(a)?ur(a,t,n,r):a.toString(t,n,r);return o?N(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function hr({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=F(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(P(e)||!F(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||P(e)||(N(e)?e.type===L.BLOCK_FOLDED||e.type===L.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=mr(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Yn(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Yn(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Yn(g,n.indent,l(f))));let _,v,y;F(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&N(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&yn(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let ee=!1,b=mr(t,n,()=>ee=!0,()=>h=!0),x=` `;if(f||_||v){if(x=_?`
|
|
28
|
+
`:``,v){let e=l(v);x+=`\n${Jn(e,n.indent)}`}b===``&&!n.inFlow?x===`
|
|
29
|
+
`&&y&&(x=`
|
|
30
|
+
|
|
31
|
+
`):x+=`\n${n.indent}`}else if(!p&&P(t)){let e=b[0],r=b.indexOf(`
|
|
32
|
+
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=b.indexOf(` `);e===`&`&&n!==-1&&n<r&&b[n+1]===`!`&&(n=b.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(x=`\n${n.indent}`)}}else(b===``||b[0]===`
|
|
33
|
+
`)&&(x=``);return g+=x+b,n.inFlow?ee&&r&&r():y&&!ee?g+=Yn(g,n.indent,l(y)):h&&i&&i(),g}function gr(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var _r=`<<`,vr={identify:e=>e===_r||typeof e==`symbol`&&e.description===_r,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new L(Symbol(_r)),{addToJSMap:br}),stringify:()=>_r},yr=(e,t)=>(vr.identify(t)||N(t)&&(!t.type||t.type===L.PLAIN)&&vr.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===vr.tag&&e.default);function br(e,t,n){let r=Sr(e,n);if(yn(r))for(let n of r.items)xr(e,t,n);else if(Array.isArray(r))for(let n of r)xr(e,t,n);else xr(e,t,r)}function xr(e,t,n){let r=Sr(e,n);if(!vn(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function Sr(e,t){return e&&gn(t)?t.resolve(e.doc,e):t}function Cr(e,t,{key:n,value:r}){if(F(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(yr(e,n))br(e,t,r);else{let i=I(n,``,e);if(t instanceof Map)t.set(i,I(r,i,e));else if(t instanceof Set)t.add(i);else{let a=wr(n,i,e),o=I(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function wr(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(F(e)&&n?.doc){let t=dr(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),gr(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function Tr(e,t,n){return new R(Un(e,void 0,n),Un(t,void 0,n))}var R=class e{constructor(e,t=null){Object.defineProperty(this,j,{value:pn}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return F(n)&&(n=n.clone(t)),F(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return Cr(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?hr(this,e,t,n):JSON.stringify(this)}};function Er(e,t,n){return(t.inFlow??e.flow?Or:Dr)(e,t,n)}function Dr({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(F(i))!d&&i.spaceBefore&&f.push(``),kr(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(M(i)){let e=F(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),kr(n,f,e.commentBefore,d))}d=!1;let s=mr(i,u,()=>o=null,()=>d=!0);o&&(s+=Yn(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
|
|
34
|
+
`}}return e?(p+=`
|
|
35
|
+
`+Jn(l(e),c),s&&s()):d&&o&&o(),p}function Or({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(F(i))i.spaceBefore&&d.push(``),kr(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(M(i)){let e=F(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),kr(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=F(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=mr(i,c,()=>a=null);l||=d.length>u||o.includes(`
|
|
36
|
+
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=Yn(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
|
|
37
|
+
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function kr({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=Jn(t(r),e);n.push(i.trimStart())}}function Ar(e,t){let n=N(t)?t.value:t;for(let r of e)if(M(r)&&(r.key===t||r.key===n||N(r.key)&&r.key.value===n))return r}var z=class extends Kn{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(fn,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Tr(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=M(e)?e:!e||typeof e!=`object`||!(`key`in e)?new R(e,e?.value):new R(e.key,e.value);let r=Ar(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);N(r.value)&&Bn(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=Ar(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=Ar(this.items,e)?.value;return(!t&&N(n)?n.value:n)??void 0}has(e){return!!Ar(this.items,e)}set(e,t){this.add(new R(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)Cr(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!M(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Er(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},jr={collection:`map`,default:!0,nodeClass:z,tag:`tag:yaml.org,2002:map`,resolve(e,t){return vn(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>z.from(e,t,n)},Mr=class extends Kn{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(hn,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Nr(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=Nr(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&N(r)?r.value:r}has(e){let t=Nr(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=Nr(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];N(r)&&Bn(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(I(e,String(r++),t));return n}toString(e,t,n){return e?Er(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(Un(a,void 0,n))}}return i}};function Nr(e){let t=N(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var Pr={collection:`seq`,default:!0,nodeClass:Mr,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return yn(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Mr.from(e,t,n)},Fr={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),ur(e,t,n,r)}},Ir={identify:e=>e==null,createNode:()=>new L(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new L(null),stringify:({source:e},t)=>typeof e==`string`&&Ir.test.test(e)?e:t.options.nullStr},Lr={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new L(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&Lr.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function Rr({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var zr={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:Rr},Br={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Rr(e)}},Vr={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new L(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:Rr},Hr=e=>typeof e==`bigint`||Number.isInteger(e),Ur=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function Wr(e,t,n){let{value:r}=e;return Hr(r)&&r>=0?n+r.toString(t):Rr(e)}var Gr={identify:e=>Hr(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>Ur(e,2,8,n),stringify:e=>Wr(e,8,`0o`)},Kr={identify:Hr,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Ur(e,0,10,n),stringify:Rr},qr={identify:e=>Hr(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Ur(e,2,16,n),stringify:e=>Wr(e,16,`0x`)},Jr=[jr,Pr,Fr,Ir,Lr,Gr,Kr,qr,zr,Br,Vr];function Yr(e){return typeof e==`bigint`||Number.isInteger(e)}var Xr=({value:e})=>JSON.stringify(e),Zr=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:Xr},{identify:e=>e==null,createNode:()=>new L(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:Xr},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:Xr},{identify:Yr,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Yr(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Xr}],Qr=[jr,Pr].concat(Zr,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),$r={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){if(!n)return``;let o=n,s;if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t??=L.BLOCK_LITERAL,t!==L.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===L.BLOCK_LITERAL?`
|
|
38
|
+
`:` `)}return ur({comment:e,type:t,value:s},r,i,a)}};function ei(e,t){if(yn(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!M(r)){if(vn(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new R(new L(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=M(r)?r:new R(r)}}else t(`Expected a sequence for this tag`);return e}function ti(e,t,n){let{replacer:r}=n,i=new Mr(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Tr(o,s,n))}return i}var ni={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:ei,createNode:ti},ri=class e extends Mr{constructor(){super(),this.add=z.prototype.add.bind(this),this.delete=z.prototype.delete.bind(this),this.get=z.prototype.get.bind(this),this.has=z.prototype.has.bind(this),this.set=z.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(M(e)?(r=I(e.key,``,t),i=I(e.value,r,t)):r=I(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=ti(e,t,n),i=new this;return i.items=r.items,i}};ri.tag=`tag:yaml.org,2002:omap`;var ii={collection:`seq`,identify:e=>e instanceof Map,nodeClass:ri,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=ei(e,t),r=[];for(let{key:e}of n.items)N(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new ri,n)},createNode:(e,t,n)=>ri.from(e,t,n)};function ai({value:e,source:t},n){return t&&(e?oi:si).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var oi={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new L(!0),stringify:ai},si={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new L(!1),stringify:ai},ci={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:Rr},li={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Rr(e)}},ui={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new L(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:Rr},di=e=>typeof e==`bigint`||Number.isInteger(e);function fi(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function pi(e,t,n){let{value:r}=e;if(di(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return Rr(e)}var mi={identify:di,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>fi(e,2,2,n),stringify:e=>pi(e,2,`0b`)},hi={identify:di,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>fi(e,1,8,n),stringify:e=>pi(e,8,`0`)},gi={identify:di,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>fi(e,0,10,n),stringify:Rr},_i={identify:di,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>fi(e,2,16,n),stringify:e=>pi(e,16,`0x`)},vi=class e extends z{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=M(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new R(e.key,null):new R(e,null),Ar(this.items,t.key)||this.items.push(t)}get(e,t){let n=Ar(this.items,e);return!t&&M(n)?N(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Ar(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new R(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Tr(e,null,n));return i}};vi.tag=`tag:yaml.org,2002:set`;var yi={collection:`map`,identify:e=>e instanceof Set,nodeClass:vi,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>vi.from(e,t,n),resolve(e,t){if(vn(e)){if(e.hasAllNullValues(!0))return Object.assign(new vi,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function bi(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function xi(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return Rr(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var Si={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>bi(e,n),stringify:xi},Ci={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>bi(e,!1),stringify:xi},wi={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(wi.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=bi(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``},Ti=[jr,Pr,Fr,Ir,oi,si,mi,hi,gi,_i,ci,li,ui,$r,vr,ii,ni,yi,Si,Ci,wi],Ei=new Map([[`core`,Jr],[`failsafe`,[jr,Pr,Fr]],[`json`,Qr],[`yaml11`,Ti],[`yaml-1.1`,Ti]]),Di={binary:$r,bool:Lr,float:Vr,floatExp:Br,floatNaN:zr,floatTime:Ci,int:Kr,intHex:qr,intOct:Gr,intTime:Si,map:jr,merge:vr,null:Ir,omap:ii,pairs:ni,seq:Pr,set:yi,timestamp:wi},Oi={"tag:yaml.org,2002:binary":$r,"tag:yaml.org,2002:merge":vr,"tag:yaml.org,2002:omap":ii,"tag:yaml.org,2002:pairs":ni,"tag:yaml.org,2002:set":yi,"tag:yaml.org,2002:timestamp":wi};function ki(e,t,n){let r=Ei.get(t);if(r&&!e)return n&&!r.includes(vr)?r.concat(vr):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(Ei.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(vr)),i.reduce((e,t)=>{let n=typeof t==`string`?Di[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(Di).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}var Ai=(e,t)=>e.key<t.key?-1:+(e.key>t.key),ji=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?ki(e,`compat`):e?ki(null,e):null,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?Oi:{},this.tags=ki(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,fn,{value:jr}),Object.defineProperty(this,mn,{value:Fr}),Object.defineProperty(this,hn,{value:Pr}),this.sortMapEntries=typeof a==`function`?a:a===!0?Ai:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function Mi(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=dr(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(Jn(t,``))}let o=!1,s=null;if(e.contents){if(F(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(Jn(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=mr(e.contents,i,()=>s=null,t);s&&(c+=Yn(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(mr(e.contents,i));if(e.directives?.docEnd){if(e.comment){let t=a(e.comment);t.includes(`
|
|
39
|
+
`)?(n.push(`...`),n.push(Jn(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(Jn(a(t),``)))}return n.join(`
|
|
40
|
+
`)+`
|
|
41
|
+
`}var Ni=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,j,{value:dn});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new jn({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[j]:{value:dn}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=F(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){Pi(this.contents)&&this.contents.add(e)}addIn(e,t){Pi(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=Nn(this);e.anchor=!t||n.has(t)?Pn(t||`a`,n):t}return new Rn(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=Fn(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Un(e,l,p);return o&&P(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new R(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return Pi(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Gn(e)?this.contents!=null&&(this.contents=null,!0):Pi(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return P(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Gn(e)?!t&&N(this.contents)?this.contents.value:this.contents:P(this.contents)?this.contents.getIn(e,t):void 0}has(e){return P(this.contents)?this.contents.has(e):!1}hasIn(e){return Gn(e)?this.contents!==void 0:P(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Wn(this.schema,[e],t):Pi(this.contents)&&this.contents.set(e,t)}setIn(e,t){Gn(e)?this.contents=t:this.contents==null?this.contents=Wn(this.schema,Array.from(e),t):Pi(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new jn({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new jn({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new ji(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=I(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?In(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return Mi(this,e)}};function Pi(e){if(P(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var Fi=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},Ii=class extends Fi{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},Li=class extends Fi{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},Ri=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
|
|
42
|
+
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function zi(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,ee=null,b=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:ee&&n===`seq-item-ind`||(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,b??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,b??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),ee&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),ee=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let x=e[e.length-1],te=x?x.offset+x.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:ee,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:te,start:b??te}}function Bi(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
|
|
43
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(Bi(t.key)||Bi(t.value))return!0}return!1;default:return!0}}function Vi(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&Bi(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function Hi(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||N(e)&&N(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var Ui=`All mapping items must start at the same column`;function Wi({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??z)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=zi(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,Ui)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
|
|
44
|
+
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||Bi(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,Ui);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&Vi(r.indent,u,i),n.atKey=!1,Hi(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=zi(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&Vi(r.indent,f,i),s=c.range[2];let l=new R(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
|
|
45
|
+
`+_.comment:g.comment=_.comment);let e=new R(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function Gi({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??Mr)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=zi(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&Vi(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function Ki(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var qi=`Block collections are not allowed within flow collections`,Ji=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function Yi({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?z:Mr))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=zi(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
|
|
46
|
+
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&Bi(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];M(t)&&(t=t.value??t.key),t.comment?t.comment+=`
|
|
47
|
+
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],Ji(m)&&i(r.range,`BLOCK_IN_FLOW`,qi)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);Ji(f)&&i(g.range,`BLOCK_IN_FLOW`,qi),n.atKey=!1;let _=zi(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?Ji(m)&&i(v.range,`BLOCK_IN_FLOW`,qi):_.comment&&(g.comment?g.comment+=`
|
|
48
|
+
`+_.comment:g.comment=_.comment);let y=new R(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;Hi(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new z(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=Ki(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
|
|
49
|
+
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function Xi(e,t,n,r,i,a){let o=n.type===`block-map`?Wi(e,t,n,r,a):n.type===`block-seq`?Gi(e,t,n,r,a):Yi(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function Zi(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===z.tagName&&s===`map`||o===Mr.tagName&&s===`seq`)return Xi(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),Xi(e,t,n,i,o)}let l=Xi(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=F(u)?u:new L(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function Qi(e,t,n){let r=t.offset,i=$i(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?L.BLOCK_FOLDED:L.BLOCK_LITERAL,o=t.source?ea(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
|
|
50
|
+
`.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
|
|
51
|
+
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===L.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
|
|
52
|
+
`):t.length>c||r[0]===` `?(f===` `?f=`
|
|
53
|
+
`:!p&&f===`
|
|
54
|
+
`&&(f=`
|
|
55
|
+
|
|
56
|
+
`),d+=f+t.slice(c)+r,f=`
|
|
57
|
+
`,p=!0):r===``?f===`
|
|
58
|
+
`?d+=`
|
|
59
|
+
`:f=`
|
|
60
|
+
`:(d+=f+r,f=` `,p=!1)}switch(i.chomp){case`-`:break;case`+`:for(let e=s;e<o.length;++e)d+=`
|
|
61
|
+
`+o[e][0].slice(c);d[d.length-1]!==`
|
|
62
|
+
`&&(d+=`
|
|
63
|
+
`);break;default:d+=`
|
|
64
|
+
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function $i({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function ea(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function ta(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=L.PLAIN,c=na(a,l);break;case`single-quoted-scalar`:s=L.QUOTE_SINGLE,c=ra(a,l);break;case`double-quoted-scalar`:s=L.QUOTE_DOUBLE,c=aa(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=Ki(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function na(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),ia(e)}function ra(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),ia(e.slice(1,-1)).replace(/''/g,`'`)}function ia(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
|
|
65
|
+
`?a+=o:o=`
|
|
66
|
+
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function aa(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
|
|
67
|
+
`){if(i===`
|
|
68
|
+
`){let{fold:t,offset:i}=oa(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=sa[i];if(a)n+=a;else if(i===`
|
|
69
|
+
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
|
|
70
|
+
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=ca(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
|
|
71
|
+
`&&(a!==`\r`||e[r+2]!==`
|
|
72
|
+
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function oa(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
|
|
73
|
+
`||r===`\r`)&&(r!==`\r`||e[t+2]===`
|
|
74
|
+
`);)r===`
|
|
75
|
+
`&&(n+=`
|
|
76
|
+
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var sa={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
|
|
77
|
+
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function ca(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function la(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?Qi(e,t,r):ta(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[mn]:c?ua(e.schema,i,c,n,r):t.type===`scalar`?da(e,i,t,r):e.schema[mn];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=N(a)?a:new L(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new L(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function ua(e,t,n,r,i){if(n===`!`)return e[mn];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[mn])}function da({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[mn];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[mn];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function fa(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var pa={composeNode:ma,composeEmptyNode:ha};function ma(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=ga(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=la(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=Zi(pa,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=ha(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!N(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function ha(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=la(e,{type:`scalar`,offset:fa(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function ga({options:e},{offset:t,source:n,end:r},i){let a=new Rn(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=Ki(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function _a(e,t,{offset:n,start:r,value:i,end:a},o){let s=new Ni(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=zi(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?ma(c,i,l,o):ha(c,l.end,r,null,l,o);let u=s.contents.range[2],d=Ki(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function va(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function ya(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
|
|
78
|
+
|
|
79
|
+
`:`
|
|
80
|
+
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var ba=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=va(e);r?this.warnings.push(new Li(i,t,n)):this.errors.push(new Ii(i,t,n))},this.directives=new jn({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=ya(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(P(i)&&!i.flow&&i.items.length>0){let e=i.items[0];M(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ya(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=va(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=_a(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new Ii(va(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new Ii(va(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=Ki(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Ii(va(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new Ni(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},xa=Symbol(`break visit`),Sa=Symbol(`skip children`),Ca=Symbol(`remove item`);function wa(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),Ta(Object.freeze([]),e,t)}wa.BREAK=xa,wa.SKIP=Sa,wa.REMOVE=Ca,wa.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},wa.parentCollection=(e,t)=>{let n=wa.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function Ta(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=Ta(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===xa)return xa;else r===Ca&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function Ea(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
|
|
81
|
+
`:case`\r
|
|
82
|
+
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function Da(e){switch(e){case void 0:case` `:case`
|
|
83
|
+
`:case`\r`:case` `:return!0;default:return!1}}var Oa=new Set(`0123456789ABCDEFabcdef`),ka=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),Aa=new Set(`,[]{}`),ja=new Set(` ,[]{}
|
|
84
|
+
\r `),Ma=e=>!e||ja.has(e),Na=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
|
|
85
|
+
`||t===`\r`&&this.buffer[e+1]===`
|
|
86
|
+
`}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
|
|
87
|
+
`||!t&&!this.atEnd)return e+n+1}return t===`
|
|
88
|
+
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&Da(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
89
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&Da(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Da(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&Da(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(Ma),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&Da(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(Ma),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||Da(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
|
|
90
|
+
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
|
|
91
|
+
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>Da(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
|
|
92
|
+
`:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
|
|
93
|
+
`)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
|
|
94
|
+
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
|
|
95
|
+
`;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
|
|
96
|
+
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(Da(r)||e&&Aa.has(r))break;t=n}else if(Da(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
|
|
97
|
+
`?(n+=1,r=`
|
|
98
|
+
`,i=this.buffer[n+1]):t=n),i===`#`||e&&Aa.has(i))break;if(r===`
|
|
99
|
+
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&Aa.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(Ma),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(Da(n)||t&&Aa.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!Da(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(ka.has(t))t=this.buffer[++e];else if(t===`%`&&Oa.has(this.buffer[e+1])&&Oa.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
100
|
+
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
101
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},Pa=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function Fa(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Ia(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function La(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function Ra(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function za(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function Ba(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function Va(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!Fa(t.start,`explicit-key-ind`)&&!Fa(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,La(t.value)?t.value.end?Ba(t.value.end,t.sep):t.value.end=t.sep:Ba(t.start,t.sep),delete t.sep)}var Ha=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new Na,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Ea(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source})}else{if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&Va(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&Ia(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:Ia(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=za(Ra(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
|
|
102
|
+
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
103
|
+
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ba(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(Fa(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=za(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Fa(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(La(t.key)&&!Fa(t.sep,`newline`)){let e=za(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Fa(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!Fa(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ba(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||Fa(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=za(Ra(t));Va(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
|
|
104
|
+
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
105
|
+
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=za(Ra(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=za(Ra(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function Ua(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Pa||null,prettyErrors:t}}function Wa(e,t={}){let{lineCounter:n,prettyErrors:r}=Ua(t),i=new Ha(n?.addNewLine),a=new ba(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new Ii(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(Ri(e,n)),o.warnings.forEach(Ri(e,n))),o}function Ga(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=Wa(e,n);if(!i)return null;if(i.warnings.forEach(e=>gr(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function Ka(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 qa(e,t=`|`){return e.map(e=>vo(e)).join(t)}function Ja(e,t){return typeof t==`bigint`?t.toString():t}var Ya=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 Xa(e){return new Ya(e)}function Za(e){return e==null}function Qa(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function $a(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}function eo(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function to(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function no(e){return to(e._zod.def)??e._zod.def.shape}function ro(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return eo(this,t,e),e},enumerable:!0,configurable:!0})}function io(e,t,n){t in e?eo(e,t,n):e[t]=n}function ao(e,t,n,r){let i=no(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?ro(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):io(e,a,r?r(n.value,a):n.value))}}function oo(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?ro(e,n,()=>t[n]):io(e,n,r.value))}}function B(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function so(e){return JSON.stringify(e)}function co(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var lo=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function uo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var fo=Xa(()=>{if(ss.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function po(e){if(uo(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return uo(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function mo(e){return po(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ho=new Set([`string`,`number`,`symbol`]);function go(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _o(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function V(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 vo(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function yo(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var bo={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},xo={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function So(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 ao(i,e,Co(e,t)),_o(e,B(n,{shape:i,checks:[]}))}function Co(e,t){let n=no(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 wo(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(Co(e,t)),a={};return ao(a,e,Reflect.ownKeys(no(e)).filter(e=>!i.has(e))),_o(e,B(n,{shape:a,checks:[]}))}function To(e,t){if(!po(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=no(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 _o(e,B(e._zod.def,{shape:Eo(e,t)}))}function Eo(e,t){let n={};return ao(n,e,Reflect.ownKeys(no(e))),oo(n,t),n}function Do(e,t){if(!po(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return _o(e,B(e._zod.def,{shape:Eo(e,t)}))}function Oo(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 ao(n,e,Reflect.ownKeys(no(e))),ao(n,t,Reflect.ownKeys(no(t))),_o(e,B(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ko(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(Co(t,n)):void 0,o={};return ao(o,t,Reflect.ownKeys(no(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),_o(t,B(t._zod.def,{shape:o,checks:[]}))}function Ao(e,t,n){let r=n?new Set(Co(t,n)):void 0,i={};return ao(i,t,Reflect.ownKeys(no(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),_o(t,B(t._zod.def,{shape:i}))}function jo(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 Mo(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 No(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Po(e){return typeof e==`string`?e:e?.message}function Fo(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Io(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Lo(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:Po(e.inst?._zod.def?.error?.(e))??Po(a?.(e))??Po(t?.error?.(e))??Po(n.customError?.(e))??Po(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 Ro=/[\uD800-\uDBFF]/;function zo(e){let t=e.length;if(!Ro.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 Bo(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Vo(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 Ho(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Uo(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):qo(e,n,r.value)}}function Wo(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Go(e,t,n){return Wo(e,t,n,!1)}function Ko(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Wo(this,n,r(this))},set(e){Wo(this,n,e)}})}return t}function qo(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Wo(this,t,n.bind(this))},set(e){Wo(this,t,e)}})}function Jo(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Yo,Xo=!1,Zo={configurable:!0,get(){Xo=!0}};function H(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Yo!==e._zod?Yo=void 0:(Yo=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Zo);let e=Xo;Xo=!1;try{let r=n(this);return Xo?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Xo||=e,r}catch(n){throw delete this[t],Xo||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Qo(e,t,n,r){let i=Jo(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 $o=`~constantCatch`;function es(e){let t=()=>e;return t[$o]=!0,t}var ts,ns={value:void 0,enumerable:!1},rs=`captureStackTrace`in Error?Error:null;function is(e){let t=rs;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return rs=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function U(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){ns.value=new a(r);try{Object.defineProperty(n,"_zod",ns)}finally{ns.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),Uo(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?is(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 as=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},os=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ts=globalThis).__zod_globalConfig??(ts.__zod_globalConfig={});var ss=globalThis.__zod_globalConfig;function cs(e){return e&&Object.assign(ss,e),ss}function ls(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ja,2),e.message}function us(e){this._zod.message=e}var ds={get:ls,set:us,enumerable:!0,configurable:!0},fs={value:void 0,enumerable:!1},ps=new WeakSet([Object.prototype,Error.prototype]),ms=U(`$ZodError`,(e,t)=>{e.name=`$ZodError`,fs.value=t,Object.defineProperty(e,"issues",fs),fs.value=void 0,Object.defineProperty(e,"message",ds);let n=Object.getPrototypeOf(e);ps.has(n)||(ps.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})}}))});function hs(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 gs(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?hs(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function _s(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 vs(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ys=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 as;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Lo(e,o,cs())));throw lo(n,a?.callee??t),n}return s.value};return t},bs=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=>Lo(e,o,cs())));throw lo(n,a?.callee??t),n}return s.value};return t},xs=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 as;return a.issues.length?Ss(e,a.issues,i):{success:!0,data:a.value}};function Ss(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Lo(e,n,cs()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Cs=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?Ss(e,a.issues,i):{success:!0,data:a.value}},ws=Symbol.for(`zod.compile.invalid`),Ts=Symbol.for(`zod.compile.fallback`),Es=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==ws)return!0;if(r.definite===!0&&n===void 0)return!1}return Ds(e,t,n)});function Ds(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Ts]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new as;return a.issues.length===0}var Os=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},ks=e=>{let t=ys(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,vs(n,a))};return n},As=e=>{let t=ys(e),n=(e,r,i,a)=>t(e,r,i,vs(n,a));return n},js=e=>{let t=bs(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,vs(n,a))};return n},Ms=e=>{let t=bs(e),n=async(e,r,i,a)=>await t(e,r,i,vs(n,a));return n},Ns=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return xs(e)(t,n,i)},Ps=e=>(t,n,r)=>xs(e)(t,n,r),Fs=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Cs(e)(t,n,i)},Is=e=>async(t,n,r)=>Cs(e)(t,n,r),Ls=/^[cC][0-9a-z]{6,}$/,Rs=/^[0-9a-z]+$/,zs=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Bs=/^[0-9a-vA-V]{20}$/,Vs=/^[A-Za-z0-9]{27}$/,Hs=/^[a-zA-Z0-9_-]{21}$/;function Us(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Ws=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gs=/^([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})$/,Ks=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)$/,qs=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Js=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Ys(){return new RegExp(Js,`u`)}var Xs=/^(?:(?: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])$/,Zs=/^(([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}|:))$/,Qs=/^((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])$/,$s=/^(([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])$/,ec=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tc=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,nc=/^https?$/,rc=/^\+[1-9]\d{6,14}$/,ic=`(?:(?:\\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 ac(e){return RegExp(`^${e}$`)}var oc=ac(ic);function sc(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 cc(e){return RegExp(`^${sc(e)}$`)}function lc(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${sc({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${sc({precision:e.precision})}`:n;return RegExp(`^${ic}T(?:${r})$`)}var uc=/^[\s\S]{0,}$/,dc=/^-?\d+(?:\.\d+)?$/,fc=/^(?:true|false)$/i,pc=/^[^A-Z]*$/,mc=/^[^a-z]*$/,W=U(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),hc=e=>{let t=e.value;return!Za(t)&&t.length!==void 0},gc={number:`number`,bigint:`bigint`,object:`date`},_c=U(`$ZodCheckLessThan`,(e,t)=>{W.init(e,t);let n=gc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:gc[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})}}),vc=U(`$ZodCheckGreaterThan`,(e,t)=>{W.init(e,t);let n=gc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:gc[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})}}),yc=U(`$ZodCheckMultipleOf`,(e,t)=>{W.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):$a(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})}}),bc=U(`$ZodCheckNumberFormat`,(e,t)=>{W.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=bo[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})}}),xc=U(`$ZodCheckMaxLength`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=hc),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?zo(r):i)<=t.maximum)return;let a=Bo(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Sc=U(`$ZodCheckMinLength`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=hc),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?zo(r):i)>=t.minimum)return;let a=Bo(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Cc=U(`$ZodCheckLengthEquals`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=hc),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?zo(r):i;if(a===t.length)return;let o=Bo(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})}}),wc=U(`$ZodCheckStringFormat`,(e,t)=>{var n,r;W.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=()=>{})}),Tc=U(`$ZodCheckRegex`,(e,t)=>{wc.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})}}),Ec=U(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=pc,wc.init(e,t)}),Dc=U(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=mc,wc.init(e,t)}),Oc=U(`$ZodCheckIncludes`,(e,t)=>{W.init(e,t);let n=go(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})}}),kc=U(`$ZodCheckStartsWith`,(e,t)=>{W.init(e,t);let n=RegExp(`^${go(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})}}),Ac=U(`$ZodCheckEndsWith`,(e,t)=>{W.init(e,t);let n=RegExp(`.*${go(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})}}),jc=U(`$ZodCheckOverwrite`,(e,t)=>{W.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Mc=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(`
|
|
106
|
+
`).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(`
|
|
107
|
+
`)}\n};`)(...Object.values(this.closed))}},Nc={major:4,minor:6,patch:7},G=U(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Nc;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=jo(t),a;for(let o of n){if(o._zod.def.when){if(Mo(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 as;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Io(t.issues,n,e),i||=jo(t,n))});else{if(t.issues.length===n)continue;Io(t.issues,n,e),i||=jo(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(jo(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new as;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 as;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Go(this,`~standard`,Ic(this))},set"~standard"(e){Wo(this,`~standard`,e)}}),Pc=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Lo(e,t,cs()))}:{value:e.value};async function Fc(e,t){let n={async:!0};return Pc(await e._zod.run({value:t,issues:[]},n),n)}function Ic(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Pc(r,n)}catch{}return Fc(e,t)},vendor:`zod`,version:1}}var Lc=U(`$ZodString`,(e,t)=>{G.init(e,t),e._zod.pattern=t.pattern??uc,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}}),K=U(`$ZodStringFormat`,(e,t)=>{wc.init(e,t),Lc.init(e,t)}),Rc=U(`$ZodGUID`,(e,t)=>{t.pattern??=Gs,K.init(e,t)}),zc=U(`$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??=Ks(e)}else t.pattern??=Ks();K.init(e,t)}),Bc=U(`$ZodEmail`,(e,t)=>{t.pattern??=qs,K.init(e,t)});function Vc(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Hc(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Vc(e)||2:Uc(e,t)}function Uc(e,t){if(!t.normalize&&t.protocol?.source===nc.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 Wc=/[\t\n\r]/g;function Gc(e){return e.replace(Wc,``)}function Kc(e,t){return t.lastIndex=0,t.test(e.hostname)}function qc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Jc=U(`$ZodURL`,(e,t)=>{K.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Hc(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=Gc(r);return}t.hostname&&!Kc(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&&!qc(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:Gc(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Yc=U(`$ZodEmoji`,(e,t)=>{t.pattern??=Ys(),K.init(e,t)}),Xc=U(`$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?Hs:Us(t.length),K.init(e,t)}),Zc=U(`$ZodCUID`,(e,t)=>{t.pattern??=Ls,K.init(e,t)}),Qc=U(`$ZodCUID2`,(e,t)=>{t.pattern??=Rs,K.init(e,t)}),$c=U(`$ZodULID`,(e,t)=>{t.pattern??=zs,K.init(e,t)}),el=U(`$ZodXID`,(e,t)=>{t.pattern??=Bs,K.init(e,t)}),tl=U(`$ZodKSUID`,(e,t)=>{t.pattern??=Vs,K.init(e,t)}),nl=U(`$ZodISODateTime`,(e,t)=>{t.pattern??=lc(t),K.init(e,t)}),rl=U(`$ZodISODate`,(e,t)=>{t.pattern??=oc,K.init(e,t)}),il=U(`$ZodISOTime`,(e,t)=>{t.pattern??=cc(t),K.init(e,t)}),al=U(`$ZodISODuration`,(e,t)=>{t.pattern??=Ws,K.init(e,t)}),ol=U(`$ZodIPv4`,(e,t)=>{t.pattern??=Xs,K.init(e,t)}),sl=/^[0-9a-fA-F:.]+$/;function cl(e){return sl.test(e)?Vc(`http://[${e}]`):!1}var ll=U(`$ZodIPv6`,(e,t)=>{t.pattern??=Zs,K.init(e,t),e._zod.check=n=>{cl(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),ul=U(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Qs,K.init(e,t)});function dl(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:cl(n)}var fl=U(`$ZodCIDRv6`,(e,t)=>{t.pattern??=$s,K.init(e,t),e._zod.check=n=>{dl(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function pl(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var ml=/^[0-9a-zA-Z+/]*={0,2}$/,hl=U(`$ZodBase64`,(e,t)=>{t.pattern??=ml,K.init(e,t),e._zod.check=n=>{pl(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),gl=/^[A-Za-z0-9_-]*$/;function _l(e){if(!gl.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return pl(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var vl=U(`$ZodBase64URL`,(e,t)=>{t.pattern??=gl,K.init(e,t),e._zod.check=n=>{_l(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),yl=U(`$ZodE164`,(e,t)=>{t.pattern??=rc,K.init(e,t)});function bl(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 xl=U(`$ZodJWT`,(e,t)=>{K.init(e,t),e._zod.check=n=>{bl(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Sl=U(`$ZodNumber`,(e,t)=>{G.init(e,t),e._zod.pattern=dc,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}}),Cl=U(`$ZodNumberFormat`,(e,t)=>{bc.init(e,t),Sl.init(e,t)}),wl=U(`$ZodBoolean`,(e,t)=>{G.init(e,t),e._zod.pattern=fc,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}}),Tl=U(`$ZodUnknown`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),El=U(`$ZodNever`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Dl(e,t){let n=Fo(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Fo(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Io(n.issues,t,e),n}}return i(n,a)}}var Ol=e=>Array.isArray(e)?e.length:-1;function kl(e,t,n){e.issues.length&&t.issues.push(...No(n,e.issues)),t.value[n]=e.value}var Al=U(`$ZodArray`,(e,t)=>{G.init(e,t);let n=ss.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=>kl(t,r,e)));else if(kl(c,r,e),s&&c.issues.length!==0&&jo(c))break}return o.length?Promise.all(o).then(()=>r):r},Dl(e,Ol)});function jl(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(...No(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Ml=[];function Nl(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Ml,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=yo(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Pl(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(jo(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=>jl(e,n,i,t,d,f))):jl(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 Fl=U(`$ZodObject`,(e,t)=>{G.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=Xa(()=>Nl(t));H(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)||eo(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=uo,o=t.catchall,s,c=ss.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(jo(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=>jl(n,t,e,r,a,o))):jl(s,t,e,r,a,o)}return o?Pl(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Il=U(`$ZodObjectJIT`,(e,t)=>{Fl.init(e,t);let n=e._zod.parse,r=Xa(()=>Nl(t)),i=ss.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Mc([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
108
|
+
let ${e}_ab = false;
|
|
109
|
+
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
110
|
+
const iss = ${e}.issues[i];
|
|
111
|
+
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
112
|
+
payload.issues.push(iss);
|
|
113
|
+
if (iss.continue !== true) ${e}_ab = true;
|
|
114
|
+
}
|
|
115
|
+
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
116
|
+
payload.value = newResult;
|
|
117
|
+
return payload;
|
|
118
|
+
}`;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)}]`:so(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(`
|
|
119
|
+
const ${n}_present = ${i};
|
|
120
|
+
if (!${n}.issues.length || ${n}_present) {
|
|
121
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (${e}) {
|
|
125
|
+
newResult[${r}] = ${n}.value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
`)}else f?(o.write(`
|
|
130
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
131
|
+
}
|
|
132
|
+
`),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
|
|
133
|
+
if (${n}.value !== undefined || ${i}) {
|
|
134
|
+
newResult[${r}] = ${n}.value;
|
|
135
|
+
}
|
|
136
|
+
`)):o.write(`
|
|
137
|
+
const ${n}_present = ${i};
|
|
138
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
139
|
+
}
|
|
140
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
141
|
+
payload.issues.push({
|
|
142
|
+
code: "invalid_type",
|
|
143
|
+
expected: "nonoptional",
|
|
144
|
+
input: undefined,
|
|
145
|
+
path: [${r}]
|
|
146
|
+
});
|
|
147
|
+
if (ctx && ctx.abortEarly) {
|
|
148
|
+
payload.value = newResult;
|
|
149
|
+
return payload;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (${n}_present) {
|
|
154
|
+
newResult[${r}] = ${n}.value;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=uo,c=!ss.jitless,l=c&&fo.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?Pl([],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 Ll(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=>!jo(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=>Lo(e,r,cs())))}),t)}var Rl=U(`$ZodUnion`,(e,t)=>{G.init(e,t),H(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),H(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),H(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),H(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Qa(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=>Ll(t,r,e,i)):Ll(o,r,e,i)}}),zl=U(`$ZodIntersection`,(e,t)=>{G.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])=>Vl(e,t,n)):Vl(e,i,a)}});function Bl(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(po(e)&&po(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=Bl(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=Bl(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 Vl(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=Bl(t.value,n.value);if(!c.valid){if(jo(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Hl=U(`$ZodTuple`,(e,t)=>{G.init(e,t);let n=t.items,r=ss.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=Ul(n,`optin`),l=Ul(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=jo(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(jo(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>Wl(t,i,e))):Wl(r,i,e)}}return s.length?Promise.all(s).then(()=>Gl(u,i,n,o,l)):Gl(u,i,n,o,l)}});function Ul(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function Wl(e,t,n){e.issues.length&&t.issues.push(...No(n,e.issues)),t.value[n]=e.value}function Gl(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...No(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}var Kl=U(`$ZodEnum`,(e,t)=>{G.init(e,t);let n=Ka(t.entries),r=new Set(n);e._zod.values=r,H(e,`pattern`,e=>{let t=Ka(e.def.entries).filter(e=>ho.has(typeof e));return RegExp(t.length?`^(${t.map(e=>go(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}}),ql=U(`$ZodTransform`,(e,t)=>{G.init(e,t),e._zod.optin=`optional`,ss.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new os(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 as;return n.value=i,n}});function Jl(e,t){return e.value=t.issues.length?void 0:t.value,e}var Yl=U(`$ZodOptional`,(e,t)=>{G.init(e,t),H(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,H(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),H(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Qa(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=>Jl(e,t)):Jl(e,r)}return t.innerType._zod.run(e,n)}}),Xl=U(`$ZodExactOptional`,(e,t)=>{Yl.init(e,t),H(e,`values`,e=>e.def.innerType._zod.values),H(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Zl=U(`$ZodNullable`,(e,t)=>{G.init(e,t),H(e,`optin`,e=>e.def.innerType._zod.optin),H(e,`optout`,e=>e.def.innerType._zod.optout),H(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Qa(t.source)}|null)$`):void 0}),H(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ql=U(`$ZodDefault`,(e,t)=>{G.init(e,t),e._zod.optin=`defaulted`,H(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=>$l(e,t)):$l(r,t)}});function $l(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var eu=U(`$ZodPrefault`,(e,t)=>{G.init(e,t),e._zod.optin=`defaulted`,H(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))}),tu=U(`$ZodNonOptional`,(e,t)=>{G.init(e,t),H(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=>nu(t,e)):nu(i,e)}});function nu(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 ru(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Lo(e,r,cs()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var iu=U(`$ZodCatch`,(e,t)=>{G.init(e,t),H(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),H(e,`optout`,e=>e.def.innerType._zod.optout),H(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(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=>ru(e,r,t,n)):ru(e,r,t,n)}}),au=U(`$ZodPipe`,(e,t)=>{G.init(e,t),H(e,`values`,e=>e.def.in._zod.values),H(e,`optin`,e=>e.def.in._zod.optin),H(e,`optout`,e=>e.def.out._zod.optout),H(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ou(e,t.in,n)):ou(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ou(e,t.out,n)):ou(r,t.out,n)}});function ou(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 su=U(`$ZodReadonly`,(e,t)=>{G.init(e,t),H(e,`propValues`,e=>e.def.innerType._zod.propValues),H(e,`values`,e=>e.def.innerType._zod.values),H(e,`optin`,e=>e.def.innerType?._zod?.optin),H(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(cu):cu(r)}});function cu(e){return e.memo||(e.value=Object.freeze(e.value)),e}var lu=U(`$ZodCustom`,(e,t)=>{W.init(e,t),G.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=>uu(t,n,r,e));uu(i,n,r,e)}});function uu(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(Ho(e))}}var du=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},fu=`~memo`,pu=[];function mu(e){return typeof e==`object`&&!!e}function hu(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var gu=new WeakMap,_u=0,vu=1,yu=2;function bu(e,t,n){let r=gu.get(e);if(r!==void 0)return r?yu:_u;if(t.has(e))return yu;t.add(e);let i=_u,a=e=>{if(i!==yu&&e?._zod){let r=bu(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=_u;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?vu:o.value?._zod?bu(o.value,t,n):_u;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=to(c);s(e?o(e,!0):vu),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?bu(r,t,!1):vu);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),xu(e,i)}function xu(e,t){return t!==vu&&gu.set(e,t===yu),t}function Su(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Cu,wu=[],Tu={alloc(e,t,n){let r=Cu;if(!r)return n;Cu=void 0;let i={value:n,issues:null};return r.set(t.value,i),wu.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`&&Du(n,e.value))throw new du;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=bu(e,new Set,!1);if(i===_u)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===yu||r?n=!0:r=!0}let l=s.value;if(!mu(l))return t(s,c);let u=c[fu];u||(u={buckets:new WeakMap,backEdges:void 0},c[fu]=u);let d;i===c?d=a:(d=Su(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(...hu(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Cu=d;let p=wu.length,m=t(s,c);Cu=void 0;let h=wu.length>p?wu.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?hu(e.issues):pu),e)):(h&&(h.issues=m.issues.length?hu(m.issues):pu),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Eu(){return Tu}function Du(e,t){let n=e[fu]?.backEdges;return n!==void 0&&mu(t)&&n.has(t)}var Ou=()=>{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(Vo(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${vo(e.values[0])}`:`Invalid option: expected one of ${qa(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`:``}: ${qa(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 ku(){return{localeError:Ou()}}var Au,ju=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 Mu(){return new ju}(Au=globalThis).__zod_globalRegistry??(Au.__zod_globalRegistry=Mu());var Nu=globalThis.__zod_globalRegistry;function Pu(e){return e.checks&&=[...e.checks],e}function Fu(e,t){return new e(Pu({type:`string`,...V(t)}))}function Iu(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...V(t)})}function Lu(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...V(t)})}function Ru(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...V(t)})}function zu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...V(t)})}function Bu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...V(t)})}function Vu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...V(t)})}function Hu(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...V(t)})}function Uu(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...V(t)})}function Wu(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...V(t)})}function Gu(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...V(t)})}function Ku(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...V(t)})}function qu(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...V(t)})}function Ju(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...V(t)})}function Yu(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...V(t)})}function Xu(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...V(t)})}function Zu(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...V(t)})}function Qu(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...V(t)})}function $u(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...V(t)})}function ed(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...V(t)})}function td(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...V(t)})}function nd(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...V(t)})}function rd(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...V(t)})}function id(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...V(t)})}function ad(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...V(t)})}function od(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...V(t)})}function sd(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...V(t)})}function cd(e,t){return new e(Pu({type:`number`,checks:[],...V(t)}))}function ld(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...V(t)})}function ud(e,t){return new e({type:`boolean`,...V(t)})}function dd(e){return new e({type:`unknown`})}function fd(e,t){return new e({type:`never`,...V(t)})}function pd(e,t){return new _c({check:`less_than`,...V(t),value:e,inclusive:!1})}function md(e,t){return new _c({check:`less_than`,...V(t),value:e,inclusive:!0})}function hd(e,t){return new vc({check:`greater_than`,...V(t),value:e,inclusive:!1})}function gd(e,t){return new vc({check:`greater_than`,...V(t),value:e,inclusive:!0})}function _d(e,t){return new yc({check:`multiple_of`,...V(t),value:e})}function vd(e,t){return new xc({check:`max_length`,...V(t),maximum:e})}function yd(e,t){return new Sc({check:`min_length`,...V(t),minimum:e})}function bd(e,t){return new Cc({check:`length_equals`,...V(t),length:e})}function xd(e,t){return new Tc({check:`string_format`,format:`regex`,...V(t),pattern:e})}function Sd(e){return new Ec({check:`string_format`,format:`lowercase`,...V(e)})}function Cd(e){return new Dc({check:`string_format`,format:`uppercase`,...V(e)})}function wd(e,t){return new Oc({check:`string_format`,format:`includes`,...V(t),includes:e})}function Td(e,t){return new kc({check:`string_format`,format:`starts_with`,...V(t),prefix:e})}function Ed(e,t){return new Ac({check:`string_format`,format:`ends_with`,...V(t),suffix:e})}function Dd(e){return new jc({check:`overwrite`,tx:e})}function Od(e){return Dd(t=>t.normalize(e))}function kd(){return Dd(e=>e.trim())}function Ad(){return Dd(e=>e.toLowerCase())}function jd(){return Dd(e=>e.toUpperCase())}function Md(){return Dd(e=>co(e))}function Nd(e,t,n){return new e({type:`array`,element:t,...V(n)})}function Pd(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...V(n)})}function Fd(e,t){let n=Id(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ho(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(Ho(r))}},e(t.value,t)),t);return n}function Id(e,t){let n=new W({check:`custom`,...V(t)});return n._zod.check=e,n}function Ld(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&eo(e,t,n[t]);return e}function Rd(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??Nu,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 zd(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 q(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,q(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Ld(o.schema,c),t.io===`input`&&J(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 Bd(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Vd(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}/${Bd(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+Bd(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>
|
|
158
|
+
|
|
159
|
+
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);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Hd(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;Hd(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 Ud=new Set([`type`,`properties`,`required`,`additionalProperties`]),Wd=[`oneOf`,`anyOf`];function Gd(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Kd(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ud.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]??Gd(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}eo(n,r,e.length===1?e[0]:Kd(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=Gd(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 qd(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ud)if(t in e)return;let n=t.filter(e=>Wd.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Kd(t);else{let e=n[0],i=Wd.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=>Kd([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ld(e,r))}function Jd(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)):Ld(i,s),Ld(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())Hd(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)??[])qd(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)}Ld(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,eo(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:Xd(t,`input`,e.processors),output:Xd(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function J(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 J(r.element,n);if(r.type===`set`)return J(r.valueType,n);if(r.type===`lazy`)return J(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 J(r.innerType,n);if(r.type===`intersection`)return J(r.left,n)||J(r.right,n);if(r.type===`record`||r.type===`map`)return J(r.keyType,n)||J(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:J(r.in,n)||J(r.out,n);if(r.type===`object`){for(let e in r.shape)if(J(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(J(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(J(e,n))return!0;return!!(r.rest&&J(r.rest,n))}return!1}var Yd=(e,t={})=>n=>{let r=Rd({...n,processors:t});return q(e,r),Vd(r,e),Jd(r,e)},Xd=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Rd({...i??{},target:a,io:t,processors:n});return q(e,o),Vd(o,e),Jd(o,e)},Zd=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Qd=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},$d=(e,t)=>{Zd(e,`minimum`,t),Qd(e,`maximum`,t)},ef=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},tf=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},nf=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},rf=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},af=(e,t)=>Zd(e,`minimum`,t.minimum),of=(e,t)=>Qd(e,`maximum`,t.maximum),sf=e=>(t,n)=>{rf(t,n.format);let[r,i]=e[n.format];Zd(t,`minimum`,r),Qd(t,`maximum`,i)},cf={greater_than:(e,t)=>Zd(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Qd(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>ef(e,t.value),number_format:sf(bo),bigint_format:sf(xo),min_length:af,max_length:of,length_equals:(e,t)=>$d(e,t.length),min_size:af,max_size:of,size_equals:(e,t)=>$d(e,t.size),string_format:(e,t)=>{rf(e,t.format),t.pattern&&tf(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)=>nf(e,t.mime)};function lf(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)cf[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Zd(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Zd(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Qd(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Qd(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&ef(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&nf(t,i.mime);for(let e of i.patterns??[])tf(t,e);return t}var uf={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},df=new Map([[ml,ec],[gl,tc]]),ff=e=>df.get(e)??e,pf=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=lf(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=uf[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(ff);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}))])}},mf=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=lf(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)):zd(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}))])}},hf=(e,t,n,r)=>{n.type=`boolean`},gf=(e,t,n,r)=>{n.not={}},_f=(e,t,n,r)=>{let i=e._zod.def,a=Ka(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},vf=(e,t,n,r)=>{zd(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},yf=(e,t,n,r)=>{zd(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},bf=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=lf(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=q(a.element,t,{...r,path:[...r.path,`items`]})};function xf(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?xf(t.out):t.type===`catch`?xf(t.innerType):e._zod.optin}var Sf=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&zd(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)eo(i.properties,e,q(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`?xf(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=q(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Cf=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>q(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},wf=(e,t,n,r)=>{let i=e._zod.def,a=q(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=q(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)},Tf=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>q(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?q(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?xf(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=lf(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)},Ef=(e,t,n,r)=>{let i=e._zod.def,a=q(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`}]},Df=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Of=Symbol();function kf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(zd(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Of):JSON.parse(o)}var Af=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=kf(i.defaultValue,e,t,n,r);o!==Of&&(n.default=o)},jf=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=kf(i.defaultValue,e,t,n,r);o!==Of&&(n._prefault=o)},Mf=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{zd(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Nf=(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;q(o,t,r);let s=t.seen.get(e);s.ref=o},Pf=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ff=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},If=new WeakSet([Object.prototype,Error.prototype]);function Lf(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 Y=U(`ZodError`,(e,t)=>{ms.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);If.has(n)||(If.add(n),Lf(n,`format`,e=>t=>_s(e,t)),Lf(n,`flatten`,e=>t=>gs(e,t)),Lf(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ja,2)}),Lf(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ja,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Rf=ys(Y),zf=bs(Y),Bf=xs(Y),Vf=Cs(Y),Hf=ks(Y),Uf=As(Y),Wf=js(Y),Gf=Ms(Y),Kf=Ns(Y),qf=Ps(Y),Jf=Fs(Y),Yf=Is(Y);function Xf(){ss.localeError||cs(ku())}function Zf(){ss.memoizer||cs({memoizer:Eu()})}var X=U(`ZodType`,(e,t)=>(Xf(),G.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(B(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 _o(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(pm(e,t))},superRefine(e,t){return this.check(mm(e,t))},overwrite(e){return this.check(Dd(e))},optional(){return Yp(this)},exactOptional(){return Zp(this)},nullable(){return $p(this)},nullish(){return Yp($p(this))},nonoptional(e){return am(this,e)},array(){return Fp(this)},or(e){return zp([this,e])},and(e){return Vp(this,e)},transform(e){return lm(this,qp(e))},default(e){return tm(this,e)},prefault(e){return rm(this,e)},catch(e){return sm(this,e)},pipe(e){return lm(this,e)},readonly(){return dm(this)},describe(e){let t=this.clone();return Nu.add(t,{description:e}),t},meta(...e){if(e.length===0)return Nu.get(this);let t=this.clone();return Nu.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 Go(this,`~standard`,{...Ic(this),jsonSchema:{input:Xd(this,`input`),output:Xd(this,`output`)}})},set"~standard"(e){Wo(this,`~standard`,e)},parse:function e(t,n){return Rf(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await zf(this,t,n,{callee:e})},safeParse(e,t){return Bf(this,e,t)},async safeParseAsync(e,t){return Vf(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Wo(this,`spa`,e)},validate(e,t){return Es(this,e,t)},validateAsync(e,t){return Os(this,e,t)},encode:function e(t,n){return Hf(this,t,n,{callee:e})},decode:function e(t,n){return Uf(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Wf(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Gf(this,t,n,{callee:e})},safeEncode(e,t){return Kf(this,e,t)},safeDecode(e,t){return qf(this,e,t)},async safeEncodeAsync(e,t){return Jf(this,e,t)},async safeDecodeAsync(e,t){return Yf(this,e,t)},toJSONSchema(e){return Yd(this,{})(e)},get description(){return Nu.get(this)?.description},get _def(){return this._zod.def}}),Qf=U(`_ZodString`,(e,t)=>{Lc.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pf(e,t,n,r)},Ko({format:e=>lf(e).format??null,minLength:e=>lf(e).minimum??null,maxLength:e=>lf(e).maximum??null},{regex(...e){return this.check(xd(...e))},includes(...e){return this.check(wd(...e))},startsWith(...e){return this.check(Td(...e))},endsWith(...e){return this.check(Ed(...e))},min(...e){return this.check(yd(...e))},max(...e){return this.check(vd(...e))},length(...e){return this.check(bd(...e))},nonempty(...e){return this.check(yd(1,...e))},lowercase(e){return this.check(Sd(e))},uppercase(e){return this.check(Cd(e))},trim(){return this.check(kd())},normalize(...e){return this.check(Od(...e))},toLowerCase(){return this.check(Ad())},toUpperCase(){return this.check(jd())},slugify(){return this.check(Md())}})),$f=U(`ZodString`,(e,t)=>{Lc.init(e,t),Qf.init(e,t)},{email(e){return this.check(Iu(ap,e))},url(e){return this.check(Hu(cp,e))},jwt(e){return this.check(rd(Cp,e))},emoji(e){return this.check(Uu(lp,e))},guid(e){return this.check(Lu(op,e))},uuid(e){return this.check(Ru(sp,e))},uuidv4(e){return this.check(zu(sp,e))},uuidv6(e){return this.check(Bu(sp,e))},uuidv7(e){return this.check(Vu(sp,e))},nanoid(e){return this.check(Wu(up,e))},cuid(e){return this.check(Gu(dp,e))},cuid2(e){return this.check(Ku(fp,e))},ulid(e){return this.check(qu(pp,e))},base64(e){return this.check(ed(bp,e))},base64url(e){return this.check(td(xp,e))},xid(e){return this.check(Ju(mp,e))},ksuid(e){return this.check(Yu(hp,e))},ipv4(e){return this.check(Xu(gp,e))},ipv6(e){return this.check(Zu(_p,e))},cidrv4(e){return this.check(Qu(vp,e))},cidrv6(e){return this.check($u(yp,e))},e164(e){return this.check(nd(Sp,e))},datetime(e){return this.check(id(tp,e))},date(e){return this.check(ad(np,e))},time(e){return this.check(od(rp,e))},duration(e){return this.check(sd(ip,e))}});function ep(e){return Fu($f,e)}var Z=U(`ZodStringFormat`,(e,t)=>{K.init(e,t),Qf.init(e,t)}),tp=U(`ZodISODateTime`,(e,t)=>{nl.init(e,t),Z.init(e,t)}),np=U(`ZodISODate`,(e,t)=>{rl.init(e,t),Z.init(e,t)}),rp=U(`ZodISOTime`,(e,t)=>{il.init(e,t),Z.init(e,t)}),ip=U(`ZodISODuration`,(e,t)=>{al.init(e,t),Z.init(e,t)}),ap=U(`ZodEmail`,(e,t)=>{Bc.init(e,t),Z.init(e,t)}),op=U(`ZodGUID`,(e,t)=>{Rc.init(e,t),Z.init(e,t)}),sp=U(`ZodUUID`,(e,t)=>{zc.init(e,t),Z.init(e,t)}),cp=U(`ZodURL`,(e,t)=>{Jc.init(e,t),Z.init(e,t)}),lp=U(`ZodEmoji`,(e,t)=>{Yc.init(e,t),Z.init(e,t)}),up=U(`ZodNanoID`,(e,t)=>{Xc.init(e,t),Z.init(e,t)}),dp=U(`ZodCUID`,(e,t)=>{Zc.init(e,t),Z.init(e,t)}),fp=U(`ZodCUID2`,(e,t)=>{Qc.init(e,t),Z.init(e,t)}),pp=U(`ZodULID`,(e,t)=>{$c.init(e,t),Z.init(e,t)}),mp=U(`ZodXID`,(e,t)=>{el.init(e,t),Z.init(e,t)}),hp=U(`ZodKSUID`,(e,t)=>{tl.init(e,t),Z.init(e,t)}),gp=U(`ZodIPv4`,(e,t)=>{ol.init(e,t),Z.init(e,t)}),_p=U(`ZodIPv6`,(e,t)=>{ll.init(e,t),Z.init(e,t)}),vp=U(`ZodCIDRv4`,(e,t)=>{ul.init(e,t),Z.init(e,t)}),yp=U(`ZodCIDRv6`,(e,t)=>{fl.init(e,t),Z.init(e,t)}),bp=U(`ZodBase64`,(e,t)=>{hl.init(e,t),Z.init(e,t)}),xp=U(`ZodBase64URL`,(e,t)=>{vl.init(e,t),Z.init(e,t)}),Sp=U(`ZodE164`,(e,t)=>{yl.init(e,t),Z.init(e,t)}),Cp=U(`ZodJWT`,(e,t)=>{xl.init(e,t),Z.init(e,t)}),wp=U(`ZodNumber`,(e,t)=>{Sl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mf(e,t,n,r),e.isFinite=!0},Ko({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=lf(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=lf(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=lf(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>lf(e).format??null},{gt(e,t){return this.check(hd(e,t))},gte(e,t){return this.check(gd(e,t))},min(e,t){return this.check(gd(e,t))},lt(e,t){return this.check(pd(e,t))},lte(e,t){return this.check(md(e,t))},max(e,t){return this.check(md(e,t))},int(e){return this.check(Dp(e))},safe(e){return this.check(Dp(e))},positive(e){return this.check(hd(0,e))},nonnegative(e){return this.check(gd(0,e))},negative(e){return this.check(pd(0,e))},nonpositive(e){return this.check(md(0,e))},multipleOf(e,t){return this.check(_d(e,t))},step(e,t){return this.check(_d(e,t))},finite(){return this}}));function Tp(e){return cd(wp,e)}var Ep=U(`ZodNumberFormat`,(e,t)=>{Cl.init(e,t),wp.init(e,t)});function Dp(e){return ld(Ep,e)}var Op=U(`ZodBoolean`,(e,t)=>{wl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hf(e,t,n,r)});function kp(e){return ud(Op,e)}var Ap=U(`ZodUnknown`,(e,t)=>{Tl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function jp(){return dd(Ap)}var Mp=U(`ZodNever`,(e,t)=>{El.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r)});function Np(e){return fd(Mp,e)}var Pp=U(`ZodArray`,(e,t)=>{Zf(),Al.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.element=t.element},{min(e,t){return this.check(yd(e,t))},nonempty(e){return this.check(yd(1,e))},max(e,t){return this.check(vd(e,t))},length(e,t){return this.check(bd(e,t))},unwrap(){return this.element}});function Fp(e,t){return Nd(Pp,e,t)}var Ip=U(`ZodObject`,(e,t)=>{Zf(),Il.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sf(e,t,n,r),Qo(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Gp(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(B(this._zod.def,{catchall:e}))},passthrough(){return this.clone(B(this._zod.def,{catchall:jp()}))},loose(){return this.clone(B(this._zod.def,{catchall:jp()}))},strict(){return this.clone(B(this._zod.def,{catchall:Np()}))},strip(){return this.clone(B(this._zod.def,{catchall:void 0}))},extend(e){return To(this,e)},safeExtend(e){return Do(this,e)},merge(e){return Oo(this,e)},pick(e){return So(this,e)},omit(e){return wo(this,e)},partial(...e){return ko(Jp,this,e[0])},exactPartial(...e){return ko(Xp,this,e[0],`exactPartial`)},required(...e){return Ao(im,this,e[0])}});function Lp(e,t){return new Ip({type:`object`,shape:e??{},...V(t)})}var Rp=U(`ZodUnion`,(e,t)=>{Rl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cf(e,t,n,r),e.options=t.options});function zp(e,t){return new Rp({type:`union`,options:e,...V(t)})}var Bp=U(`ZodIntersection`,(e,t)=>{zl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wf(e,t,n,r)});function Vp(e,t){return new Bp({type:`intersection`,left:e,right:t})}var Hp=U(`ZodTuple`,(e,t)=>{Zf(),Hl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tf(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new Jp({type:`optional`,innerType:e}))})}});function Up(e,t,n){let r=t instanceof G;return new Hp({type:`tuple`,items:e,rest:r?t:null,...V(r?n:t)})}var Wp=U(`ZodEnum`,(e,t)=>{Kl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_f(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 Wp({...t,checks:[],...V(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 Wp({...t,checks:[],...V(r),entries:i})}});function Gp(e,t){return new Wp({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...V(t)})}var Kp=U(`ZodTransform`,(e,t)=>{Zf(),ql.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yf(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new os(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ho(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(Ho(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function qp(e){return new Kp({type:`transform`,transform:e})}var Jp=U(`ZodOptional`,(e,t)=>{Yl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yp(e){return new Jp({type:`optional`,innerType:e})}var Xp=U(`ZodExactOptional`,(e,t)=>{Xl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zp(e){return new Xp({type:`optional`,innerType:e})}var Qp=U(`ZodNullable`,(e,t)=>{Zl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ef(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $p(e){return new Qp({type:`nullable`,innerType:e})}var em=U(`ZodDefault`,(e,t)=>{Ql.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Af(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tm(e,t){return new em({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():mo(t)}})}var nm=U(`ZodPrefault`,(e,t)=>{eu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rm(e,t){return new nm({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():mo(t)}})}var im=U(`ZodNonOptional`,(e,t)=>{tu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Df(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function am(e,t){return new im({type:`nonoptional`,innerType:e,...V(t)})}var om=U(`ZodCatch`,(e,t)=>{iu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sm(e,t){return new om({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:es(t)})}var cm=U(`ZodPipe`,(e,t)=>{au.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nf(e,t,n,r),e.in=t.in,e.out=t.out});function lm(e,t){return new cm({type:`pipe`,in:e,out:t})}var um=U(`ZodReadonly`,(e,t)=>{su.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dm(e){return new um({type:`readonly`,innerType:e})}var fm=U(`ZodCustom`,(e,t)=>{lu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vf(e,t,n,r)});function pm(e,t={}){return Pd(fm,e,t)}function mm(e,t){return Fd(e,t)}var hm=.25,gm=Tp().finite(),_m=Tp().finite().positive(),vm=Up([gm,gm]),ym=Lp({number:ep().regex(/^[1-9][0-9]*$/,`pad numbers are pin numbers: digits, starting at 1`),shape:Gp([`rect`,`roundrect`,`circle`,`oval`]),x:gm,y:gm,width:_m,height:_m,rotation:gm.optional(),layers:Gp([`top`,`through`]).optional(),drill:zp([_m,Lp({width:_m,height:_m}).strict()]).optional()}).strict(),bm=e=>Lp({pads:Fp(ym).min(1),courtyard:Fp(e).min(3).optional(),silkscreen:Fp(Fp(e).min(2)).optional(),body:Fp(e).min(3).optional(),placeholder:kp().optional()}).strict(),xm=bm(vm);bm(Fp(gm).length(2));function Sm(e,t){let n=t=>({error:`${e}: ${t}`}),r;try{r=Ga(t)}catch(e){return n(`not valid YAML (${e.message.split(`
|
|
160
|
+
`)[0]})`)}let i=xm.safeParse(Dm(r));if(!i.success)return n(i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `));let a=Cm(i.data);return a.length>0?n(a.join(`; `)):wm(e,i.data)}function Cm(e){let t=[];for(let[n,r]of e.pads.entries()){let e=`pad ${r.number} (entry ${n+1})`,i=r.layers===`through`;i&&r.drill===void 0&&t.push(`${e} is a through pad and needs a drill`),!i&&r.drill!==void 0&&t.push(`${e} is a top pad and must not have a drill`)}return t}function wm(e,t){let n=t.pads.map(Tm),r=([e,t])=>({x:e,y:t});return{name:e,pads:n,courtyard:t.courtyard?t.courtyard.map(r):Em(n,hm),silkscreen:(t.silkscreen??[]).map(e=>e.map(r)),fabrication:t.body?[(e=>[...e,...e[0]?[e[0]]:[]])(t.body.map(r))]:[],origin:`copperflow footprint file ${e}`,...t.placeholder?{placeholder:!0}:{}}}function Tm(e){let t=typeof e.drill==`number`?{width:e.drill,height:e.drill}:e.drill;return{number:e.number,shape:e.shape,x:e.x,y:e.y,width:e.width,height:e.height,rotation:e.rotation??0,layers:e.layers??`top`,...t?{drill:{...t}}:{}}}function Em(e,t,n=[]){let r=n.map(e=>e.x),i=n.map(e=>e.y);for(let t of e){let e=t.rotation*Math.PI/180,n=(Math.abs(t.width*Math.cos(e))+Math.abs(t.height*Math.sin(e)))/2,a=(Math.abs(t.width*Math.sin(e))+Math.abs(t.height*Math.cos(e)))/2;r.push(t.x-n,t.x+n),i.push(t.y-a,t.y+a)}let a=Math.min(...r)-t,o=Math.max(...r)+t,s=Math.min(...i)-t,c=Math.max(...i)+t;return[{x:a,y:s},{x:o,y:s},{x:o,y:c},{x:a,y:c}]}function Dm(e){if(typeof e!=`object`||!e||!Array.isArray(e.pads))return e;let t=e.pads.map(e=>typeof e==`object`&&e&&Number.isInteger(e.number)?{...e,number:String(e.number)}:e);return{...e,pads:t}}var Om=[`chips 0201 0402 0603 0805 1206 1210 1812 2010 2512`,`sod123 sod323`,`sma smb smc (do214ac do214aa do214ab)`,`sot23 sot23_5 sot23_6 sot223 sot89`,...Ct.map(({form:e,pins:t})=>`${e} (N ${km(t)})`),`qfp32 qfp48 qfp64 qfp100, qfp<N>_<b>x<b>_p<pitch> (lqfp, tqfp)`,`qfn16 qfn32 qfn48 with _ep, qfn<N>_<b>x<b>_p<pitch>[_ep<size>]`,`dfn<N>_<a>x<b>_p<pitch>`,`bga<N>_<x>x<y>_p<pitch>`,`dip<N>[_w<spacing>]`,`to220 to92 hc49 hc49s`,`radial<can>x<spacing>`,`pinrow<N>[_p<pitch>] pinrow2x<N>`].join(`; `);function km(e){return e.length>2&&e.every((t,n)=>n===0||t-(e[n-1]??0)===2)?`even ${e[0]}–${e[e.length-1]}`:e.join(`, `)}var Am=[`0201`,`0402`,`0603`,`0805`,`1206`,`1210`,`1812`,`2010`,`2512`],jm=(e,t,n)=>Array.from({length:Math.floor((t-e)/n)+1},(t,r)=>e+r*n),Mm=[...Am,`sod123`,`sod323`,`sot23`,`sot223`,`sot89`,`do214ac`,`do214aa`,`do214ab`,...Ct.flatMap(({form:e,pins:t})=>t.map(t=>e.replace(`<N>`,String(t)))),...[`qfp`,`lqfp`,`tqfp`].flatMap(e=>[32,48,64,100].map(t=>`${e}${t}`)),...[16,32,48].map(e=>`qfn${e}`),...jm(4,64,2).map(e=>`dip${e}`),`to220`,`to92`,`hc49`,`hc49s`,...jm(1,40,1).map(e=>`pinrow${e}`)],Nm=3,Pm=3,Fm=Mm.flatMap(e=>{let t=n(e);return t?[{text:e,kind:t.kind,number:Number(t.code||0),suffix:t.suffix??``}]:[]});function Im(e){let t=n(e);if(!t)return[];let r=Number(t.code||0),i=t.suffix??``,a=e=>(e.suffix===i?0:Pm)+Math.abs(e.number-r);return Fm.filter(e=>e.kind===t.kind).sort((e,t)=>a(e)-a(t)||e.number-t.number||e.text.localeCompare(t.text)).slice(0,Nm).sort((e,t)=>e.number-t.number||e.text.localeCompare(t.text)).map(e=>e.text)}function Lm(e){let t=Im(e);return`copperflow cannot make footprint "${e}":${t.length>0?` nearest are ${t.join(`, `)};`:``} known families are ${Om} (see the skill's parts library reference)`}var Q=(e,t)=>({min:e,max:t}),Rm={label:`DO-214AC (SMA)`,span:Q(4.93,5.28),terminal:Q(.76,1.52),leadWidth:Q(1.25,1.65),bodyLength:Q(3.99,4.5),bodyWidth:Q(2.54,2.79)},zm={label:`DO-214AA (SMB)`,span:Q(5.21,5.59),terminal:Q(.76,1.52),leadWidth:Q(1.95,2.2),bodyLength:Q(4.06,4.57),bodyWidth:Q(3.3,3.94)},Bm={label:`DO-214AB (SMC)`,span:Q(7.75,8.13),terminal:Q(.76,1.52),leadWidth:Q(2.9,3.2),bodyLength:Q(6.6,7.11),bodyWidth:Q(5.59,6.22)},Vm=new Map([[`sma`,Rm],[`smb`,zm],[`smc`,Bm],[`do214ac`,Rm],[`do214aa`,zm],[`do214ab`,Bm]]);function Hm(e){if(!(e.variant!==void 0||e.cross!==void 0||e.size!==void 0||e.pairs!==void 0||Object.keys(e.params).length>0))return`${e.kind}${e.code}${e.suffix??``}`}function Um(e){if(e.kind===`do`&&e.code===`214`&&!Vm.has(`do214${e.suffix??``}`))return D(`do214 needs a suffix: do214ac, do214aa or do214ab`);let t=Hm(e),n=t===void 0?void 0:Vm.get(t);if(!t||!n)return;let r=ae(s({span:n.span,terminal:n.terminal,width:n.leadWidth},_.goals,l),_.roundOff),i={x:n.bodyLength.max/2,y:n.bodyWidth.max/2};return{name:t,pads:r,courtyard:E(r,{x:n.span.max/2,y:Math.max(n.bodyWidth.max,n.leadWidth.max)/2},_),silkscreen:[...he(r,i),ge(r,i)],fabrication:pe(i),origin:`IPC-7351B nominal, ${n.label}`}}var Wm=1,Gm=1.7,Km=.25,qm=1e3,Jm=e=>String(w(e));function Ym(e,t){return`pinrow${e}_p${Jm(t)}mm`}function Xm(e,t,n=0){return{number:String(e),shape:e===1?`rect`:`circle`,x:t,y:n,width:Gm,height:Gm,rotation:0,layers:`through`,drill:{width:Wm,height:Wm}}}function Zm(e){if(e.kind!==`pinrow`||e.variant!==void 0||Object.keys(e.params).some(e=>e!==`p`))return;let t=e.params.p??2.54;if(t===!0||t<=Gm)return;if(e.cross!==void 0)return th(e,t);if(!i(e))return;let n=Number(e.code);if(!Number.isInteger(n)||n<1||n>qm)return;let r=se(n,t).map((e,t)=>Xm(t+1,e));return{name:Ym(n,t),...Qm(r),origin:`Fixed pin row, not an IPC-7351B calculation: ${Jm(t)} mm pitch, ${Wm.toFixed(1)} mm drill, ${Gm.toFixed(1)} mm pads`}}function Qm(e){let t=T(e),n=e=>({x:w(t.x+e),y:w(t.y+e)});return{pads:e,courtyard:de(n(Km)),silkscreen:[fe(n(C))],fabrication:[]}}var $m=.3,eh=.1;function th(e,t){let n=e.suffix===void 0&&e.size===void 0&&e.pairs===void 0,r=Number(e.cross);if(!n)return;if(e.code!==`2`)return D(`headers have one row (pinrow<N>) or two (pinrow2x<N>)`);if(!Number.isInteger(r)||r<1||r>qm/2)return D(`a two-row header has 1 to ${qm/2} pins a row`);let i=se(r,t).flatMap((e,n)=>[Xm(2*n+1,e,w(t/2)),Xm(2*n+2,e,w(-t/2))]),a=Qm(i),o=T(i),s=w(-(o.x+C+$m)),c=w(t/2+Gm/2);return{name:`pinrow2x${r}_p${Jm(t)}mm`,...a,courtyard:de({x:w(-s+eh),y:w(o.y+Km)}),silkscreen:[...a.silkscreen,[{x:s,y:c},{x:s,y:w(c-Gm)}]],origin:`Fixed two-row pin header, not an IPC-7351B calculation: ${Jm(t)} mm pitch, ${Wm.toFixed(1)} mm drill, ${Gm.toFixed(1)} mm pads`}}var nh=(e,t,n,r,i)=>({label:`LQFP-${e}`,pitch:t,span:n,terminal:A(.45,.75),leadWidth:r,bodyAcross:i,bodyAlong:i}),rh=new Map([[`32`,nh(32,.8,A(8.85,9.15),A(.3,.4),A(6.9,7.1))],[`48`,nh(48,.5,A(8.85,9.15),A(.17,.27),A(6.9,7.1))],[`64`,nh(64,.5,A(11.85,12.15),A(.17,.27),A(9.9,10.1))],[`100`,nh(100,.5,A(15.75,16.25),A(.17,.27),A(13.9,14.1))]]),ih=(e,t,n)=>({label:`QFN-${e}`,pitch:.5,span:t,terminal:A(.3,.5),leadWidth:A(.18,.3),bodyAcross:t,bodyAlong:t,exposedPad:n}),ah=new Map([[`16`,ih(16,A(2.9,3.1),A(1.45,1.75))],[`32`,ih(32,A(4.9,5.1),A(2.95,3.25))],[`48`,ih(48,A(6.9,7.1),A(4.95,5.25))]]);function oh(e,t,n){let r=se(e/4,t),i=[...r].reverse(),a=n.centre,o=(e,t)=>({x:e,y:t,width:n.length,height:n.width}),s=(e,t)=>({x:e,y:t,width:n.width,height:n.length});return[...i.map(e=>o(-a,e)),...r.map(e=>s(e,-a)),...r.map(e=>o(a,e)),...i.map(e=>s(e,a))].map((e,t)=>S(String(t+1),e.x,e.y,e.width,e.height))}var sh=new Set([`qfn`,...new Set([`qfp`,`lqfp`,`tqfp`])]);function ch(e){if(sh.has(e.kind)&&e.variant===void 0)return e.size?dh(e,e.size):lh(e)}function lh(e){let t=e.kind===`qfn`,n=t?ah.get(e.code):rh.get(e.code);if(!n||!i(e)||!it(e.params,n,t?[`ep`]:[]))return;let r=e.params.ep===!0&&n.exposedPad?uh(n.exposedPad):void 0;return fh(e.kind+e.code+(r?`_ep`:``),Number(e.code),n,t,r)}var uh=e=>{let t=w((e.min+e.max)/2);return{x:t,y:t}};function dh(e,t){let n=e.kind===`qfn`,r=n?`QFN`:`QFP`,i=e.params.p;if(e.cross!==void 0||e.suffix!==void 0)return;if(typeof i!=`number`)return D(`a ${r} named by its body needs its pitch, such as _p0.5`);let a=n?Yt(e.code,t,i):Zt(e.code,t,i);if(Ee(a))return a;let o=n?Ae(e,r):ke(e)?void 0:D(`a QFP takes only _p`);return Ee(o)?o:fh(`${e.kind}${e.code}_${O(t[0])}x${O(t[1])}_p${O(i)}${o?`_ep${Oe(o)}`:``}`,Number(e.code),a,n,o)}function fh(e,t,n,r,i){let{row:a,table:o}=r?tt(n):et(n),s=oh(t,n.pitch,a),c=i?[...s,S(String(t+1),0,0,i.x,i.y)]:s,l=je(c,i!==void 0);if(l)return l;let u=n.bodyAcross.max/2,d=Math.max(n.span.max,n.bodyAcross.max)/2;return{name:e,pads:c,courtyard:E(c,{x:d,y:d},o),silkscreen:be(s,{x:u,y:u}),fabrication:pe({x:u,y:u}),origin:`IPC-7351B nominal, ${n.label}${i?` with exposed pad`:``}`}}var ph=[{upTo:7.99,lead:A(.4,.5)},{upTo:10,lead:A(.55,.65)},{upTo:1/0,lead:A(.75,.85)}],mh=3,hh=40,gh=.4;function _h(e){let t=w(e.y+e.height/2+C+.05+gh);return[[{x:w(e.x-gh),y:t},{x:w(e.x+gh),y:t}],[{x:w(e.x),y:w(t-gh)},{x:w(e.x),y:w(t+gh)}]]}function vh(e){let t=e.suffix===void 0&&e.size===void 0&&e.pairs===void 0&&e.variant===void 0;if(e.kind!==`radial`||!t||Object.keys(e.params).length>0)return;if(e.cross===void 0)return D(`a radial capacitor is radial<can diameter>x<lead spacing>, such as radial6.3x2.5`);let n=Number(e.code),r=Number(e.cross),i=ph.find(e=>n<=e.upTo)?.lead;if(!i||n<mh||n>hh)return D(`the can is ${mh} to ${hh} mm across`);if(r<=0||r>=n)return D(`the leads must be closer together than the ${O(n)} mm can is wide`);let a=dt(ut(i));if(r-a.pad<.1)return D(`${a.pad} mm lands ${O(r)} mm apart would touch`);let o=[ft(`1`,w(-r/2),0,a,!0),ft(`2`,w(r/2),0,a)],s=n/2,c=Math.max(s,r/2+a.pad*Math.SQRT2/2+C);return{name:`radial${O(n)}x${O(r)}`,pads:o,courtyard:E(o,{x:c,y:c},lt),silkscreen:[xe({x:0,y:0},c,0,360,5),..._h(o[0])],fabrication:[xe({x:0,y:0},s,0,360,5)],origin:`Through-hole, radial electrolytic ${O(n)} mm can, leads ${O(r)} mm apart: ${a.drill} mm holes, ${a.pad} mm lands (IPC-2222 level B)`}}var yh=(e,t)=>({min:e,max:t}),bh={123:{label:`SOD-123`,span:yh(3.55,3.85),terminal:yh(.25,.4),leadWidth:yh(.52,.62),bodyLength:yh(2.55,2.85),bodyWidth:yh(1.4,1.7)},323:{label:`SOD-323`,span:yh(2.3,2.7),terminal:yh(.2,.4),leadWidth:yh(.25,.35),bodyLength:yh(1.6,1.8),bodyWidth:yh(1.2,1.4)}};function xh(e){if(!Object.hasOwn(bh,e))return;let t=bh[e],n={span:t.span,terminal:t.terminal,width:t.leadWidth},r=ae(s(n,ee(n,t.bodyLength.max),l),p.roundOff),i={x:t.bodyLength.max/2,y:t.bodyWidth.max/2},a={x:Math.max(t.span.max,t.bodyLength.max)/2,y:Math.max(t.bodyWidth.max,t.leadWidth.max)/2};return{name:`sod${e}`,pads:r,courtyard:E(r,a,p),silkscreen:[...he(r,i),ge(r,i)],fabrication:pe(i),origin:`IPC-7351B nominal, ${t.label}`}}var Sh={pkg:{label:`SOT-23`,pitch:.95,span:A(2.1,2.5),terminal:A(.15,.45),leadWidth:A(.38,.48),bodyAcross:A(1.2,1.4),bodyAlong:A(2.8,3)},bottom:[-1,1],top:[0]},Ch=e=>({label:`SOT-23-${e}`,pitch:.95,span:A(2.7,3),terminal:A(.35,.55),leadWidth:A(.35,.5),bodyAcross:A(1.5,1.7),bodyAlong:A(2.9,3.1)}),wh=new Map([[void 0,Sh],[`5`,{pkg:Ch(5),bottom:[-1,0,1],top:[1,-1]}],[`6`,{pkg:Ch(6),bottom:[-1,0,1],top:[1,0,-1]}]]);function Th(e,t,n,r){let i=t=>w(t*e.pkg.pitch),a=e.bottom.map((e,a)=>S(String(a+1),i(e),-t,r,n)),o=e.bottom.length+1,s=e.top.map((e,a)=>S(String(o+a),i(e),t,r,n));return[...a,...s]}function Eh(e){let t=e.kind===`sot`&&e.code===`23`?wh.get(e.variant):void 0;if(!t||!i(e)||!it(e.params,t.pkg))return;let{pkg:n}=t,{row:r,table:a}=et(n),o=Th(t,r.centre,r.length,r.width),s={x:n.bodyAlong.max/2,y:n.bodyAcross.max/2},c=Math.max(...[...t.bottom,...t.top].map(Math.abs))*n.pitch+n.leadWidth.max/2,l={x:Math.max(s.x,c),y:n.span.max/2};return{name:e.variant===void 0?`sot23`:`sot23_${e.variant}`,pads:o,courtyard:E(o,l,a),silkscreen:ve(o,s),fabrication:pe(s),origin:`IPC-7351B nominal, ${n.label}`}}var Dh={pkg:{label:`SOT-223`,pitch:2.3,span:A(6.7,7.3),terminal:A(.7,1.1),leadWidth:A(.6,.8),bodyAcross:A(3.3,3.7),bodyAlong:A(6.3,6.7)},tabWidth:A(2.9,3.1),tabNumber:`4`},Oh={pkg:{label:`SOT-89`,pitch:1.5,span:A(3.94,4.25),terminal:A(.89,1.2),leadWidth:A(.44,.56),bodyAcross:A(2.4,2.6),bodyAlong:A(4.4,4.6)},tabWidth:A(1.62,1.83),tabNumber:`2`,tabUnderBody:!0},kh=new Map([[`223`,Dh],[`89`,Oh]]),Ah=.3;function jh(e){let{row:t}=et(e.pkg),n=et({...e.pkg,leadWidth:e.tabWidth}).row,r=e.pkg.pitch,i=[-r,0,r].map((e,n)=>S(String(n+1),e,-t.centre,t.width,t.length)),a=n.centre+n.length/2,o=e.tabUnderBody?-t.centre+t.length/2+Ah:n.centre-n.length/2;return[...i,S(e.tabNumber,0,w((a+o)/2),n.width,w(a-o))]}function Mh(e,t){let n=T(e),r=w(Math.max(t.x,n.x+C)),i=w(t.y);return[[{x:-r,y:-w(n.y)},{x:-r,y:i}],[{x:r,y:-i},{x:r,y:i}]]}function Nh(e){let t=e.kind===`sot`?kh.get(e.code):void 0;if(!t||!i(e)||e.variant!==void 0||Object.keys(e.params).length>0)return;let{pkg:n}=t,{table:r}=et(n),a=jh(t),o={x:n.bodyAlong.max/2,y:n.bodyAcross.max/2},s=n.pitch+n.leadWidth.max/2,c={x:Math.max(o.x,s,t.tabWidth.max/2),y:n.span.max/2};return{name:`sot${e.code}`,pads:a,courtyard:E(a,c,r),silkscreen:Mh(a,o),fabrication:pe(o),origin:`IPC-7351B nominal, ${n.label}`}}var Ph=2.54,Fh=A(.7,.9),Ih=A(.45,.6),Lh=10.66,Rh=-2,zh=2.5,Bh=1.23,Vh=Lh/2;function Hh(){let[e,t,n]=[w(Vh),w(Rh),w(zh)];return[{x:-e,y:t},{x:e,y:t},{x:e,y:n},{x:-e,y:n},{x:-e,y:t}]}function Uh(e){let t=i(e)&&e.variant===void 0&&Object.keys(e.params).length===0;if(e.kind!==`to`||e.code!==`220`||!t)return;let n=dt(ut(Fh,Ih)),r=se(3,Ph).map((e,t)=>ft(String(t+1),e,0,n,t===0)),a=[{x:-w(Vh),y:w(Bh)},{x:w(Vh),y:w(Bh)}];return{name:`to220`,pads:r,courtyard:E(r,{x:Vh,y:Math.max(2,zh)},lt),silkscreen:[Hh(),a,Te(r[0],-2.3)],fabrication:[Hh(),a],origin:`Through-hole, TO-220 upright: ${n.drill} mm holes, ${n.pad} mm lands (IPC-2222 level B)`}}var Wh=2.54,Gh=A(.36,.53),Kh=A(.36,.51),qh=5.21/2,Jh=-1.5850000000000004;function Yh(){let e=Math.asin(Jh/qh)*180/Math.PI;return xe({x:0,y:0},qh,e,180-e,2).concat([xe({x:0,y:0},qh,e,e)[0]])}function Xh(e){let t=i(e)&&e.variant===void 0&&Object.keys(e.params).length===0;if(e.kind!==`to`||e.code!==`92`||!t)return;let n=dt(ut(Gh,Kh)),r=[-2.54,0,Wh].map((e,t)=>ft(String(t+1),e,0,n,t===0)),a=Yh();return{name:`to92`,pads:r,courtyard:E(r,{x:qh,y:qh},lt),silkscreen:[...Ce(a,r),Te(r[0],w(-1.8850000000000005))],fabrication:[a],origin:`Through-hole, TO-92 with leads formed to 2.54 mm: ${n.drill} mm holes, ${n.pad} mm lands (IPC-2222 level B)`}}var Zh=e=>i(e)&&e.variant===void 0&&Object.keys(e.params).length===0,Qh=[e=>e.kind===``&&Zh(e)?Qe(e.code):void 0,e=>e.kind===`sod`&&Zh(e)?xh(e.code):void 0,Eh,Nh,Um,Dt,ch,Qt,Je,Zm,ln,Uh,Xh,bt,vh],$h=512,eg=new Map,tg=/^parts\/[A-Za-z0-9._-]+\/footprint\.yaml$/,ng=e=>e.includes(`/`);function rg(e,t){if(ng(e))return og(ig(e,t));let n=eg.get(e);if(n)return n;let r=og(ag(e));return eg.size>=$h&&eg.delete(eg.keys().next().value),eg.set(e,r),r}function ig(e,t){if(!tg.test(e)||e.split(`/`).some(e=>e.includes(`..`)))return{error:`"${e}" is not a footprint file: only parts/<id>/footprint.yaml can be read`};if(!t)return{error:`"${e}" is a footprint file and needs a way to read files`};let n=t(e);return n===void 0?{error:`${e}: footprint file not found`}:Sm(e,n)}function ag(e){let t=n(e);if(t)for(let n of Qh){let r=n(t);if(Ee(r))return{error:`copperflow cannot make footprint "${e}": ${r.refused}`};if(r)return r}return{error:Lm(e)}}function og(e){if(typeof e==`object`&&e&&!Object.isFrozen(e)){for(let t of Object.values(e))og(t);Object.freeze(e)}return e}var sg=`Type a footprint string such as soic8, qfn32_5x5_p0.5 or hc49s.`;function cg(e,t){let n=e.trim();if(n===``)return{error:sg};if(n.includes(`/`))return{error:`"${n}" is not a footprint string`};let r=rg(n);if(`error`in r)return{error:r.error};let i=ug([...r.courtyard,...r.silkscreen.flat(),...r.fabrication.flat(),...r.pads.flatMap(lg)]),a=Math.min((t.width-20)/Math.max(i.width,1e-6),(t.height-20)/Math.max(i.height,1e-6)),o=e=>({x:t.width/2+(e.x-i.cx)*a,y:t.height/2-(e.y-i.cy)*a}),s=r.pads.map(e=>{let t=o(e);return{number:e.number,shape:e.shape,x:t.x,y:t.y,width:e.width*a,height:e.height*a,rotation:-e.rotation,through:e.layers===`through`,...e.drill?{drill:Math.min(e.drill.width,e.drill.height)*a}:{}}}),c=ug(r.courtyard),l=r.pads.length;return{pads:s,courtyard:r.courtyard.map(o),silkscreen:r.silkscreen.map(e=>e.map(o)),body:r.fabrication.map(e=>e.map(o)),scale:a,summary:`${l} pad${l===1?``:`s`}, courtyard ${dg(c.width)} × ${dg(c.height)} mm`}}function lg(e){let[t,n]=[e.width/2,e.height/2],r=e.rotation*Math.PI/180,[i,a]=[Math.cos(r),Math.sin(r)];return[[-t,-n],[t,-n],[t,n],[-t,n]].map(([t=0,n=0])=>({x:e.x+t*i-n*a,y:e.y+t*a+n*i}))}function ug(e){let t=e.map(e=>e.x),n=e.map(e=>e.y),[r,i,a,o]=[Math.min(...t),Math.max(...t),Math.min(...n),Math.max(...n)];return{width:i-r,height:o-a,cx:(r+i)/2,cy:(a+o)/2}}var dg=e=>Number(e.toFixed(2)),fg=[`power_in`,`power_out`,`ground`,`input`,`output`,`bidirectional`,`passive`,`no_connect`],pg=/^[A-Za-z](?:[A-Za-z0-9._-]{0,62}[A-Za-z0-9])?$/,mg=/^[1-9][0-9]*$/,hg=/^[A-Za-z_][A-Za-z0-9_]*$/,gg=`${fg.slice(0,-1).join(`, `)} or ${fg[fg.length-1]}`;function _g(e){let t=e.split(/\r?\n/),n=yg(t),r=t.findIndex(e=>e.trim()!==``),i=[],a=[],o=new Map;return t.forEach((e,t)=>{let s=e.trim();if(s===``)return;let c=bg(s,n);if(t===r&&Sg(s,c[0]??``))return;let l=t+1,u=Cg(c,o);typeof u==`string`?a.push({line:l,text:s,message:`Line ${l}: ${u}`}):(o.set(u.number,l),i.push(u))}),{pins:i,errors:a}}function vg(e){let t=e.replace(/[^A-Za-z0-9_]/g,`_`);return/^[A-Za-z_]/.test(t)?t:`_${t}`}function yg(e){let t=e.map(e=>e.trim()).filter(e=>e!==``);return t.some(e=>e.includes(` `))?`tab`:t.some(e=>/^[^\s,]+\s*,/.test(e))?`comma`:t.some(e=>/ {2,}/.test(e))?`spaces`:`space`}function bg(e,t){let n={tab:/\t/,comma:/,/,spaces:/ {2,}/,space:/\s+/}[t],r=t===`space`||t===`spaces`&&!/ {2,}/.test(e),i=e.split(r?/\s+/:n).map(e=>e.trim());return r&&i.length>3?[...i.slice(0,3),i.slice(3).join(` `)]:i}var xg=/\b(pin|no|number|name|type|function|description)\b/i;function Sg(e,t){return!/[0-9]/.test(e)||!mg.test(t)&&xg.test(e)}function Cg(e,t){let[n=``,r=``,i=``,...a]=e;if(!mg.test(n))return`"${n}" is not a pin number; pins are numbered 1, 2, 3 …`;let o=t.get(n);if(o!==void 0)return`pin ${n} is already on line ${o}`;if(r===``)return`pin ${n} has no name`;if(!hg.test(r))return`"${r}" is not a pin name; use letters, digits and _, starting with a letter (e.g. ${vg(r)})`;let s=i===``?`passive`:wg(i);if(!s)return`"${i}" is not a pin type; use ${gg}`;let c=a.filter(e=>e!==``).join(`, `);return{number:n,name:r,type:s,...c?{description:c}:{}}}function wg(e){let t=e.toLowerCase().replace(/[-\s]+/g,`_`);return fg.find(e=>e===t)}var Tg={id:``,title:``,manufacturer:``,mpn:``,packageKind:`string`,packageText:``,pins:[],suppliers:[{supplier:`lcsc`,number:``}],datasheet:``,replace:!1},Eg=/^[a-z0-9_]+$/,Dg=e=>e.number.trim()===``&&e.name.trim()===``,Og=(e,t)=>(Number(e.number)||1/0)-(Number(t.number)||1/0);function kg(e){let t=Math.max(0,...e.map(e=>Number(e.number)).filter(e=>Number.isInteger(e)));return[...e,{number:String(t+1),name:``,type:`passive`,description:``}]}function Ag(e,t,n){return e.map((e,r)=>r===t?{...e,...n}:e)}function jg(e,t){return e.filter((e,n)=>n!==t)}function Mg(e,t){let n=_g(t),r=new Map(n.pins.map(e=>[e.number,{...e,description:e.description??``}]));return{pins:[...e.filter(e=>!Dg(e)&&!r.has(e.number.trim())),...r.values()].sort(Og),errors:n.errors}}function Ng(e){let t=e.id.trim(),n=e.title.trim(),r=Fg(e.pins),i=Ig(e.suppliers),a=e.datasheet.trim(),o=[...t===``?[`Give the part an id, such as its part number.`]:pg.test(t)&&!t.includes(`..`)?[]:[`"${t}" is not a part id: start with a letter, end with a letter or digit, and use letters, digits, ".", "_" or "-".`],...n===``?[`Give the part a title.`]:[],...Pg(e),...r.problems,...i.problems,...a===``||/^https?:\/\/\S+$/.test(a)?[]:[`The datasheet link must start with http:// or https://.`]];if(o.length>0)return{problems:o};let s=t=>e[t].trim()?{[t]:e[t].trim()}:{};return{id:t,title:n,...s(`manufacturer`),...s(`mpn`),package:e.packageKind===`file`?{file:`footprint.yaml`}:e.packageText.trim(),pins:r.rows,...Object.keys(i.record).length>0?{suppliers:i.record}:{},...a?{datasheet:{url:a}}:{},replace:e.replace}}function Pg(e){if(e.packageKind===`file`)return[];let t=e.packageText.trim();if(t===``)return[`Type a footprint string such as soic8, or choose a footprint file.`];if(t.includes(`/`))return[`"${t}" is not a footprint string.`];let n=rg(t);return`error`in n?[n.error]:[]}function Fg(e){let t=e.map((e,t)=>({pin:e,row:t+1})).filter(({pin:e})=>!Dg(e));if(t.length===0)return{rows:[],problems:[`Add the pins: type them in the rows or paste the datasheet's pin table.`]};let n=[],r=[],i=new Map;for(let{pin:e,row:a}of t){let[t,o,s]=[e.number.trim(),e.name.trim(),e.description.trim()],c=e=>r.push(`Pin row ${a}: ${e}`);if(!mg.test(t)){c(`"${t}" is not a pin number; pins are numbered 1, 2, 3 ….`);continue}let l=i.get(t);l===void 0?i.set(t,a):c(`pin ${t} is already in row ${l}.`),o===``?c(`pin ${t} has no name.`):hg.test(o)||c(`"${o}" is not a pin name; use letters, digits and _, starting with a letter (e.g. ${vg(o)}).`),n.push({number:t,name:o,type:e.type,...s?{description:s}:{}})}return{rows:n,problems:r}}function Ig(e){let t={},n=[];for(let r of e){let[e,i]=[r.supplier.trim(),r.number.trim()];if(e===``&&i===``)continue;let a=e.toLowerCase();if(!Eg.test(a)||i===``||a in t){let t=a.split(/[^a-z0-9_]/)[0]||`lcsc`;n.push(`Supplier "${e}": name it with lower-case letters, digits and _ (e.g. ${t}) and give its part number.`)}else t[a]=i}return{record:t,problems:n}}var $=t(),Lg={width:240,height:150},Rg={board:a.background,pad:a.topCopper,throughPad:a.multiLayer,drill:a.drill,outline:a.topAssembly,silk:a.topSilk};function zg(e,t){let n=window.devicePixelRatio||1;e.width=Lg.width*n,e.height=Lg.height*n;let r=e.getContext(`2d`);if(!r)return;r.setTransform(n,0,0,n,0,0),r.fillStyle=Rg.board,r.fillRect(0,0,Lg.width,Lg.height);let i=(e,t,n,i=[])=>{r.strokeStyle=t,r.lineWidth=1,r.setLineDash(i);for(let t of e)r.beginPath(),t.forEach((e,t)=>t===0?r.moveTo(e.x,e.y):r.lineTo(e.x,e.y)),n&&r.closePath(),r.stroke();r.setLineDash([])};i([t.courtyard],Rg.outline,!0,[3,3]),i(t.body,Rg.outline,!1),i(t.silkscreen,Rg.silk,!1);for(let e of t.pads)r.save(),r.translate(e.x,e.y),r.rotate(e.rotation*Math.PI/180),r.fillStyle=e.through?Rg.throughPad:Rg.pad,r.beginPath(),e.shape===`circle`||e.shape===`oval`?r.ellipse(0,0,e.width/2,e.height/2,0,0,2*Math.PI):r.rect(-e.width/2,-e.height/2,e.width,e.height),r.fill(),e.drill&&(r.fillStyle=Rg.drill,r.beginPath(),r.arc(0,0,e.drill/2,0,2*Math.PI),r.fill()),r.restore();let a=t.pads.find(e=>e.number===`1`);a&&(r.fillStyle=Rg.silk,r.font=`10px sans-serif`,r.fillText(`1`,a.x-a.width/2-8,a.y+3))}function Bg({text:e}){let t=(0,o.useRef)(null),n=(0,o.useMemo)(()=>cg(e,Lg),[e]);return(0,o.useEffect)(()=>{t.current&&!(`error`in n)&&zg(t.current,n)},[n]),`error`in n?(0,$.jsx)(`p`,{className:`new-part-preview-note`,children:n.error}):(0,$.jsxs)(`figure`,{className:`new-part-preview`,children:[(0,$.jsx)(`canvas`,{ref:t,style:Lg,role:`img`,"aria-label":`Footprint ${e.trim()}: ${n.summary}`}),(0,$.jsx)(`figcaption`,{children:n.summary})]})}function Vg({pins:e,onChange:t}){return(0,$.jsxs)(`table`,{className:`new-part-pins`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{children:`Pin`}),(0,$.jsx)(`th`,{children:`Name`}),(0,$.jsx)(`th`,{children:`Type`}),(0,$.jsx)(`th`,{children:`Description`}),(0,$.jsx)(`th`,{})]})}),(0,$.jsx)(`tbody`,{children:e.map((n,r)=>(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`td`,{children:(0,$.jsx)(`input`,{"aria-label":`Row ${r+1} pin number`,value:n.number,onChange:n=>t(Ag(e,r,{number:n.target.value}))})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`input`,{"aria-label":`Row ${r+1} pin name`,value:n.name,onChange:n=>t(Ag(e,r,{name:n.target.value}))})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`select`,{"aria-label":`Row ${r+1} pin type`,value:n.type,onChange:n=>t(Ag(e,r,{type:n.target.value})),children:fg.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`input`,{"aria-label":`Row ${r+1} description`,value:n.description,onChange:n=>t(Ag(e,r,{description:n.target.value}))})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`Remove row ${r+1}`,onClick:()=>t(jg(e,r)),children:`×`})})]},r))})]})}function Hg({pins:e,onChange:t}){let[n,r]=(0,o.useState)(``),[i,a]=(0,o.useState)([]),s=(0,o.useId)();return(0,$.jsxs)(`div`,{className:`new-part-paste`,children:[(0,$.jsx)(`label`,{htmlFor:s,children:`Paste a pin table: one pin per line, "1 VDD power_in", tab or comma separated; no type means passive.`}),(0,$.jsx)(`textarea`,{id:s,rows:4,value:n,onChange:e=>r(e.target.value)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{let i=Mg(e,n);t(i.pins),a(i.errors),i.errors.length===0&&r(``)},disabled:n.trim()===``,children:`Add pasted pins`}),i.length>0&&(0,$.jsx)(`ul`,{role:`alert`,children:i.map(e=>(0,$.jsx)(`li`,{children:e.message},e.line))})]})}function Ug({fields:e,onChange:t}){let n=(n,r,i)=>t(e.map((e,t)=>t===n?{...e,[r]:i}:e));return(0,$.jsxs)($.Fragment,{children:[e.map((e,t)=>(0,$.jsxs)(`div`,{className:`new-part-supplier`,children:[(0,$.jsx)(`input`,{"aria-label":`Supplier ${t+1}`,placeholder:`lcsc`,value:e.supplier,onChange:e=>n(t,`supplier`,e.target.value)}),(0,$.jsx)(`input`,{"aria-label":`Supplier ${t+1} part number`,placeholder:`C16212`,value:e.number,onChange:e=>n(t,`number`,e.target.value)})]},t)),(0,$.jsx)(`button`,{type:`button`,className:`new-part-add`,onClick:()=>t([...e,{supplier:``,number:``}]),children:`Add supplier`})]})}function Wg({result:e}){return(0,$.jsxs)(`div`,{className:`import-result`,role:`status`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`strong`,{children:r(e)})}),e.notes.length>0&&(0,$.jsx)(`ul`,{children:e.notes.map(e=>(0,$.jsx)(`li`,{children:e},e))}),(0,$.jsx)(`h3`,{children:`Written`}),(0,$.jsx)(`ul`,{children:e.files.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`code`,{children:e})},e))}),(0,$.jsx)(`h3`,{children:(0,$.jsx)(`code`,{children:e.verification})}),(0,$.jsx)(`pre`,{className:`new-part-checklist`,children:e.checklist})]})}function Gg({panel:e,onClose:t}){let[n,r]=(0,o.useState)(()=>({...Tg,pins:kg([])})),[i,a]=(0,o.useState)([]),[s,c]=(0,o.useState)(!1),[l,u]=(0,o.useState)(),d=(0,o.useId)(),f=(e,t)=>r(n=>({...n,[e]:t})),p=async r=>{if(r.preventDefault(),s)return;if(l)return t();let i=Ng(n);if(`problems`in i)return a(i.problems);c(!0),a([]);try{u(await e.create(i))}catch(e){a([e.message])}finally{c(!1)}};if(l)return(0,$.jsxs)(`form`,{className:`rules-form new-part-form`,onSubmit:e=>void p(e),children:[(0,$.jsx)(Wg,{result:l}),(0,$.jsx)(`button`,{type:`submit`,children:`Close`})]});let m=(e,t,r)=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`${d}-${e}`,children:t}),(0,$.jsx)(`input`,{id:`${d}-${e}`,value:n[e],placeholder:r,onChange:t=>f(e,t.target.value)})]});return(0,$.jsxs)(`form`,{className:`rules-form new-part-form`,onSubmit:e=>void p(e),children:[(0,$.jsxs)(`fieldset`,{className:`new-part-fields`,disabled:s,children:[m(`id`,`Part id`,`AP2112K-3.3`),m(`title`,`Title`,`3.3 V LDO regulator`),m(`manufacturer`,`Manufacturer`,`Diodes Incorporated`),m(`mpn`,`MPN`,`AP2112K-3.3TRG1`),(0,$.jsx)(`span`,{children:`Package`}),(0,$.jsxs)(`div`,{className:`new-part-package`,children:[(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`radio`,name:`${d}-kind`,checked:n.packageKind===`string`,onChange:()=>f(`packageKind`,`string`)}),` Footprint string`]}),(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`radio`,name:`${d}-kind`,checked:n.packageKind===`file`,onChange:()=>f(`packageKind`,`file`)}),` Footprint file`]})]}),n.packageKind===`string`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`${d}-package`,children:`Footprint`}),(0,$.jsx)(`input`,{id:`${d}-package`,value:n.packageText,placeholder:`soic8, qfn32_5x5_p0.5, hc49s`,onChange:e=>f(`packageText`,e.target.value)}),(0,$.jsx)(Bg,{text:n.packageText})]}):(0,$.jsx)(`p`,{children:`footprint.yaml is written as a placeholder, one pad per pin. The schematic can use the part now; the board reports an error for it until you draw its pads from the datasheet's land pattern and delete "placeholder: true".`}),(0,$.jsx)(`h3`,{children:`Pins`}),(0,$.jsx)(Vg,{pins:n.pins,onChange:e=>f(`pins`,e)}),(0,$.jsx)(`button`,{type:`button`,className:`new-part-add`,onClick:()=>f(`pins`,kg(n.pins)),children:`Add pin`}),(0,$.jsx)(Hg,{pins:n.pins,onChange:e=>f(`pins`,e)}),(0,$.jsx)(`h3`,{children:`Suppliers`}),(0,$.jsx)(Ug,{fields:n.suppliers,onChange:e=>f(`suppliers`,e)}),m(`datasheet`,`Datasheet URL`,`https://…`),(0,$.jsxs)(`label`,{className:`make-sheet-rename`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n.replace,onChange:e=>f(`replace`,e.target.checked)}),`Replace a part with this id that is not verified`]})]}),i.length>0&&(0,$.jsx)(`ul`,{className:`new-part-problems`,role:`alert`,children:i.map(e=>(0,$.jsx)(`li`,{children:e},e))}),(0,$.jsx)(`p`,{children:`The part is written unverified; check it against the datasheet in its verification.md.`}),(0,$.jsx)(`button`,{type:`submit`,disabled:s,children:s?`Writing…`:`Create part`})]})}export{Gg as NewPartForm};
|