Skip to content

Instantly share code, notes, and snippets.

@amritk
Created October 23, 2024 19:27
Show Gist options
  • Save amritk/84171dd8f425cfd9309db66beb3c01dc to your computer and use it in GitHub Desktop.
Save amritk/84171dd8f425cfd9309db66beb3c01dc to your computer and use it in GitHub Desktop.
Testing api client
This file has been truncated, but you can view the full file.
!function(){"use strict";try{if("undefined"!=typeof document){var a=document.createElement("style");a.appendChild(document.createTextNode('.scalar-icon[data-v-a4126bd9],.scalar-icon[data-v-a4126bd9] *{stroke-width:var(--3c7f90fa)}.scalar-modal-layout[data-v-e37b0bd8]{animation:fadein-layout-e37b0bd8 ease-in-out .3s forwards}.scalar-modal[data-v-e37b0bd8]{animation:fadein-modal-e37b0bd8 ease-in-out .3s forwards;animation-delay:.1s;position:fixed;left:0;top:0;right:0;box-shadow:var(--scalar-shadow-2);transform:translate3d(0,10px,0)}.dark-mode .scalar-modal[data-v-e37b0bd8]{background-color:color-mix(in srgb,var(--scalar-background-1),black)}.scalar-modal.scalar-modal-search[data-v-e37b0bd8]{max-width:540px;max-height:440px;background-color:transparent}.modal-content-search .modal-body[data-v-e37b0bd8]{padding:0;overflow:hidden;display:flex;flex-direction:column;max-height:440px}@media (max-width: 1280px){.scalar-modal[data-v-e37b0bd8]{max-height:calc(100% - 56px);top:28px}}@keyframes fadein-layout-e37b0bd8{0%{opacity:0}to{opacity:1}}@keyframes fadein-modal-e37b0bd8{0%{opacity:0;transform:translate3d(0,10px,0)}to{opacity:1;transform:translateZ(0)}}.full-size-styles[data-v-e37b0bd8]{transform:translateZ(0);animation:fadein-layout-e37b0bd8 ease-in-out .3s forwards;max-height:100%!important;top:0!important;width:100%!important;border-radius:0!important;background-color:color-mix(in srgb,var(--scalar-background-1),transparent 6%)!important}@layer scalar-base,scalar-theme;@layer scalar-base{body{margin:0;line-height:inherit}}:where(.scalar-app){font-family:var(--scalar-font);line-height:1.15;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4}:where(.scalar-app) *,:where(.scalar-app) *:before,:where(.scalar-app) *:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--scalar-border-color);outline-width:1px;outline-style:none;outline-color:var(--scalar-color-accent);font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:inherit;font-weight:inherit;line-height:inherit;color:inherit;margin:unset;padding:unset;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:where(.scalar-app) :before,:where(.scalar-app) :after{--tw-content: ""}:where(.scalar-app) button,:where(.scalar-app) input,:where(.scalar-app) optgroup,:where(.scalar-app) select,:where(.scalar-app) textarea,:where(.scalar-app) ::file-selector-button{background:transparent}:where(.scalar-app) ol,:where(.scalar-app) ul,:where(.scalar-app) menu{list-style:none}:where(.scalar-app) input:where(:not([type=button],[type=reset],[type=submit])),:where(.scalar-app) select,:where(.scalar-app) textarea{border-radius:var(--scalar-radius);border-width:1px}:where(.scalar-app) input::-moz-placeholder{color:var(--scalar-color-3);font-family:var(--scalar-font)}:where(.scalar-app) input::placeholder{color:var(--scalar-color-3);font-family:var(--scalar-font)}:where(.scalar-app) input[type=search]::-webkit-search-cancel-button,:where(.scalar-app) input[type=search]::-webkit-search-decoration{-webkit-appearance:none;-moz-appearance:none;appearance:none}:where(.scalar-app) input:-webkit-autofill{-webkit-background-clip:text!important;background-clip:text!important}:where(.scalar-app) :focus-visible{outline-style:solid}:where(.scalar-app) button,:where(.scalar-app) [role=button]{cursor:pointer}:where(.scalar-app) :disabled{cursor:default}:where(.scalar-app) img,:where(.scalar-app) svg,:where(.scalar-app) video,:where(.scalar-app) canvas,:where(.scalar-app) audio,:where(.scalar-app) iframe,:where(.scalar-app) embed,:where(.scalar-app) object{display:block;vertical-align:middle}:where(.scalar-app) [hidden]{display:none}.scalar-app .cm-scroller,.scalar-app .custom-scroll{overflow-y:auto;scrollbar-color:transparent transparent;scrollbar-width:thin;-webkit-overflow-scrolling:touch}.scalar-app .custom-scroll-self-contain-overflow{overscroll-behavior:contain}.scalar-app .cm-scroller:hover,.scalar-app .custom-scroll:hover,.scalar-app.scalar-scrollbars-obtrusive .cm-scroller,.scalar-app.scalar-scrollbars-obtrusive .custom-scroll{scrollbar-color:var(--scalar-scrollbar-color, transparent) transparent}.scalar-app .cm-scroller:hover::-webkit-scrollbar-thumb,.scalar-app .custom-scroll:hover::-webkit-scrollbar-thumb{background:var(--scalar-scrollbar-color);background-clip:content-box;border:3px solid transparent}.scalar-app .cm-scroller::-webkit-scrollbar-thumb:active,.scalar-app .custom-scroll::-webkit-scrollbar-thumb:active{background:var(--scalar-scrollbar-color-active);background-clip:content-box;border:3px solid transparent}.scalar-app .cm-scroller::-webkit-scrollbar-corner,.scalar-app .custom-scroll::-webkit-scrollbar-corner{background:transparent}.scalar-app .cm-scroller::-webkit-scrollbar,.scalar-app .custom-scroll::-webkit-scrollbar{height:12px;width:12px}.scalar-app .cm-scroller::-webkit-scrollbar-track,.scalar-app .custom-scroll::-webkit-scrollbar-track{background:transparent}.scalar-app .cm-scroller::-webkit-scrollbar-thumb,.scalar-app .custom-scroll::-webkit-scrollbar-thumb{border-radius:20px;background:transparent;background-clip:content-box;border:3px solid transparent}@media (pointer: coarse){.scalar-app .cm-scroller,.scalar-app .custom-scroll{padding-right:12px}}@layer scalar-base{:root{--scalar-border-width: .5px;--scalar-radius: 3px;--scalar-radius-lg: 6px;--scalar-radius-xl: 8px;--scalar-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;--scalar-font-code: "JetBrains Mono", ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New", monospace;--scalar-heading-1: 40px;--scalar-page-description: 24px;--scalar-heading-2: 24px;--scalar-heading-3: 20px;--scalar-heading-4: 16px;--scalar-heading-5: 16px;--scalar-heading-6: 16px;--scalar-paragraph: 16px;--scalar-small: 14px;--scalar-mini: 13px;--scalar-micro: 12px;--scalar-bold: 600;--scalar-semibold: 500;--scalar-regular: 400;--scalar-font-size-1: 24px;--scalar-font-size-2: 16px;--scalar-font-size-3: 14px;--scalar-font-size-4: 13px;--scalar-font-size-5: 12px;--scalar-font-size-6: 12px;--scalar-font-size-7: 10px;--scalar-line-height-1: 32px;--scalar-line-height-2: 24px;--scalar-line-height-3: 20px;--scalar-line-height-4: 18px;--scalar-line-height-5: 16px;--scalar-font-medium: 500;--scalar-font-bold: 700;--scalar-text-decoration: none;--scalar-text-decoration-hover: underline}.dark-mode{color-scheme:dark;--scalar-scrollbar-color: rgba(255, 255, 255, .18);--scalar-scrollbar-color-active: rgba(255, 255, 255, .36);--scalar-button-1: rgba(255, 255, 255, 1);--scalar-button-1-hover: rgba(255, 255, 255, .9);--scalar-button-1-color: black;--scalar-shadow-1: 0 1px 3px 0 rgb(0, 0, 0, .1);--scalar-shadow-2: rgba(15, 15, 15, .2) 0px 3px 6px, rgba(15, 15, 15, .4) 0px 9px 24px, 0 0 0 1px var(--scalar-border-color);--scalar-lifted-brightness: 1.45;--scalar-backdrop-brightness: .5;--scalar-sidebar-indent-border: transparent;--scalar-sidebar-indent-border-hover: transparent;--scalar-sidebar-indent-border-active: transparent}.light-mode{color-scheme:light;--scalar-scrollbar-color-active: rgba(0, 0, 0, .36);--scalar-scrollbar-color: rgba(0, 0, 0, .18);--scalar-button-1: rgba(0, 0, 0, 1);--scalar-button-1-hover: rgba(0, 0, 0, .8);--scalar-button-1-color: rgba(255, 255, 255, .9);--scalar-shadow-1: 0 1px 3px 0 rgba(0, 0, 0, .11);--scalar-shadow-2: rgba(0, 0, 0, .08) 0px 13px 20px 0px, rgba(0, 0, 0, .08) 0px 3px 8px 0px, #eeeeed 0px 0 0 .5px;--scalar-lifted-brightness: 1;--scalar-backdrop-brightness: 1;--scalar-sidebar-indent-border: transparent;--scalar-sidebar-indent-border-hover: transparent;--scalar-sidebar-indent-border-active: transparent}.light-mode .dark-mode{color-scheme:dark!important}@media (max-width: 460px){:root{--scalar-font-size-1: 22px;--scalar-font-size-2: 14px;--scalar-font-size-3: 12px}}@media (max-width: 720px){:root{--scalar-heading-1: 24px;--scalar-page-description: 20px}}*::-moz-selection{background:var(--scalar-selection-background);color:var(--scalar-selection-color)}*::selection{background:var(--scalar-selection-background);color:var(--scalar-selection-color)}.light-mode{--scalar-background-1: #fff;--scalar-background-2: #f6f6f6;--scalar-background-3: #e7e7e7;--scalar-background-accent: #8ab4f81f;--scalar-color-1: #2a2f45;--scalar-color-2: #757575;--scalar-color-3: #8e8e8e;--scalar-color-accent: #0099ff;--scalar-border-color: #dfdfdf}.dark-mode{--scalar-background-1: #0f0f0f;--scalar-background-2: #1a1a1a;--scalar-background-3: #272727;--scalar-color-1: #e7e7e7;--scalar-color-2: #a4a4a4;--scalar-color-3: #797979;--scalar-color-accent: #3ea6ff;--scalar-background-accent: #3ea6ff1f;--scalar-border-color: #2d2d2d}.light-mode .t-doc__sidebar,.dark-mode .t-doc__sidebar{--scalar-sidebar-background-1: var(--scalar-background-1);--scalar-sidebar-color-1: var(--scalar-color-1);--scalar-sidebar-color-2: var(--scalar-color-2);--scalar-sidebar-border-color: var(--scalar-border-color);--scalar-sidebar-item-hover-background: var(--scalar-background-2);--scalar-sidebar-item-hover-color: currentColor;--scalar-sidebar-item-active-background: var(--scalar-background-2);--scalar-sidebar-color-active: var(--scalar-color-1);--scalar-sidebar-search-background: transparent;--scalar-sidebar-search-color: var(--scalar-color-3);--scalar-sidebar-search-border-color: var(--scalar-border-color)}.light-mode,.dark-mode{--scalar-selection-background: color-mix( in sRGB, var(--scalar-color-1) 80%, transparent );--scalar-selection-color: var(--scalar-background-1)}.light-mode{--scalar-color-green: #069061;--scalar-color-red: #ef0006;--scalar-color-yellow: #edbe20;--scalar-color-blue: #0082d0;--scalar-color-orange: #fb892c;--scalar-color-purple: #5203d1;--scalar-button-1: rgba(0, 0, 0, 1);--scalar-button-1-hover: rgba(0, 0, 0, .8);--scalar-button-1-color: rgba(255, 255, 255, .9)}.dark-mode{--scalar-color-green: #00b648;--scalar-color-red: #dc1b19;--scalar-color-yellow: #ffc90d;--scalar-color-blue: #4eb3ec;--scalar-color-orange: #ff8d4d;--scalar-color-purple: #b191f9;--scalar-button-1: rgba(255, 255, 255, 1);--scalar-button-1-hover: rgba(255, 255, 255, .9);--scalar-button-1-color: black}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }}:where(.scalar-app) .container{width:100%}@media (min-width: 400px){:where(.scalar-app) .container{max-width:400px}}@media (min-width: 600px){:where(.scalar-app) .container{max-width:600px}}@media (min-width: 800px){:where(.scalar-app) .container{max-width:800px}}@media (min-width: 1000px){:where(.scalar-app) .container{max-width:1000px}}@media (min-width: 1200px){:where(.scalar-app) .container{max-width:1200px}}:where(.scalar-app) .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}:where(.scalar-app) .pointer-events-none{pointer-events:none}:where(.scalar-app) .visible{visibility:visible}:where(.scalar-app) .invisible{visibility:hidden}:where(.scalar-app) .\\!static{position:static!important}:where(.scalar-app) .static{position:static}:where(.scalar-app) .fixed{position:fixed}:where(.scalar-app) .absolute{position:absolute}:where(.scalar-app) .relative{position:relative}:where(.scalar-app) .sticky{position:sticky}:where(.scalar-app) .inset-0{top:0;right:0;bottom:0;left:0}:where(.scalar-app) .left-0{left:0}:where(.scalar-app) .left-3{left:12px}:where(.scalar-app) .left-px{left:1px}:where(.scalar-app) .right-2{right:8px}:where(.scalar-app) .top-0{top:0}:where(.scalar-app) .top-1\\/2{top:50%}:where(.scalar-app) .top-2{top:8px}:where(.scalar-app) .top-\\[0\\.5px\\]{top:.5px}:where(.scalar-app) .top-px{top:1px}:where(.scalar-app) .-z-1{z-index:-1}:where(.scalar-app) .z-\\[1001\\]{z-index:1001}:where(.scalar-app) .z-overlay{z-index:10000}:where(.scalar-app) .\\!m-0{margin:0!important}:where(.scalar-app) .m-0{margin:0}:where(.scalar-app) .m-1{margin:4px}:where(.scalar-app) .m-auto{margin:auto}:where(.scalar-app) .-mx-0{margin-left:-0px;margin-right:-0px}:where(.scalar-app) .-mx-0\\.75{margin-left:-3px;margin-right:-3px}:where(.scalar-app) .mx-2{margin-left:8px;margin-right:8px}:where(.scalar-app) .mx-auto{margin-left:auto;margin-right:auto}:where(.scalar-app) .my-0{margin-top:0;margin-bottom:0}:where(.scalar-app) .my-0\\.75{margin-top:3px;margin-bottom:3px}:where(.scalar-app) .my-3{margin-top:12px;margin-bottom:12px}:where(.scalar-app) .-mb-1{margin-bottom:-4px}:where(.scalar-app) .mb-0{margin-bottom:0}:where(.scalar-app) .ml-1{margin-left:4px}:where(.scalar-app) .mr-2{margin-right:8px}:where(.scalar-app) .mr-3{margin-right:12px}:where(.scalar-app) .mt-0{margin-top:0}:where(.scalar-app) .mt-1{margin-top:4px}:where(.scalar-app) .mt-1\\.5{margin-top:6px}:where(.scalar-app) .mt-20{margin-top:80px}:where(.scalar-app) .line-clamp-4{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4}:where(.scalar-app) .block{display:block}:where(.scalar-app) .inline-block{display:inline-block}:where(.scalar-app) .flex{display:flex}:where(.scalar-app) .grid{display:grid}:where(.scalar-app) .contents{display:contents}:where(.scalar-app) .hidden{display:none}:where(.scalar-app) .aspect-square{aspect-ratio:1 / 1}:where(.scalar-app) .size-10{width:40px;height:40px}:where(.scalar-app) .size-2{width:8px;height:8px}:where(.scalar-app) .size-2\\.5{width:10px;height:10px}:where(.scalar-app) .size-3{width:12px;height:12px}:where(.scalar-app) .size-3\\.5{width:14px;height:14px}:where(.scalar-app) .size-4{width:16px;height:16px}:where(.scalar-app) .size-5{width:20px;height:20px}:where(.scalar-app) .size-6{width:24px;height:24px}:where(.scalar-app) .size-8{width:32px;height:32px}:where(.scalar-app) .size-full{width:100%;height:100%}:where(.scalar-app) .h-10{height:40px}:where(.scalar-app) .h-3{height:12px}:where(.scalar-app) .h-3\\.5{height:14px}:where(.scalar-app) .h-4{height:16px}:where(.scalar-app) .h-5{height:20px}:where(.scalar-app) .h-72{height:288px}:where(.scalar-app) .h-8{height:32px}:where(.scalar-app) .h-\\[100dvh\\]{height:100dvh}:where(.scalar-app) .h-fit{height:-moz-fit-content;height:fit-content}:where(.scalar-app) .h-full{height:100%}:where(.scalar-app) .h-px{height:1px}:where(.scalar-app) .h-screen{height:100vh}:where(.scalar-app) .max-h-\\[440px\\]{max-height:440px}:where(.scalar-app) .max-h-\\[calc\\(100dvh-120px\\)\\]{max-height:calc(100dvh - 120px)}:where(.scalar-app) .max-h-\\[calc\\(100dvh-180px\\)\\]{max-height:calc(100dvh - 180px)}:where(.scalar-app) .max-h-\\[calc\\(100dvh-240px\\)\\]{max-height:calc(100dvh - 240px)}:where(.scalar-app) .max-h-dvh{max-height:100dvh}:where(.scalar-app) .min-h-\\[77px\\]{min-height:77px}:where(.scalar-app) .w-3{width:12px}:where(.scalar-app) .w-4{width:16px}:where(.scalar-app) .w-40{width:160px}:where(.scalar-app) .w-48{width:192px}:where(.scalar-app) .w-5{width:20px}:where(.scalar-app) .w-56{width:224px}:where(.scalar-app) .w-6{width:24px}:where(.scalar-app) .w-\\[100dvw\\]{width:100dvw}:where(.scalar-app) .w-\\[calc\\(100vw-16px\\)\\]{width:calc(100vw - 16px)}:where(.scalar-app) .w-full{width:100%}:where(.scalar-app) .min-w-0{min-width:0px}:where(.scalar-app) .max-w-screen-lg{max-width:800px}:where(.scalar-app) .max-w-screen-md{max-width:640px}:where(.scalar-app) .max-w-screen-sm{max-width:540px}:where(.scalar-app) .max-w-screen-xl{max-width:1000px}:where(.scalar-app) .max-w-screen-xs{max-width:480px}:where(.scalar-app) .max-w-screen-xxs{max-width:360px}:where(.scalar-app) .flex-1{flex:1 1 0%}:where(.scalar-app) .origin-top-left{transform-origin:top left}:where(.scalar-app) .-translate-y-1\\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}:where(.scalar-app) .translate-x-2{--tw-translate-x: 8px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}:where(.scalar-app) .translate-x-2\\.5{--tw-translate-x: 10px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}:where(.scalar-app) .rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}:where(.scalar-app) .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}:where(.scalar-app) .cursor-not-allowed{cursor:not-allowed}:where(.scalar-app) .cursor-pointer{cursor:pointer}:where(.scalar-app) .resize-none{resize:none}:where(.scalar-app) .resize{resize:both}:where(.scalar-app) .appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}:where(.scalar-app) .flex-col{flex-direction:column}:where(.scalar-app) .flex-wrap{flex-wrap:wrap}:where(.scalar-app) .items-start{align-items:flex-start}:where(.scalar-app) .items-center{align-items:center}:where(.scalar-app) .justify-start{justify-content:flex-start}:where(.scalar-app) .justify-center{justify-content:center}:where(.scalar-app) .justify-between{justify-content:space-between}:where(.scalar-app) .gap-0{gap:0px}:where(.scalar-app) .gap-0\\.75{gap:3px}:where(.scalar-app) .gap-1{gap:4px}:where(.scalar-app) .gap-1\\.5{gap:6px}:where(.scalar-app) .gap-16{gap:64px}:where(.scalar-app) .gap-2{gap:8px}:where(.scalar-app) .gap-2\\.5{gap:10px}:where(.scalar-app) .gap-4{gap:16px}:where(.scalar-app) .divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(var(--scalar-border-width) * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(var(--scalar-border-width) * var(--tw-divide-y-reverse))}:where(.scalar-app) .self-center{align-self:center}:where(.scalar-app) .overflow-auto{overflow:auto}:where(.scalar-app) .overflow-hidden{overflow:hidden}:where(.scalar-app) .overflow-visible{overflow:visible}:where(.scalar-app) .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:where(.scalar-app) .text-ellipsis{text-overflow:ellipsis}:where(.scalar-app) .text-wrap{text-wrap:wrap}:where(.scalar-app) .rounded{border-radius:var(--scalar-radius)}:where(.scalar-app) .rounded-full{border-radius:9999px}:where(.scalar-app) .rounded-lg{border-radius:var(--scalar-radius-lg)}:where(.scalar-app) .rounded-none{border-radius:0}:where(.scalar-app) .border{border-width:var(--scalar-border-width)}:where(.scalar-app) .border-0{border-width:0}:where(.scalar-app) .border-t{border-top-width:var(--scalar-border-width)}:where(.scalar-app) .border-solid{border-style:solid}:where(.scalar-app) .border-dashed{border-style:dashed}:where(.scalar-app) .border-none{border-style:none}:where(.scalar-app) .border-border{border-color:var(--scalar-border-color)}:where(.scalar-app) .border-c-3{border-color:var(--scalar-color-3)}:where(.scalar-app) .border-red{border-color:var(--scalar-color-red)}:where(.scalar-app) .bg-b-1{background-color:var(--scalar-background-1)}:where(.scalar-app) .bg-b-2{background-color:var(--scalar-background-2)}:where(.scalar-app) .bg-b-3{background-color:var(--scalar-background-3)}:where(.scalar-app) .bg-b-btn{background-color:var(--scalar-button-1)}:where(.scalar-app) .bg-backdrop{background-color:#00000038}:where(.scalar-app) .bg-border{background-color:var(--scalar-border-color)}:where(.scalar-app) .bg-c-accent{background-color:var(--scalar-color-accent)}:where(.scalar-app) .bg-red{background-color:var(--scalar-color-red)}:where(.scalar-app) .bg-transparent{background-color:transparent}:where(.scalar-app) .bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}:where(.scalar-app) .p-0{padding:0}:where(.scalar-app) .p-0\\.5{padding:2px}:where(.scalar-app) .p-0\\.75{padding:3px}:where(.scalar-app) .p-1{padding:4px}:where(.scalar-app) .p-2{padding:8px}:where(.scalar-app) .p-3{padding:12px}:where(.scalar-app) .p-6{padding:24px}:where(.scalar-app) .p-\\[3px\\]{padding:3px}:where(.scalar-app) .px-1{padding-left:4px;padding-right:4px}:where(.scalar-app) .px-1\\.5{padding-left:6px;padding-right:6px}:where(.scalar-app) .px-2{padding-left:8px;padding-right:8px}:where(.scalar-app) .px-2\\.5{padding-left:10px;padding-right:10px}:where(.scalar-app) .px-3{padding-left:12px;padding-right:12px}:where(.scalar-app) .px-6{padding-left:24px;padding-right:24px}:where(.scalar-app) .px-9{padding-left:36px;padding-right:36px}:where(.scalar-app) .py-1{padding-top:4px;padding-bottom:4px}:where(.scalar-app) .py-1\\.5{padding-top:6px;padding-bottom:6px}:where(.scalar-app) .py-2{padding-top:8px;padding-bottom:8px}:where(.scalar-app) .py-2\\.5{padding-top:10px;padding-bottom:10px}:where(.scalar-app) .py-4{padding-top:16px;padding-bottom:16px}:where(.scalar-app) .pb-0{padding-bottom:0}:where(.scalar-app) .pl-8{padding-left:32px}:where(.scalar-app) .pr-3{padding-right:12px}:where(.scalar-app) .pt-3{padding-top:12px}:where(.scalar-app) .pt-6{padding-top:24px}:where(.scalar-app) .text-left{text-align:left}:where(.scalar-app) .font-code{font-family:var(--scalar-font-code)}:where(.scalar-app) .text-lg{font-size:var(--scalar-font-size-2)}:where(.scalar-app) .text-sm{font-size:var(--scalar-font-size-4)}:where(.scalar-app) .text-xs{font-size:var(--scalar-font-size-5)}:where(.scalar-app) .text-xxs{font-size:var(--scalar-font-size-6)}:where(.scalar-app) .font-bold{font-weight:var(--scalar-bold)}:where(.scalar-app) .font-medium{font-weight:var(--scalar-semibold)}:where(.scalar-app) .font-normal{font-weight:var(--scalar-regular)}:where(.scalar-app) .leading-none{line-height:1}:where(.scalar-app) .leading-snug{line-height:1.375}:where(.scalar-app) .text-b-1{color:var(--scalar-background-1)}:where(.scalar-app) .text-c-1{color:var(--scalar-color-1)}:where(.scalar-app) .text-c-2{color:var(--scalar-color-2)}:where(.scalar-app) .text-c-3{color:var(--scalar-color-3)}:where(.scalar-app) .text-c-accent{color:var(--scalar-color-accent)}:where(.scalar-app) .text-c-btn{color:var(--scalar-button-1-color)}:where(.scalar-app) .text-c-ghost{color:var(--scalar-color-ghost)}:where(.scalar-app) .text-red{color:var(--scalar-color-red)}:where(.scalar-app) .text-transparent{color:transparent}:where(.scalar-app) .text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}:where(.scalar-app) .no-underline{text-decoration-line:none}:where(.scalar-app) .opacity-0{opacity:0}:where(.scalar-app) .opacity-40{opacity:.4}:where(.scalar-app) .opacity-50{opacity:.5}:where(.scalar-app) .shadow{--tw-shadow: var(--scalar-shadow-1);--tw-shadow-colored: var(--scalar-shadow-1);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}:where(.scalar-app) .shadow-lg{--tw-shadow: var(--scalar-shadow-2);--tw-shadow-colored: var(--scalar-shadow-2);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}:where(.scalar-app) .shadow-md{--tw-shadow: var(--scalar-shadow-1);--tw-shadow-colored: var(--scalar-shadow-1);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}:where(.scalar-app) .shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}:where(.scalar-app) .shadow-sm{--tw-shadow: rgba(0, 0, 0, .09) 0px 1px 4px;--tw-shadow-colored: 0px 1px 4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}:where(.scalar-app) .shadow-current{--tw-shadow-color: currentColor;--tw-shadow: var(--tw-shadow-colored)}:where(.scalar-app) .outline-none{outline:2px solid transparent;outline-offset:2px}:where(.scalar-app) .outline{outline-style:solid}:where(.scalar-app) .blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:where(.scalar-app) .brightness-lifted{--tw-brightness: brightness(var(--scalar-lifted-brightness));filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:where(.scalar-app) .filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:where(.scalar-app) .transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:where(.scalar-app) .transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:where(.scalar-app) .transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:where(.scalar-app) .transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:where(.scalar-app) .duration-300{transition-duration:.3s}:where(.scalar-app) .ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}:where(.scalar-app) .bg-b-1{--tw-bg-base: var(--scalar-background-1)}:where(.scalar-app) .bg-b-2{--tw-bg-base: var(--scalar-background-2)}:where(.scalar-app) .bg-b-3{--tw-bg-base: var(--scalar-background-3)}:where(.scalar-app) .bg-b-btn{--tw-bg-base: var(--scalar-button-1)}:where(.scalar-app) .bg-backdrop{--tw-bg-base: rgba(0, 0, 0, .22)}:where(.scalar-app) .bg-border{--tw-bg-base: var(--scalar-border-color)}:where(.scalar-app) .bg-c-accent{--tw-bg-base: var(--scalar-color-accent)}:where(.scalar-app) .bg-red{--tw-bg-base: var(--scalar-color-red)}:where(.scalar-app) .bg-transparent{--tw-bg-base: transparent}:where(.scalar-app) .bg-white{--tw-bg-opacity: 1;--tw-bg-base: rgb(255 255 255 / var(--tw-bg-opacity))}:where(.scalar-app) .row,:where(.scalar-app) .scalar-row{display:flex;flex-direction:row}:where(.scalar-app) .col{display:flex;flex-direction:column}:where(.scalar-app) .centered-x{left:50%;--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}:where(.scalar-app) .centered{left:50%;--tw-translate-x: -50%;top:50%;--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}:where(.scalar-app) .first-of-type\\:mt-0:first-of-type{margin-top:0}:where(.scalar-app) .first-of-type\\:mt-0\\.75:first-of-type{margin-top:3px}:where(.scalar-app) .last-of-type\\:mb-0:last-of-type{margin-bottom:0}:where(.scalar-app) .last-of-type\\:mb-0\\.75:last-of-type{margin-bottom:3px}:where(.scalar-app) .hover\\:bg-b-2:hover{background-color:var(--scalar-background-2)}:where(.scalar-app) .hover\\:text-c-1:hover{color:var(--scalar-color-1)}:where(.scalar-app) .hover\\:bg-b-2:hover{--tw-bg-base: var(--scalar-background-2)}:where(.scalar-app) .focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}:where(.scalar-app) .focus-visible\\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}:where(.scalar-app) .focus-visible\\:ring-c-accent:focus-visible{--tw-ring-color: var(--scalar-color-accent)}:where(.scalar-app) .active\\:bg-b-btn:active{background-color:var(--scalar-button-1)}:where(.scalar-app) .active\\:text-c-1:active{color:var(--scalar-color-1)}:where(.scalar-app) .active\\:shadow-none:active{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}:where(.scalar-app) .active\\:brightness-90:active{--tw-brightness: brightness(.9);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:where(.scalar-app) .active\\:bg-b-btn:active{--tw-bg-base: var(--scalar-button-1)}:where(.scalar-app) .group:hover .group-hover\\:text-c-1{color:var(--scalar-color-1)}:where(.scalar-app) .group:hover .group-hover\\:opacity-100{opacity:1}:where(.scalar-app) .group\\/listbox:hover .group-hover\\/listbox\\:shadow-border,:where(.scalar-app) .group:hover .group-hover\\:shadow-border{--tw-shadow: inset 0 0 0 1px var(--scalar-border-color);--tw-shadow-colored: inset 0 0 0 1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow);--tw-shadow-color: var(--scalar-border-color);--tw-shadow: var(--tw-shadow-colored)}:where(.scalar-app) .has-\\[\\:focus-visible\\]\\:outline:has(:focus-visible){outline-style:solid}:where(.scalar-app) .ui-open\\:rotate-180[data-headlessui-state~=open]{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}:where(.scalar-app) :where([data-headlessui-state~=open]) .ui-open\\:rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}:where(.scalar-app) .has-actv-btn\\:border:has(button:active){border-width:var(--scalar-border-width)}:where(.scalar-app) .has-actv-btn\\:border-border:has(button:active){border-color:var(--scalar-border-color)}:where(.scalar-app) .\\!empty\\:flex:not(:empty){display:flex}:where(.scalar-app) .\\!empty\\:w-7:not(:empty){width:28px}:where(.scalar-app) .\\!empty\\:items-center:not(:empty){align-items:center}:where(.scalar-app) .\\!empty\\:pr-3:not(:empty){padding-right:12px}:where(.scalar-app) .hocus\\:bg-h-btn:hover{background-color:var(--scalar-button-1-hover)}:where(.scalar-app) .hocus\\:text-c-1:hover{color:var(--scalar-color-1)}:where(.scalar-app) .hocus\\:brightness-90:hover{--tw-brightness: brightness(.9);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:where(.scalar-app) .hocus\\:bg-h-btn:hover{--tw-bg-base: var(--scalar-button-1-hover)}:where(.scalar-app) .hocus\\:bg-h-btn:focus-visible{background-color:var(--scalar-button-1-hover)}:where(.scalar-app) .hocus\\:text-c-1:focus-visible{color:var(--scalar-color-1)}:where(.scalar-app) .hocus\\:brightness-90:focus-visible{--tw-brightness: brightness(.9);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:where(.scalar-app) .hocus\\:bg-h-btn:focus-visible{--tw-bg-base: var(--scalar-button-1-hover)}@media (min-width: 800px){:where(.scalar-app) .md\\:row{display:flex;flex-direction:row}}@media (min-width: 1000px){:where(.scalar-app) .lg\\:w-\\[calc\\(100vw-32px\\)\\]{width:calc(100vw - 32px)}:where(.scalar-app) .lg\\:w-full{width:100%}}:where(.scalar-app) .dark\\:bg-backdropdark:where(.dark-mode,.dark-mode *){background-color:#00000073;--tw-bg-base: rgba(0, 0, 0, .45)}.loader-wrapper[data-v-5a129980]{position:relative;display:flex;align-items:center;justify-content:center;--loader-size: 50%}.svg-loader[data-v-5a129980]{width:var(--loader-size);height:var(--loader-size);top:1rem;right:.9rem;overflow:visible;fill:none;background-color:transparent;stroke:currentColor}.svg-path[data-v-5a129980]{stroke-width:14;fill:none;transition:.3s}.svg-x-mark[data-v-5a129980]{stroke-dasharray:57;stroke-dashoffset:57;transition-delay:0s}.svg-check-mark[data-v-5a129980]{stroke-dasharray:149;stroke-dashoffset:149;transition-delay:0s}.icon-is-invalid .svg-x-mark[data-v-5a129980],.icon-is-valid .svg-check-mark[data-v-5a129980]{stroke-dashoffset:0;transition-delay:.3s}.circular-loader[data-v-5a129980]{animation:rotate-5a129980 .7s linear infinite,fade-in-5a129980 .4s;transform-origin:center center;transform:scale(5);background:transparent}.loader-path[data-v-5a129980]{stroke-dasharray:50,200;stroke-dashoffset:-100;stroke-linecap:round}.loader-path-off[data-v-5a129980]{stroke-dasharray:50,200;stroke-dashoffset:-100;transition:opacity .3s;opacity:0}@keyframes fade-in-5a129980{0%{opacity:0}70%{opacity:0}to{opacity:1}}@keyframes rotate-5a129980{0%{transform:scale(5) rotate(0)}to{transform:scale(5) rotate(360deg)}}.scalar-code-block{background:inherit;position:relative;overflow:auto;padding:.5rem .5rem .5rem .75rem}.scalar-code-block:hover .copy-button{opacity:100;visibility:visible}.scalar-codeblock-pre{margin:0;background:transparent;text-wrap:nowrap;white-space-collapse:preserve;border-radius:0}.scalar-code-copy{display:flex;align-items:start;justify-content:flex-end;position:sticky;top:0;right:0;bottom:0;left:0}.copy-button{position:relative;top:0;right:0;display:flex;align-items:center;background-color:var(--scalar-background-2);border:1px solid var(--scalar-border-color);border-radius:3px;color:var(--scalar-color-3);cursor:pointer;height:30px;margin-bottom:-30px;opacity:0;padding:6px;transition:opacity .15s ease-in-out,color .15s ease-in-out;visibility:hidden}.scalar-code-copy,.copy-button{background:inherit}.copy-button:after{content:".";color:transparent;font-size:var(--scalar-mini);line-height:1.35;width:0px}.copy-button:hover{color:var(--scalar-color-1)}.copy-button svg{stroke-width:1.5}.scalar-app code.hljs *{font-size:var(--scalar-small);font-family:var(--scalar-font-code);text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.4;-moz-tab-size:4;-o-tab-size:4;tab-size:4}.scalar-app code.hljs{font-size:var(--scalar-small);font-family:var(--scalar-font-code);display:inline-block;counter-reset:linenumber}.scalar-app .hljs{background:transparent;color:var(--scalar-color-2)}.scalar-app .hljs .line:before{color:var(--scalar-color-3);display:inline-block;counter-increment:linenumber;content:counter(linenumber);margin-right:.7em;min-width:calc(var(--line-digits) * 1ch);text-align:right}.scalar-app .hljs-comment,.scalar-app .hljs-quote{color:var(--scalar-color-3);font-style:italic}.scalar-app .hljs-number{color:var(--scalar-color-orange)}.scalar-app .hljs-regexp,.scalar-app .hljs-string,.scalar-app .hljs-built_in{color:var(--scalar-color-blue)}.scalar-app .hljs-title.class_{color:var(--scalar-color-1)}.scalar-app .hljs-keyword{color:var(--scalar-color-purple)}.scalar-app .hljs-title.function_{color:var(--scalar-color-orange)}.scalar-app .hljs-subst,.scalar-app .hljs-name{color:var(--scalar-color-blue)}.scalar-app .hljs-attr,.scalar-app .hljs-attribute{color:var(--scalar-color-1)}.scalar-app .hljs-addition,.scalar-app .hljs-literal,.scalar-app .hljs-selector-tag,.scalar-app .hljs-type{color:var(--scalar-color-green)}.scalar-app .hljs-selector-attr,.scalar-app .hljs-selector-pseudo{color:var(--scalar-color-orange)}.scalar-app .hljs-doctag,.scalar-app .hljs-section,.scalar-app .hljs-title{color:var(--scalar-color-blue)}.scalar-app .hljs-selector-id,.scalar-app .hljs-template-variable,.scalar-app .hljs-variable{color:var(--scalar-color-1)}.scalar-app .hljs-name,.scalar-app .hljs-section,.scalar-app .hljs-strong{font-weight:var(--scalar-semibold)}.scalar-app .hljs-bullet,.scalar-app .hljs-link,.scalar-app .hljs-meta,.scalar-app .hljs-symbol{color:var(--scalar-color-blue)}.scalar-app .hljs-deletion{color:var(--scalar-color-red)}.scalar-app .hljs-formula{background:var(--scalar-color-1)}.scalar-app .hljs-emphasis{font-style:italic}.scalar-app .credentials{font-size:0!important;color:transparent}.scalar-app .credentials:after{content:"·····";font-size:var(--scalar-small);color:var(--scalar-color-3);-webkit-user-select:none;-moz-user-select:none;user-select:none}.hljs.language-html{color:var(--scalar-color-1)}.hljs.language-html .hljs-attr{color:var(--scalar-color-2)}.hljs.language-curl .hljs-keyword{color:var(--scalar-color-orange)}.hljs.language-curl .hljs-string{color:var(--scalar-color-1)}.hljs.language-curl .hljs-literal,.hljs.language-php .hljs-variable{color:var(--scalar-color-blue)}.hljs.language-objectivec .hljs-meta{color:var(--scalar-color-1)}.hljs.language-objectivec .hljs-built_in,.hljs-built_in{color:var(--scalar-color-orange)}.scalar-app .markdown{font-family:var(--scalar-font);color:var(--scalar-color-1);word-break:break-word}.scalar-app .markdown h1,.scalar-app .markdown h2,.scalar-app .markdown h3,.scalar-app .markdown h4,.scalar-app .markdown h5,.scalar-app .markdown h6,.scalar-app .markdown p,.scalar-app .markdown div,.scalar-app .markdown img,.scalar-app .markdown details,.scalar-app .markdown summary,.scalar-app .markdown ul,.scalar-app .markdown ol,.scalar-app .markdown table,.scalar-app .markdown blockquote,.scalar-app .markdown code{margin:12px 0}.scalar-app .markdown details{margin:12px 0;color:var(--scalar-color-1)}.scalar-app .markdown summary{display:block;margin:1em 0;padding-left:20px;position:relative;font-weight:var(--scalar-semibold);cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.scalar-app .markdown summary:after{display:block;content:"";position:absolute;top:1px;left:1px;width:16px;height:16px;background-color:var(--scalar-color-3);-webkit-mask-image:url(\'data:image/svg+xml,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.25 19.5L15.75 12L8.25 4.5" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>\');mask-image:url(\'data:image/svg+xml,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.25 19.5L15.75 12L8.25 4.5" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>\')}.scalar-app .markdown summary:hover:after{background-color:var(--scalar-color-1)}.scalar-app .markdown details[open] summary:after{transform:rotate(90deg)}.scalar-app .markdown summary::-webkit-details-marker{display:none}.scalar-app .markdown img{overflow:hidden;border-radius:var(--scalar-radius);max-width:100%}.scalar-app .markdown>:first-child{margin-top:0;margin-bottom:0}.scalar-app .markdown h1{--font-size: 1.4em}.scalar-app .markdown h2{--font-size: 1.25em}.scalar-app .markdown h3{--font-size: 1.1em}.scalar-app .markdown h4,.scalar-app .markdown h6{--font-size: 1em}.scalar-app .markdown h1,.scalar-app .markdown h2,.scalar-app .markdown h3,.scalar-app .markdown h4,.scalar-app .markdown h5,.scalar-app .markdown h6{font-size:var(--font-size);margin:18px 0 6px;font-weight:var(--scalar-bold);display:block;line-height:1.45}.scalar-app .markdown b,.scalar-app .markdown strong{font-weight:var(--scalar-bold)}.scalar-app .markdown p{color:inherit;font-weight:var(--font-weight, var(--scalar-regular));line-height:1.5;margin-bottom:0;display:block}.scalar-app .markdown ul,.scalar-app .markdown ol{padding-left:24px;line-height:1.5;margin:12px 0;display:block}.scalar-app .markdown ul{list-style:disc}.scalar-app .markdown ol{list-style:decimal}.scalar-app .markdown ul.contains-task-list{list-style:none;padding-left:0}.scalar-app .markdown li{margin:6px 0;display:list-item}.scalar-app .markdown ul:first-of-type li:first-of-type{margin-top:0}.scalar-app .markdown a{color:var(--scalar-color-accent);-webkit-text-decoration:var(--scalar-text-decoration);text-decoration:var(--scalar-text-decoration);cursor:pointer}.scalar-app .markdown a:hover{-webkit-text-decoration:var(--scalar-text-decoration-hover);text-decoration:var(--scalar-text-decoration-hover)}.scalar-app .markdown em{font-style:italic}.scalar-app .markdown sup{font-size:var(--scalar-micro);vertical-align:super;font-weight:450}.scalar-app .markdown sub{font-size:var(--scalar-micro);vertical-align:sub;font-weight:450}.scalar-app .markdown del{text-decoration:line-through}.scalar-app .markdown code{font-family:var(--scalar-font-code);background-color:var(--scalar-background-2);box-shadow:0 0 0 var(--scalar-border-width) var(--scalar-border-color);font-size:var(--scalar-micro);border-radius:2px;padding:0 3px}.scalar-app .markdown pre code{display:block;white-space:pre;padding:12px;line-height:1.5;margin:12px 0;-webkit-overflow-scrolling:touch;overflow-x:auto;max-width:100%;min-width:100px}.scalar-app .markdown hr{border:none;border-bottom:var(--scalar-border-width) solid var(--scalar-border-color)}.scalar-app .markdown blockquote{border-left:3px solid var(--scalar-border-color);padding-left:12px;margin:0;display:block}.scalar-app .markdown table{display:block;overflow-x:auto;position:relative;border-collapse:collapse;width:-moz-max-content;width:max-content;max-width:100%;margin:1em 0;box-shadow:0 0 0 var(--scalar-border-width) var(--scalar-border-color);border-radius:var(--scalar-radius-lg)}.scalar-app .markdown tbody{display:table-row-group;vertical-align:middle}.scalar-app .markdown thead{display:table-header-group;vertical-align:middle}.scalar-app .markdown tr{display:table-row;border-color:inherit;vertical-align:inherit}.scalar-app .markdown td,.scalar-app .markdown th{display:table-cell;vertical-align:inherit;min-width:1em;padding:6px 9px;vertical-align:top;line-height:1.5;position:relative;word-break:initial;font-size:var(--scalar-small);color:var(--scalar-color-1);font-weight:var(--font-weight, var(--scalar-regular));border-right:var(--scalar-border-width) solid var(--scalar-border-color);border-bottom:var(--scalar-border-width) solid var(--scalar-border-color)}.scalar-app .markdown td>*,.scalar-app .markdown th>*{margin-bottom:0}.scalar-app .markdown th:empty{display:none}.scalar-app .markdown td:first-of-type,.scalar-app .markdown th:first-of-type{border-left:none}.scalar-app .markdown td:last-of-type,.scalar-app .markdown th:last-of-type{border-right:none}.scalar-app .markdown tr:last-of-type td{border-bottom:none}.scalar-app .markdown th{font-weight:var(--scalar-semibold)!important;text-align:left;border-left-color:transparent;background:var(--scalar-background-2)}.scalar-app .markdown tr>[align=left]{text-align:left}.scalar-app .markdown tr>[align=right]{text-align:right}.scalar-app .markdown tr>[align=center]{text-align:center}.dark-mode .scalar-dropdown-item[data-v-a4980d5e]:hover{filter:brightness(1.1)}.scalar-input-wrapper-focus .scalar-input-label[data-v-4de7a24e]{color:var(--scalar-color-1)}.scalar-input-wrapper-error .scalar-input-label[data-v-4de7a24e]{color:var(--scalar-color-red)}.scalar-input[data-v-4de7a24e]::-moz-selection{color:var(--scalar-color-1);background:#ffa55859}.scalar-input[data-v-4de7a24e]::selection{color:var(--scalar-color-1);background:#ffa55859}.scalar-input[data-v-4de7a24e]:has(+.scalar-input-label){opacity:0}.scalar-input[data-v-4de7a24e]:not(:-moz-placeholder-shown){opacity:1;-moz-transition:opacity .2s ease-in-out .15s;transition:opacity .2s ease-in-out .15s}.scalar-input[data-v-4de7a24e]:not(:placeholder-shown),.scalar-input-wrapper-focus .scalar-input[data-v-4de7a24e]{opacity:1;transition:opacity .2s ease-in-out .15s}.scalar-input[data-v-4de7a24e]:-webkit-autofill,.scalar-input[data-v-4de7a24e]:-webkit-autofill:hover,.scalar-input[data-v-4de7a24e]:-webkit-autofill:focus,.scalar-input[data-v-4de7a24e]:-webkit-autofill:active,.scalar-input[data-v-4de7a24e]:focus-within:-webkit-autofill,.scalar-input[data-v-4de7a24e]:focus-within:-webkit-autofill:hover,.scalar-input[data-v-4de7a24e]:focus-within:-webkit-autofill:focus,.scalar-input[data-v-4de7a24e]:focus-within:-webkit-autofill:active{-webkit-box-shadow:0 0 0px 1000px var(--scalar-background-1) inset!important;-webkit-text-fill-color:var(--scalar-color-1);color:var(--scalar-color-1);border-radius:var(--scalar-radius)}.scalar-input:not(:-moz-placeholder-shown)+.scalar-input-label[data-v-4de7a24e]{transform:translate3d(0,-20px,0) scale(.8);transform-origin:top left}.scalar-input-wrapper-focus .scalar-input-label[data-v-4de7a24e],.scalar-input:not(:placeholder-shown)+.scalar-input-label[data-v-4de7a24e]{transform:translate3d(0,-20px,0) scale(.8);transform-origin:top left}.scalar-input-wrapper-focus:has(button:active) .scalar-input-label[data-v-4de7a24e]{color:var(--scalar-color-3)!important}@layer scalar-base{*,:before,:after{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }}.scalar-client{line-height:1.5;color:var(--scalar-color-1)}.scalar-client .row{display:flex;flex-direction:row}.scalar-client .row-1{display:flex;flex-direction:row;flex:1 1 0%}.scalar-client .col{display:flex;flex-direction:column}.scalar-client .col-1{display:flex;flex-direction:column;flex:1 1 0%}.scalar-client .flex-center{display:flex;justify-content:center;align-items:center}.scalar-client .centered-x{left:50%;--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .centered-y{top:50%;--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .centered{left:50%;--tw-translate-x: -50%;top:50%;--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.scalar-client .pointer-events-none{pointer-events:none}.scalar-client .pointer-events-auto{pointer-events:auto}.scalar-client .visible{visibility:visible}.scalar-client .static{position:static}.scalar-client .fixed{position:fixed}.scalar-client .absolute{position:absolute}.scalar-client .relative{position:relative}.scalar-client .sticky{position:sticky}.scalar-client .inset-0{top:0;right:0;bottom:0;left:0}.scalar-client .inset-y-2\\/4{top:50%;bottom:50%}.scalar-client .-right-6{right:-24px}.scalar-client .bottom-0{bottom:0}.scalar-client .bottom-10{bottom:40px}.scalar-client .left-0{left:0}.scalar-client .right-0{right:0}.scalar-client .right-1{right:4px}.scalar-client .right-10{right:40px}.scalar-client .right-2{right:8px}.scalar-client .right-4{right:16px}.scalar-client .right-5{right:20px}.scalar-client .right-7{right:28px}.scalar-client .top-0{top:0}.scalar-client .top-1\\/2{top:50%}.scalar-client .top-8{top:32px}.scalar-client .top-\\[0\\.5px\\]{top:.5px}.scalar-client .-z-1{z-index:-1}.scalar-client .z-0{z-index:0}.scalar-client .z-1{z-index:1}.scalar-client .z-10{z-index:10}.scalar-client .z-50{z-index:50}.scalar-client .z-\\[10001\\]{z-index:10001}.scalar-client .z-context{z-index:1000}.scalar-client .z-overlay{z-index:10000}.scalar-client .order-last{order:9999}.scalar-client .col-span-full{grid-column:1 / -1}.scalar-client .\\!m-0{margin:0!important}.scalar-client .m-0{margin:0}.scalar-client .m-4{margin:16px}.scalar-client .m-auto{margin:auto}.scalar-client .-my-1{margin-top:-4px;margin-bottom:-4px}.scalar-client .mx-0{margin-left:0;margin-right:0}.scalar-client .mx-1{margin-left:4px;margin-right:4px}.scalar-client .my-1{margin-top:4px;margin-bottom:4px}.scalar-client .my-1\\.25{margin-top:5px;margin-bottom:5px}.scalar-client .my-12{margin-top:48px;margin-bottom:48px}.scalar-client .my-4{margin-top:16px;margin-bottom:16px}.scalar-client .\\!mb-0{margin-bottom:0!important}.scalar-client .\\!mr-0{margin-right:0!important}.scalar-client .-mr-1{margin-right:-4px}.scalar-client .-mr-1\\.5{margin-right:-6px}.scalar-client .-mr-3{margin-right:-12px}.scalar-client .mb-0{margin-bottom:0}.scalar-client .mb-0\\.5{margin-bottom:2px}.scalar-client .mb-1{margin-bottom:4px}.scalar-client .mb-1\\.5{margin-bottom:6px}.scalar-client .mb-2{margin-bottom:8px}.scalar-client .mb-4{margin-bottom:16px}.scalar-client .mb-5{margin-bottom:20px}.scalar-client .mb-8{margin-bottom:32px}.scalar-client .mb-\\[\\.5px\\]{margin-bottom:.5px}.scalar-client .ml-0{margin-left:0}.scalar-client .ml-0\\.5{margin-left:2px}.scalar-client .ml-1{margin-left:4px}.scalar-client .ml-8{margin-left:32px}.scalar-client .ml-auto{margin-left:auto}.scalar-client .mr-1{margin-right:4px}.scalar-client .mr-1\\.5{margin-right:6px}.scalar-client .mr-2{margin-right:8px}.scalar-client .mr-2\\.5{margin-right:10px}.scalar-client .mr-auto{margin-right:auto}.scalar-client .mt-1{margin-top:4px}.scalar-client .mt-10{margin-top:40px}.scalar-client .mt-2{margin-top:8px}.scalar-client .mt-3{margin-top:12px}.scalar-client .mt-4{margin-top:16px}.scalar-client .mt-8{margin-top:32px}.scalar-client .mt-auto{margin-top:auto}.scalar-client .line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.scalar-client .line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.scalar-client .block{display:block}.scalar-client .inline-block{display:inline-block}.scalar-client .flex{display:flex}.scalar-client .inline-flex{display:inline-flex}.scalar-client .table{display:table}.scalar-client .grid{display:grid}.scalar-client .contents{display:contents}.scalar-client .hidden{display:none}.scalar-client .aspect-\\[4\\/3\\]{aspect-ratio:4/3}.scalar-client .aspect-square{aspect-ratio:1 / 1}.scalar-client .size-2{width:8px;height:8px}.scalar-client .size-2\\.5{width:10px;height:10px}.scalar-client .size-3{width:12px;height:12px}.scalar-client .size-3\\.5{width:14px;height:14px}.scalar-client .size-4{width:16px;height:16px}.scalar-client .h-10{height:40px}.scalar-client .h-2{height:8px}.scalar-client .h-2\\.5{height:10px}.scalar-client .h-24{height:96px}.scalar-client .h-3{height:12px}.scalar-client .h-3\\.5{height:14px}.scalar-client .h-4{height:16px}.scalar-client .h-48{height:192px}.scalar-client .h-5{height:20px}.scalar-client .h-6{height:24px}.scalar-client .h-64{height:256px}.scalar-client .h-7{height:28px}.scalar-client .h-8{height:32px}.scalar-client .h-\\[68px\\]{height:68px}.scalar-client .h-\\[calc\\(100\\%_-_50px\\)\\]{height:calc(100% - 50px)}.scalar-client .h-auto{height:auto}.scalar-client .h-fit{height:-moz-fit-content;height:fit-content}.scalar-client .h-full{height:100%}.scalar-client .h-screen{height:100vh}.scalar-client .max-h-40{max-height:160px}.scalar-client .max-h-8{max-height:32px}.scalar-client .max-h-\\[300px\\]{max-height:300px}.scalar-client .max-h-\\[40dvh\\]{max-height:40dvh}.scalar-client .min-h-0{min-height:0px}.scalar-client .min-h-10{min-height:40px}.scalar-client .min-h-11{min-height:44px}.scalar-client .min-h-12{min-height:48px}.scalar-client .min-h-20{min-height:80px}.scalar-client .min-h-8{min-height:32px}.scalar-client .w-10{width:40px}.scalar-client .w-2{width:8px}.scalar-client .w-2\\.5{width:10px}.scalar-client .w-20{width:80px}.scalar-client .w-3{width:12px}.scalar-client .w-3\\.5{width:14px}.scalar-client .w-4{width:16px}.scalar-client .w-5{width:20px}.scalar-client .w-6{width:24px}.scalar-client .w-6\\/12{width:50%}.scalar-client .w-64{width:256px}.scalar-client .w-8{width:32px}.scalar-client .w-\\[60px\\]{width:60px}.scalar-client .w-\\[calc\\(100\\%-10px\\)\\]{width:calc(100% - 10px)}.scalar-client .w-\\[calc\\(100\\%_-_8px\\)\\]{width:calc(100% - 8px)}.scalar-client .w-\\[inherit\\]{width:inherit}.scalar-client .w-auto{width:auto}.scalar-client .w-dvw{width:100dvw}.scalar-client .w-fit{width:-moz-fit-content;width:fit-content}.scalar-client .w-full{width:100%}.scalar-client .w-max{width:-moz-max-content;width:max-content}.scalar-client .min-w-0{min-width:0px}.scalar-client .min-w-2{min-width:8px}.scalar-client .min-w-2\\.5{min-width:10px}.scalar-client .min-w-3{min-width:12px}.scalar-client .min-w-48{min-width:192px}.scalar-client .min-w-60{min-width:240px}.scalar-client .min-w-8{min-width:32px}.scalar-client .min-w-\\[120px\\]{min-width:120px}.scalar-client .min-w-\\[37px\\]{min-width:37px}.scalar-client .min-w-full{min-width:100%}.scalar-client .max-w-\\[100\\%\\]{max-width:100%}.scalar-client .max-w-\\[14px\\]{max-width:14px}.scalar-client .max-w-\\[150px\\]{max-width:150px}.scalar-client .max-w-\\[320px\\]{max-width:320px}.scalar-client .max-w-\\[37px\\]{max-width:37px}.scalar-client .max-w-\\[420px\\]{max-width:420px}.scalar-client .max-w-\\[720px\\]{max-width:720px}.scalar-client .max-w-full{max-width:100%}.scalar-client .flex-1{flex:1 1 0%}.scalar-client .flex-shrink-0,.scalar-client .shrink-0{flex-shrink:0}.scalar-client .flex-grow{flex-grow:1}.scalar-client .-translate-x-1\\/2{--tw-translate-x:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .-translate-y-1\\/2{--tw-translate-y:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .translate-x-0{--tw-translate-x:0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .rotate-90{--tw-rotate:90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .cursor-default{cursor:default}.scalar-client .cursor-help{cursor:help}.scalar-client .cursor-pointer{cursor:pointer}.scalar-client .cursor-text{cursor:text}.scalar-client .select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.scalar-client .resize-none{resize:none}.scalar-client .resize{resize:both}.scalar-client .auto-rows-\\[32px\\]{grid-auto-rows:32px}.scalar-client .auto-rows-auto{grid-auto-rows:auto}.scalar-client .grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.scalar-client .grid-cols-\\[44px\\,1fr\\,repeat\\(3\\,auto\\)\\]{grid-template-columns:44px 1fr repeat(3,auto)}.scalar-client .grid-cols-\\[auto\\,1fr\\]{grid-template-columns:auto 1fr}.scalar-client .grid-cols-\\[repeat\\(auto-fill\\,minmax\\(32px\\,1fr\\)\\)\\]{grid-template-columns:repeat(auto-fill,minmax(32px,1fr))}.scalar-client .flex-row{flex-direction:row}.scalar-client .flex-col{flex-direction:column}.scalar-client .flex-wrap{flex-wrap:wrap}.scalar-client .content-between{align-content:space-between}.scalar-client .items-start{align-items:flex-start}.scalar-client .items-end{align-items:flex-end}.scalar-client .items-center{align-items:center}.scalar-client .items-stretch{align-items:stretch}.scalar-client .justify-start{justify-content:flex-start}.scalar-client .justify-end{justify-content:flex-end}.scalar-client .justify-center{justify-content:center}.scalar-client .justify-between{justify-content:space-between}.scalar-client .\\!gap-1{gap:4px!important}.scalar-client .\\!gap-1\\.5{gap:6px!important}.scalar-client .\\!gap-2{gap:8px!important}.scalar-client .gap-0{gap:0px}.scalar-client .gap-0\\.25{gap:1px}.scalar-client .gap-0\\.5{gap:2px}.scalar-client .gap-1{gap:4px}.scalar-client .gap-1\\.5{gap:6px}.scalar-client .gap-10{gap:40px}.scalar-client .gap-2{gap:8px}.scalar-client .gap-2\\.5{gap:10px}.scalar-client .gap-3{gap:12px}.scalar-client .gap-4{gap:16px}.scalar-client .gap-6{gap:24px}.scalar-client .gap-\\[\\.5px\\]{gap:.5px}.scalar-client .gap-\\[1\\.5px\\]{gap:1.5px}.scalar-client .gap-px{gap:1px}.scalar-client .space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(4px * var(--tw-space-x-reverse));margin-left:calc(4px * calc(1 - var(--tw-space-x-reverse)))}.scalar-client .divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-top-width:calc(var(--scalar-border-width) * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(var(--scalar-border-width) * var(--tw-divide-y-reverse))}.scalar-client .self-center{align-self:center}.scalar-client .justify-self-end{justify-self:end}.scalar-client .overflow-auto{overflow:auto}.scalar-client .overflow-hidden{overflow:hidden}.scalar-client .overflow-visible{overflow:visible}.scalar-client .overflow-x-auto{overflow-x:auto}.scalar-client .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.scalar-client .text-ellipsis{text-overflow:ellipsis}.scalar-client .whitespace-nowrap{white-space:nowrap}.scalar-client .whitespace-pre{white-space:pre}.scalar-client .text-balance{text-wrap:balance}.scalar-client .text-pretty{text-wrap:pretty}.scalar-client .break-words{overflow-wrap:break-word}.scalar-client .break-all{word-break:break-all}.scalar-client .rounded{border-radius:var(--scalar-radius)}.scalar-client .rounded-\\[10px\\]{border-radius:10px}.scalar-client .rounded-full{border-radius:9999px}.scalar-client .rounded-lg{border-radius:var(--scalar-radius-lg)}.scalar-client .rounded-md{border-radius:var(--scalar-radius)}.scalar-client .rounded-xl{border-radius:var(--scalar-radius-xl)}.scalar-client .rounded-b{border-bottom-right-radius:var(--scalar-radius);border-bottom-left-radius:var(--scalar-radius)}.scalar-client .rounded-b-lg{border-bottom-right-radius:var(--scalar-radius-lg);border-bottom-left-radius:var(--scalar-radius-lg)}.scalar-client .rounded-b-none{border-bottom-right-radius:0;border-bottom-left-radius:0}.scalar-client .rounded-t{border-top-left-radius:var(--scalar-radius);border-top-right-radius:var(--scalar-radius)}.scalar-client .rounded-t-none{border-top-left-radius:0;border-top-right-radius:0}.scalar-client .\\!border-0{border-width:0!important}.scalar-client .border{border-width:var(--scalar-border-width)}.scalar-client .border-0{border-width:0}.scalar-client .border-1\\/2{border-width:calc(var(--scalar-border-width) / 2)}.scalar-client .border-\\[1\\.5px\\]{border-width:1.5px}.scalar-client .border-b-0{border-bottom-width:0}.scalar-client .border-b-1\\/2{border-bottom-width:calc(var(--scalar-border-width) / 2)}.scalar-client .border-l-0{border-left-width:0}.scalar-client .border-l-1\\/2{border-left-width:calc(var(--scalar-border-width) / 2)}.scalar-client .border-r{border-right-width:var(--scalar-border-width)}.scalar-client .border-r-0{border-right-width:0}.scalar-client .border-r-1\\/2{border-right-width:calc(var(--scalar-border-width) / 2)}.scalar-client .border-t{border-top-width:var(--scalar-border-width)}.scalar-client .border-t-0{border-top-width:0}.scalar-client .border-t-1\\/2{border-top-width:calc(var(--scalar-border-width) / 2)}.scalar-client .border-solid{border-style:solid}.scalar-client .border-none{border-style:none}.scalar-client .border-b-3{border-color:var(--scalar-background-3)}.scalar-client .border-c-3{border-color:var(--scalar-color-3)}.scalar-client .border-transparent{border-color:transparent}.scalar-client .border-r-transparent{border-right-color:transparent}.scalar-client .bg-b-1{background-color:var(--scalar-background-1)}.scalar-client .bg-b-2{background-color:var(--scalar-background-2)}.scalar-client .bg-b-3{background-color:var(--scalar-background-3)}.scalar-client .bg-blue{background-color:var(--scalar-color-blue)}.scalar-client .bg-c-2{background-color:var(--scalar-color-2)}.scalar-client .bg-c-accent{background-color:var(--scalar-color-accent)}.scalar-client .bg-green{background-color:var(--scalar-color-green)}.scalar-client .bg-grey{background-color:var(--scalar-color-3)}.scalar-client .bg-orange{background-color:var(--scalar-color-orange)}.scalar-client .bg-pink{background-color:var(--scalar-color-pink)}.scalar-client .bg-purple{background-color:var(--scalar-color-purple)}.scalar-client .bg-red{background-color:var(--scalar-color-red)}.scalar-client .bg-sidebar-active-b{background-color:var(--scalar-sidebar-item-active-background, var(--scalar-background-2))}.scalar-client .bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.scalar-client .bg-yellow{background-color:var(--scalar-color-yellow)}.scalar-client .bg-none{background-image:none}.scalar-client .fill-current{fill:currentColor}.scalar-client .stroke-2{stroke-width:2}.scalar-client .stroke-\\[2\\.25\\]{stroke-width:2.25}.scalar-client .\\!p-1{padding:4px!important}.scalar-client .p-0{padding:0}.scalar-client .p-0\\.5{padding:2px}.scalar-client .p-0\\.75{padding:3px}.scalar-client .p-1{padding:4px}.scalar-client .p-1\\.5{padding:6px}.scalar-client .p-2{padding:8px}.scalar-client .p-2\\.25{padding:9px}.scalar-client .p-3{padding:12px}.scalar-client .p-4{padding:16px}.scalar-client .p-\\[3px\\]{padding:3px}.scalar-client .p-\\[5px\\]{padding:5px}.scalar-client .p-\\[8px\\]{padding:8px}.scalar-client .px-0{padding-left:0;padding-right:0}.scalar-client .px-0\\.5{padding-left:2px;padding-right:2px}.scalar-client .px-1{padding-left:4px;padding-right:4px}.scalar-client .px-1\\.5{padding-left:6px;padding-right:6px}.scalar-client .px-2{padding-left:8px;padding-right:8px}.scalar-client .px-2\\.5{padding-left:10px;padding-right:10px}.scalar-client .px-3{padding-left:12px;padding-right:12px}.scalar-client .px-3\\.5{padding-left:14px;padding-right:14px}.scalar-client .px-4{padding-left:16px;padding-right:16px}.scalar-client .px-5{padding-left:20px;padding-right:20px}.scalar-client .px-6{padding-left:24px;padding-right:24px}.scalar-client .px-\\[0px\\]{padding-left:0;padding-right:0}.scalar-client .px-\\[2\\.25px\\]{padding-left:2.25px;padding-right:2.25px}.scalar-client .py-0{padding-top:0;padding-bottom:0}.scalar-client .py-0\\.5{padding-top:2px;padding-bottom:2px}.scalar-client .py-1{padding-top:4px;padding-bottom:4px}.scalar-client .py-1\\.5{padding-top:6px;padding-bottom:6px}.scalar-client .py-2{padding-top:8px;padding-bottom:8px}.scalar-client .py-2\\.5{padding-top:10px;padding-bottom:10px}.scalar-client .py-3{padding-top:12px;padding-bottom:12px}.scalar-client .py-5{padding-top:20px;padding-bottom:20px}.scalar-client .py-\\[0px\\]{padding-top:0;padding-bottom:0}.scalar-client .py-\\[2\\.25px\\]{padding-top:2.25px;padding-bottom:2.25px}.scalar-client .py-\\[9px\\]{padding-top:9px;padding-bottom:9px}.scalar-client .py-px{padding-top:1px;padding-bottom:1px}.scalar-client .pb-0{padding-bottom:0}.scalar-client .pb-14{padding-bottom:56px}.scalar-client .pb-3{padding-bottom:12px}.scalar-client .pb-4{padding-bottom:16px}.scalar-client .pb-\\[75px\\]{padding-bottom:75px}.scalar-client .pl-1{padding-left:4px}.scalar-client .pl-2{padding-left:8px}.scalar-client .pl-5{padding-left:20px}.scalar-client .pl-8{padding-left:32px}.scalar-client .pl-9{padding-left:36px}.scalar-client .pl-px{padding-left:1px}.scalar-client .pr-0{padding-right:0}.scalar-client .pr-1{padding-right:4px}.scalar-client .pr-1\\.5{padding-right:6px}.scalar-client .pr-2{padding-right:8px}.scalar-client .pr-2\\.5{padding-right:10px}.scalar-client .pr-6{padding-right:24px}.scalar-client .pr-\\[26px\\]{padding-right:26px}.scalar-client .pt-0{padding-top:0}.scalar-client .pt-1{padding-top:4px}.scalar-client .pt-3{padding-top:12px}.scalar-client .pt-px{padding-top:1px}.scalar-client .text-left{text-align:left}.scalar-client .text-center{text-align:center}.scalar-client .text-right{text-align:right}.scalar-client .font-code{font-family:var(--scalar-font-code)}.scalar-client .text-3xs{font-size:var(--scalar-font-size-7)}.scalar-client .text-\\[11px\\]{font-size:11px}.scalar-client .text-\\[21px\\]{font-size:21px}.scalar-client .text-\\[50px\\]{font-size:50px}.scalar-client .text-\\[6px\\]{font-size:6px}.scalar-client .text-base{font-size:var(--scalar-font-size-3)}.scalar-client .text-sm{font-size:var(--scalar-font-size-4)}.scalar-client .text-xl{font-size:var(--scalar-font-size-1)}.scalar-client .text-xs{font-size:var(--scalar-font-size-5)}.scalar-client .text-xxs{font-size:var(--scalar-font-size-6)}.scalar-client .font-bold{font-weight:var(--scalar-bold)}.scalar-client .font-medium{font-weight:var(--scalar-semibold)}.scalar-client .font-normal{font-weight:var(--scalar-regular)}.scalar-client .uppercase{text-transform:uppercase}.scalar-client .lowercase{text-transform:lowercase}.scalar-client .capitalize{text-transform:capitalize}.scalar-client .leading-3{line-height:var(--scalar-line-height-3)}.scalar-client .leading-5{line-height:var(--scalar-line-height-5)}.scalar-client .leading-\\[1\\.44\\]{line-height:1.44}.scalar-client .leading-\\[21px\\]{line-height:21px}.scalar-client .leading-\\[7px\\]{line-height:7px}.scalar-client .leading-none{line-height:1}.scalar-client .leading-normal{line-height:1.5}.scalar-client .leading-snug{line-height:1.375}.scalar-client .leading-tight{line-height:1.25}.scalar-client .tracking-\\[-3px\\]{letter-spacing:-3px}.scalar-client .\\!text-c-1{color:var(--scalar-color-1)!important}.scalar-client .text-b-1{color:var(--scalar-background-1)}.scalar-client .text-blue{color:var(--scalar-color-blue)}.scalar-client .text-border{color:var(--scalar-border-color)}.scalar-client .text-c-1{color:var(--scalar-color-1)}.scalar-client .text-c-2{color:var(--scalar-color-2)}.scalar-client .text-c-3{color:var(--scalar-color-3)}.scalar-client .text-green{color:var(--scalar-color-green)}.scalar-client .text-grey{color:var(--scalar-color-3)}.scalar-client .text-orange{color:var(--scalar-color-orange)}.scalar-client .text-purple{color:var(--scalar-color-purple)}.scalar-client .text-red{color:var(--scalar-color-red)}.scalar-client .text-sidebar-active-c{color:var(--scalar-sidebar-color-active, currentColor)}.scalar-client .text-sidebar-c-2{color:var(--scalar-sidebar-color-2, var(--scalar-color-2))}.scalar-client .text-transparent{color:transparent}.scalar-client .text-yellow{color:var(--scalar-color-yellow)}.scalar-client .underline{text-decoration-line:underline}.scalar-client .no-underline{text-decoration-line:none}.scalar-client .decoration-c-3{text-decoration-color:var(--scalar-color-3)}.scalar-client .underline-offset-2{text-underline-offset:2px}.scalar-client .opacity-0{opacity:0}.scalar-client .opacity-100{opacity:1}.scalar-client .shadow{--tw-shadow:var(--scalar-shadow-1);--tw-shadow-colored:var(--scalar-shadow-1);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.scalar-client .shadow-\\[-8px_0_4px_var\\(--scalar-background-1\\)\\]{--tw-shadow:-8px 0 4px var(--scalar-background-1);--tw-shadow-colored:-8px 0 4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.scalar-client .shadow-\\[0_-8px_0_8px_var\\(--scalar-background-1\\)\\,0_0_8px_8px_var\\(--scalar-background-1\\)\\]{--tw-shadow:0 -8px 0 8px var(--scalar-background-1),0 0 8px 8px var(--scalar-background-1);--tw-shadow-colored:0 -8px 0 8px var(--tw-shadow-color), 0 0 8px 8px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.scalar-client .shadow-lg{--tw-shadow:var(--scalar-shadow-2);--tw-shadow-colored:var(--scalar-shadow-2);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.scalar-client .shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.scalar-client .outline-none{outline:2px solid transparent;outline-offset:2px}.scalar-client .outline{outline-style:solid}.scalar-client .ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.scalar-client .ring-offset-4{--tw-ring-offset-width:4px}.scalar-client .blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.scalar-client .brightness-lifted{--tw-brightness:brightness(var(--scalar-lifted-brightness));filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.scalar-client .filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.scalar-client .backdrop-filter{-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.scalar-client .transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.scalar-client .transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.scalar-client .transition-none{transition-property:none}.scalar-client .transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.scalar-client .transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.scalar-client .duration-150{transition-duration:.15s}.scalar-client .duration-200{transition-duration:.2s}.scalar-client .duration-300{transition-duration:.3s}.scalar-client .ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.scalar-client .bg-mix-transparent{background-color:color-mix(var(--tw-bg-mix-method, in srgb),transparent calc(var(--tw-bg-mix-amount, 0) * 1%),var(--tw-bg-base))}.scalar-client .bg-mix-amount-90{--tw-bg-mix-amount:90}.scalar-client .bg-b-1{--tw-bg-base:var(--scalar-background-1)}.scalar-client .bg-b-2{--tw-bg-base:var(--scalar-background-2)}.scalar-client .bg-b-3{--tw-bg-base:var(--scalar-background-3)}.scalar-client .bg-blue{--tw-bg-base:var(--scalar-color-blue)}.scalar-client .bg-c-2{--tw-bg-base:var(--scalar-color-2)}.scalar-client .bg-c-accent{--tw-bg-base:var(--scalar-color-accent)}.scalar-client .bg-green{--tw-bg-base:var(--scalar-color-green)}.scalar-client .bg-grey{--tw-bg-base:var(--scalar-color-3)}.scalar-client .bg-orange{--tw-bg-base:var(--scalar-color-orange)}.scalar-client .bg-pink{--tw-bg-base:var(--scalar-color-pink)}.scalar-client .bg-purple{--tw-bg-base:var(--scalar-color-purple)}.scalar-client .bg-red{--tw-bg-base:var(--scalar-color-red)}.scalar-client .bg-sidebar-active-b{--tw-bg-base:var(--scalar-sidebar-item-active-background, var(--scalar-background-2))}.scalar-client .bg-white{--tw-bg-opacity:1;--tw-bg-base:rgb(255 255 255 / var(--tw-bg-opacity))}.scalar-client .bg-yellow{--tw-bg-base:var(--scalar-color-yellow)}.scalar-client .\\[--scalar-small\\:--scalar-font-size-4\\]{--scalar-small:var(--scalar-font-size-4)}.scalar-client .\\*\\:flex>*{display:flex}.scalar-client .\\*\\:h-8>*{height:32px}.scalar-client .\\*\\:cursor-pointer>*{cursor:pointer}.scalar-client .\\*\\:items-center>*{align-items:center}.scalar-client .\\*\\:rounded-none>*{border-radius:0}.scalar-client .\\*\\:border-t-1\\/2>*{border-top-width:calc(var(--scalar-border-width) / 2)}.scalar-client .\\*\\:px-1>*{padding-left:4px;padding-right:4px}.scalar-client .\\*\\:px-1\\.5>*{padding-left:6px;padding-right:6px}.scalar-client .before\\:pointer-events-none:before{content:var(--tw-content);pointer-events:none}.scalar-client .before\\:absolute:before{content:var(--tw-content);position:absolute}.scalar-client .before\\:-top-8:before{content:var(--tw-content);top:-32px}.scalar-client .before\\:left-0:before{content:var(--tw-content);left:0}.scalar-client .before\\:left-1\\/2:before{content:var(--tw-content);left:50%}.scalar-client .before\\:left-\\[calc\\(\\.75rem_\\+_\\.5px\\)\\]:before{content:var(--tw-content);left:calc(.75rem + .5px)}.scalar-client .before\\:left-\\[calc\\(1\\.75rem_-_1\\.5px\\)\\]:before{content:var(--tw-content);left:calc(1.75rem - 1.5px)}.scalar-client .before\\:left-\\[calc\\(1rem_-_1\\.5px\\)\\]:before{content:var(--tw-content);left:calc(1rem - 1.5px)}.scalar-client .before\\:right-\\[23px\\]:before{content:var(--tw-content);right:23px}.scalar-client .before\\:top-0:before{content:var(--tw-content);top:0}.scalar-client .before\\:top-1\\/2:before{content:var(--tw-content);top:50%}.scalar-client .before\\:z-1:before{content:var(--tw-content);z-index:1}.scalar-client .before\\:mx-\\[0\\.5ch\\]:before{content:var(--tw-content);margin-left:.5ch;margin-right:.5ch}.scalar-client .before\\:block:before{content:var(--tw-content);display:block}.scalar-client .before\\:aspect-square:before{content:var(--tw-content);aspect-ratio:1 / 1}.scalar-client .before\\:h-\\[calc\\(100\\%\\+32px\\)\\]:before{content:var(--tw-content);height:calc(100% + 32px)}.scalar-client .before\\:h-\\[calc\\(100\\%_\\+_\\.5px\\)\\]:before{content:var(--tw-content);height:calc(100% + .5px)}.scalar-client .before\\:min-h-full:before{content:var(--tw-content);min-height:100%}.scalar-client .before\\:w-3:before{content:var(--tw-content);width:12px}.scalar-client .before\\:w-9\\/12:before{content:var(--tw-content);width:75%}.scalar-client .before\\:w-\\[\\.5px\\]:before{content:var(--tw-content);width:.5px}.scalar-client .before\\:w-full:before{content:var(--tw-content);width:100%}.scalar-client .before\\:-translate-x-1\\/2:before{content:var(--tw-content);--tw-translate-x:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .before\\:-translate-y-1\\/2:before{content:var(--tw-content);--tw-translate-y:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .before\\:transform:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .before\\:rounded:before{content:var(--tw-content);border-radius:var(--scalar-radius)}.scalar-client .before\\:rounded-lg:before{content:var(--tw-content);border-radius:var(--scalar-radius-lg)}.scalar-client .before\\:border:before{content:var(--tw-content);border-width:var(--scalar-border-width)}.scalar-client .before\\:border-\\[1px\\]:before{content:var(--tw-content);border-width:1px}.scalar-client .before\\:bg-border:before{content:var(--tw-content);background-color:var(--scalar-border-color)}.scalar-client .before\\:bg-gradient-to-r:before{content:var(--tw-content);background-image:linear-gradient(to right,var(--tw-gradient-stops))}.scalar-client .before\\:from-transparent:before{content:var(--tw-content);--tw-gradient-from:transparent var(--tw-gradient-from-position);--tw-gradient-to:rgb(0 0 0 / 0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from), var(--tw-gradient-to)}.scalar-client .before\\:to-b-1:before{content:var(--tw-content);--tw-gradient-to:var(--scalar-background-1) var(--tw-gradient-to-position)}.scalar-client .before\\:opacity-0:before{content:var(--tw-content);opacity:0}.scalar-client .before\\:shadow-lg:before{content:var(--tw-content);--tw-shadow:var(--scalar-shadow-2);--tw-shadow-colored:var(--scalar-shadow-2);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.scalar-client .before\\:content-\\[\\\'\\\'\\]:before{--tw-content:"";content:var(--tw-content)}.scalar-client .before\\:content-\\[\\\'·\\\'\\]:before{--tw-content:"·";content:var(--tw-content)}.scalar-client .before\\:bg-border:before{content:var(--tw-content);--tw-bg-base:var(--scalar-border-color)}.scalar-client .first\\:\\*\\:rounded-l>*:first-child{border-top-left-radius:var(--scalar-radius);border-bottom-left-radius:var(--scalar-radius)}.scalar-client .first\\:\\*\\:border-t-0>*:first-child{border-top-width:0}.scalar-client .last\\:mb-0:last-child{margin-bottom:0}.scalar-client .last\\:border-r-0:last-child{border-right-width:0}.scalar-client .last\\:\\*\\:rounded-r>*:last-child{border-top-right-radius:var(--scalar-radius);border-bottom-right-radius:var(--scalar-radius)}.scalar-client .last\\:before\\:h-full:last-child:before{content:var(--tw-content);height:100%}.scalar-client .focus-within\\:border-b-3:focus-within{border-color:var(--scalar-background-3)}.scalar-client .focus-within\\:bg-b-1:focus-within{background-color:var(--scalar-background-1)}.scalar-client .focus-within\\:bg-b-2:focus-within{background-color:var(--scalar-background-2)}.scalar-client .focus-within\\:text-c-1:focus-within{color:var(--scalar-color-1)}.scalar-client .focus-within\\:bg-b-1:focus-within{--tw-bg-base:var(--scalar-background-1)}.scalar-client .focus-within\\:bg-b-2:focus-within{--tw-bg-base:var(--scalar-background-2)}.scalar-client .hover\\:bg-b-2:hover{background-color:var(--scalar-background-2)}.scalar-client .hover\\:bg-b-3:hover{background-color:var(--scalar-background-3)}.scalar-client .hover\\:bg-sidebar-active-b:hover{background-color:var(--scalar-sidebar-item-active-background, var(--scalar-background-2))}.scalar-client .hover\\:text-c-1:hover{color:var(--scalar-color-1)}.scalar-client .hover\\:text-c-2:hover{color:var(--scalar-color-2)}.scalar-client .hover\\:bg-b-2:hover{--tw-bg-base:var(--scalar-background-2)}.scalar-client .hover\\:bg-b-3:hover{--tw-bg-base:var(--scalar-background-3)}.scalar-client .hover\\:bg-sidebar-active-b:hover{--tw-bg-base:var(--scalar-sidebar-item-active-background, var(--scalar-background-2))}.scalar-client .\\*\\:hover\\:bg-b-2:hover>*{background-color:var(--scalar-background-2)}.scalar-client .\\*\\:hover\\:bg-b-2:hover>*{--tw-bg-base:var(--scalar-background-2)}.scalar-client .focus\\:text-c-1:focus{color:var(--scalar-color-1)}.scalar-client .focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.scalar-client .active\\:text-c-1:active{color:var(--scalar-color-1)}.scalar-client .disabled\\:text-c-2:disabled{color:var(--scalar-color-2)}.scalar-client .group:last-child .group-last\\:border-b-transparent{border-bottom-color:transparent}.scalar-client .group\\/upload:hover .group-hover\\/upload\\:block,.scalar-client .group:hover .group-hover\\:block{display:block}.scalar-client .group\\/item:hover .group-hover\\/item\\:flex,.scalar-client .group:hover .group-hover\\:flex{display:flex}.scalar-client .group:hover .group-hover\\:hidden{display:none}.scalar-client .group:hover .group-hover\\:cursor-auto{cursor:auto}.scalar-client .group:hover .group-hover\\:bg-b-2{background-color:var(--scalar-background-2)}.scalar-client .group\\/info:hover .group-hover\\/info\\:text-c-1{color:var(--scalar-color-1)}.scalar-client .group\\/scopes-accordion:hover .group-hover\\/scopes-accordion\\:text-c-2{color:var(--scalar-color-2)}.scalar-client .group:hover .group-hover\\:text-c-1{color:var(--scalar-color-1)}.scalar-client .group\\/params:hover .group-hover\\/params\\:opacity-100,.scalar-client .group:hover .group-hover\\:opacity-100{opacity:1}.scalar-client .group:hover .group-hover\\:opacity-80{opacity:.8}.scalar-client .group\\/item:hover .group-hover\\/item\\:shadow-border,.scalar-client .group:hover .group-hover\\:shadow-border{--tw-shadow:inset 0 0 0 1px var(--scalar-border-color);--tw-shadow-colored:inset 0 0 0 1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.scalar-client .group\\/item:hover .group-hover\\/item\\:shadow-border,.scalar-client .group:hover .group-hover\\:shadow-border{--tw-shadow-color:var(--scalar-border-color);--tw-shadow:var(--tw-shadow-colored)}.scalar-client .group:hover .group-hover\\:bg-b-2{--tw-bg-base:var(--scalar-background-2)}.scalar-client .group\\/cell:hover .group-hover\\/cell\\:before\\:opacity-100:before{content:var(--tw-content);opacity:1}.scalar-client .peer:checked~.peer-checked\\:text-c-2{color:var(--scalar-color-2)}.scalar-client .peer:focus~.peer-focus\\:opacity-0{opacity:0}.scalar-client .has-\\[\\.empty-sidebar-item\\]\\:border-t-1\\/2:has(.empty-sidebar-item){border-top-width:calc(var(--scalar-border-width) / 2)}.scalar-client .peer:has(.cm-focused)~.peer-has-\\[\\.cm-focused\\]\\:opacity-0{opacity:0}.scalar-client .ui-open\\:mb-3[data-headlessui-state~=open]{margin-bottom:12px}.scalar-client .ui-open\\:rotate-90[data-headlessui-state~=open]{--tw-rotate:90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .ui-open\\:pb-1[data-headlessui-state~=open]{padding-bottom:4px}.scalar-client :where([data-headlessui-state~=open]) .ui-open\\:mb-3{margin-bottom:12px}.scalar-client :where([data-headlessui-state~=open]) .ui-open\\:rotate-90{--tw-rotate:90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client :where([data-headlessui-state~=open]) .ui-open\\:pb-1{padding-bottom:4px}.scalar-client .ui-not-open\\:invisible[data-headlessui-state]:not([data-headlessui-state~=open]){visibility:hidden}.scalar-client .ui-not-open\\:mb-0[data-headlessui-state]:not([data-headlessui-state~=open]){margin-bottom:0}.scalar-client .ui-not-open\\:rotate-0[data-headlessui-state]:not([data-headlessui-state~=open]){--tw-rotate:0deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client .ui-not-open\\:bg-transparent[data-headlessui-state]:not([data-headlessui-state~=open]){background-color:transparent}.scalar-client .ui-not-open\\:pb-0[data-headlessui-state]:not([data-headlessui-state~=open]){padding-bottom:0}.scalar-client .ui-not-open\\:bg-transparent[data-headlessui-state]:not([data-headlessui-state~=open]){--tw-bg-base:transparent}.scalar-client .ui-not-open\\:hover\\:bg-b-2:hover[data-headlessui-state]:not([data-headlessui-state~=open]){background-color:var(--scalar-background-2)}.scalar-client .ui-not-open\\:hover\\:bg-b-2:hover[data-headlessui-state]:not([data-headlessui-state~=open]){--tw-bg-base:var(--scalar-background-2)}.scalar-client :where([data-headlessui-state]:not([data-headlessui-state~=open])) .ui-not-open\\:invisible:not([data-headlessui-state]){visibility:hidden}.scalar-client :where([data-headlessui-state]:not([data-headlessui-state~=open])) .ui-not-open\\:mb-0:not([data-headlessui-state]){margin-bottom:0}.scalar-client :where([data-headlessui-state]:not([data-headlessui-state~=open])) .ui-not-open\\:rotate-0:not([data-headlessui-state]){--tw-rotate:0deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scalar-client :where([data-headlessui-state]:not([data-headlessui-state~=open])) .ui-not-open\\:bg-transparent:not([data-headlessui-state]){background-color:transparent}.scalar-client :where([data-headlessui-state]:not([data-headlessui-state~=open])) .ui-not-open\\:pb-0:not([data-headlessui-state]){padding-bottom:0}.scalar-client :where([data-headlessui-state]:not([data-headlessui-state~=open])) .ui-not-open\\:bg-transparent:not([data-headlessui-state]){--tw-bg-base:transparent}.scalar-client :where([data-headlessui-state]:not([data-headlessui-state~=open])) .ui-not-open\\:hover\\:bg-b-2:hover:not([data-headlessui-state]){background-color:var(--scalar-background-2)}.scalar-client :where([data-headlessui-state]:not([data-headlessui-state~=open])) .ui-not-open\\:hover\\:bg-b-2:hover:not([data-headlessui-state]){--tw-bg-base:var(--scalar-background-2)}.scalar-client .ui-checked\\:bg-b-3[data-headlessui-state~=checked]{background-color:var(--scalar-background-3)}.scalar-client .ui-checked\\:bg-b-3[data-headlessui-state~=checked]{--tw-bg-base:var(--scalar-background-3)}.scalar-client :where([data-headlessui-state~=checked]) .ui-checked\\:bg-b-3{background-color:var(--scalar-background-3)}.scalar-client :where([data-headlessui-state~=checked]) .ui-checked\\:bg-b-3{--tw-bg-base:var(--scalar-background-3)}.scalar-client .ui-active\\:bg-b-2[data-headlessui-state~=active]{background-color:var(--scalar-background-2)}.scalar-client .ui-active\\:bg-b-2[data-headlessui-state~=active]{--tw-bg-base:var(--scalar-background-2)}.scalar-client :where([data-headlessui-state~=active]) .ui-active\\:bg-b-2{background-color:var(--scalar-background-2)}.scalar-client :where([data-headlessui-state~=active]) .ui-active\\:bg-b-2{--tw-bg-base:var(--scalar-background-2)}@media (min-width: 600px){.scalar-client .sm\\:order-none{order:0}}@media (min-width: 600px){.scalar-client .sm\\:flex-row{flex-direction:row}}@media (min-width: 600px){.scalar-client .sm\\:flex-col{flex-direction:column}}@media (min-width: 800px){.scalar-client .md\\:mx-1{margin-left:4px;margin-right:4px}}@media (min-width: 800px){.scalar-client .md\\:block{display:block}}@media (min-width: 800px){.scalar-client .md\\:flex{display:flex}}@media (min-width: 800px){.scalar-client .md\\:w-full{width:100%}}@media (min-width: 800px){.scalar-client .md\\:min-w-fit{min-width:-moz-fit-content;min-width:fit-content}}@media (min-width: 800px){.scalar-client .md\\:flex-none{flex:none}}@media (min-width: 800px){.scalar-client .md\\:flex-row{flex-direction:row}}@media (min-width: 800px){.scalar-client .md\\:border-b-0{border-bottom-width:0}}@media (min-width: 800px){.scalar-client .md\\:border-r-1\\/2{border-right-width:calc(var(--scalar-border-width) / 2)}}@media (min-width: 800px){.scalar-client .md\\:p-1{padding:4px}}@media (min-width: 800px){.scalar-client .md\\:p-1\\.5{padding:6px}}@media (min-width: 800px){.scalar-client .md\\:p-5{padding:20px}}@media (min-width: 800px){.scalar-client .md\\:px-2{padding-left:8px;padding-right:8px}}@media (min-width: 800px){.scalar-client .md\\:px-2\\.5{padding-left:10px;padding-right:10px}}@media (min-width: 800px){.scalar-client .md\\:px-4{padding-left:16px;padding-right:16px}}@media (min-width: 800px){.scalar-client .md\\:py-2{padding-top:8px;padding-bottom:8px}}@media (min-width: 800px){.scalar-client .md\\:py-2\\.5{padding-top:10px;padding-bottom:10px}}@media (min-width: 800px){.scalar-client .md\\:pb-2{padding-bottom:8px}}@media (min-width: 800px){.scalar-client .md\\:pb-2\\.5{padding-bottom:10px}}@media (min-width: 800px){.scalar-client .md\\:pb-\\[37px\\]{padding-bottom:37px}}@media (min-width: 800px){.scalar-client .md\\:pl-1{padding-left:4px}}@media (min-width: 800px){.scalar-client .md\\:\\*\\:border-t-0>*{border-top-width:0}}@media (min-width: 1000px){.scalar-client .lg\\:order-none{order:0}}@media (min-width: 1000px){.scalar-client .lg\\:mb-0{margin-bottom:0}}@media (min-width: 1000px){.scalar-client .lg\\:flex{display:flex}}@media (min-width: 1000px){.scalar-client .lg\\:min-h-header{min-height:var(--scalar-client-header-height)}}@media (min-width: 1000px){.scalar-client .lg\\:w-\\[120px\\]{width:120px}}@media (min-width: 1000px){.scalar-client .lg\\:w-auto{width:auto}}@media (min-width: 1000px){.scalar-client .lg\\:min-w-\\[720px\\]{min-width:720px}}@media (min-width: 1000px){.scalar-client .lg\\:max-w-\\[720px\\]{max-width:720px}}@media (min-width: 1000px){.scalar-client .lg\\:flex-1{flex:1 1 0%}}@media (min-width: 1000px){.scalar-client .lg\\:p-1{padding:4px}}@media (min-width: 1000px){.scalar-client .lg\\:px-1{padding-left:4px;padding-right:4px}}@media (min-width: 1000px){.scalar-client .lg\\:px-2{padding-left:8px;padding-right:8px}}@media (min-width: 1000px){.scalar-client .lg\\:px-2\\.5{padding-left:10px;padding-right:10px}}@media (min-width: 1000px){.scalar-client .lg\\:pr-24{padding-right:96px}}@media (min-width: 1000px){.scalar-client .lg\\:text-sm{font-size:var(--scalar-font-size-4)}}@media (min-width: 1200px){.scalar-client .xl\\:flex{display:flex}}@media (min-width: 1200px){.scalar-client .xl\\:min-h-header{min-height:var(--scalar-client-header-height)}}@media (min-width: 1200px){.scalar-client .xl\\:min-w-0{min-width:0px}}@media (min-width: 1200px){.scalar-client .xl\\:flex-1{flex:1 1 0%}}@media (min-width: 1200px){.scalar-client .xl\\:flex-row{flex-direction:row}}@media (min-width: 1200px){.scalar-client .xl\\:overflow-hidden{overflow:hidden}}@media (min-width: 1200px){.scalar-client .xl\\:rounded-none{border-radius:0}}@media (min-width: 1200px){.scalar-client .xl\\:px-4{padding-left:16px;padding-right:16px}}@media (min-width: 1200px){.scalar-client .xl\\:px-6{padding-left:24px;padding-right:24px}}@media (min-width: 1200px){.scalar-client .xl\\:pr-5{padding-right:20px}}@media (min-width: 1200px){.scalar-client .xl\\:\\*\\:border-l-1\\/2>*{border-left-width:calc(var(--scalar-border-width) / 2)}}@media (min-width: 1200px){.scalar-client .xl\\:\\*\\:border-t-0>*{border-top-width:0}}@media (min-width: 1200px){.scalar-client .xl\\:first\\:\\*\\:border-l-0>*:first-child{border-left-width:0}}.scalar-client .dark\\:hover\\:bg-b-2:hover:where(.dark-mode,.dark-mode *){background-color:var(--scalar-background-2)}.scalar-client .dark\\:hover\\:bg-b-2:hover:where(.dark-mode,.dark-mode *){--tw-bg-base:var(--scalar-background-2)}:root{--scalar-client-header-height: 50px;--scalar-sidebar-width: 280px;--scalar-toc-width: 280px}.scalar .scalar-api-client[data-v-900788ee]{max-height:calc(100% - calc(var(--scalar-app-header-height)));border-radius:8px}.scalar .scalar-app-layout[data-v-900788ee]{background:var(--scalar-background-1);height:calc(100% - 120px);max-width:1390px;width:100%;margin:auto;opacity:0;animation:scalarapiclientfadein-900788ee .35s forwards;position:relative;overflow:hidden;border-radius:8px}@keyframes scalarapiclientfadein-900788ee{0%{opacity:0}to{opacity:1}}.scalar .scalar-app-exit[data-v-900788ee]{position:fixed;top:0;left:0;width:100vw;height:100vh;background:#00000038;transition:all .3s ease-in-out;cursor:pointer;animation:scalardrawerexitfadein-900788ee .35s forwards}.dark-mode .scalar .scalar-app-exit[data-v-900788ee]{background:#00000073}.scalar .scalar-app-exit[data-v-900788ee]:before{font-family:sans-serif;position:absolute;top:0;font-size:30px;font-weight:100;line-height:50px;right:12px;text-align:center;color:#fff;opacity:.6}.scalar .scalar-app-exit[data-v-900788ee]:hover:before{opacity:1}@keyframes scalardrawerexitfadein-900788ee{0%{opacity:0}to{opacity:1}}.scalar-container[data-v-900788ee]{overflow:hidden;visibility:visible;position:fixed;bottom:0;top:0;left:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.scalar .url-form-input[data-v-900788ee]{min-height:auto!important}.scalar .scalar-container[data-v-900788ee]{line-height:normal}.scalar .scalar-app-header span[data-v-900788ee]{color:var(--scalar-color-3)}.scalar .scalar-app-header a[data-v-900788ee]{color:var(--scalar-color-1)}.scalar .scalar-app-header a[data-v-900788ee]:hover{text-decoration:underline}.scalar-activate[data-v-900788ee]{width:-moz-fit-content;width:fit-content;margin:0px .75rem .75rem auto;line-height:24px;cursor:pointer;font-size:.875rem;font-weight:600;display:flex;align-items:center;gap:6px}.scalar-activate-button[data-v-900788ee]{display:flex;gap:6px;align-items:center;color:var(--scalar-color-blue);-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none;background:transparent;padding:0 .5rem}.scalar-activate:hover .scalar-activate-button[data-v-900788ee]{background:var(--scalar-background-3);border-radius:3px}.http-bg-gradient[data-v-a2902675]{background:linear-gradient(#ffffffbf,#00000009)}.http-bg-gradient[data-v-a2902675]:hover{background:linear-gradient(#00000009,#ffffffbf)}.dark-mode .http-bg-gradient[data-v-a2902675]{background:linear-gradient(#ffffff09,#00000026)}.dark-mode .http-bg-gradient[data-v-a2902675]:hover{background:linear-gradient(#00000026,#ffffff09)}.scroll-timeline-x[data-v-50c10cc9]{overflow:auto;scroll-timeline:--scroll-timeline x;scroll-timeline:--scroll-timeline horizontal;-ms-overflow-style:none;scrollbar-width:none}.fade-request-section-content[data-v-1bc6f599]{background:linear-gradient(to left,var(--scalar-background-1) 64%,transparent)}.filter-hover[data-v-1bc6f599]{height:100%;padding-right:42px;padding-left:24px;position:absolute;right:0;transition:width 0s ease-in-out .2s;overflow:hidden}.filter-hover[data-v-1bc6f599]:hover{width:100%}.filter-hover[data-v-1bc6f599]:before{content:"";position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--scalar-background-1);opacity:0;transition:all .3s ease-in-out;pointer-events:none}.filter-hover button[data-v-1bc6f599]{opacity:0}.filter-hover button[data-v-1bc6f599]:not(:last-of-type){transform:translate3d(0,3px,0)}.filter-hover:hover button[data-v-1bc6f599]{transition:opacity .2s ease-in-out,transform .2s ease-in-out}.filter-hover:hover button[data-v-1bc6f599]:nth-last-of-type(1){transition-delay:.05s}.filter-hover:hover button[data-v-1bc6f599]:nth-last-of-type(2){transition-delay:.1s}.filter-hover:hover button[data-v-1bc6f599]:nth-last-of-type(3){transition-delay:.15s}.filter-hover:hover button[data-v-1bc6f599]:nth-last-of-type(4){transition-delay:.2s}.filter-hover:hover button[data-v-1bc6f599]:nth-last-of-type(5){transition-delay:.25s}.filter-hover:hover button[data-v-1bc6f599]:nth-last-of-type(6){transition-delay:.3s}.filter-hover:hover button[data-v-1bc6f599]:nth-last-of-type(7){transition-delay:.4s}.filter-hover:hover button[data-v-1bc6f599]{opacity:1;transform:translateZ(0)}.filter-hover[data-v-1bc6f599]:hover:before{opacity:.9;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}[data-v-9121d6e5] .cm-editor{height:100%;outline:none;padding:0;background:transparent}[data-v-9121d6e5] .cm-placeholder{color:var(--scalar-color-3)}[data-v-9121d6e5] .cm-content{font-family:var(--scalar-font-code);font-size:var(--scalar-small);max-height:20px;padding:8px 0}[data-v-9121d6e5] .cm-tooltip{background:transparent!important;filter:brightness(var(--scalar-lifted-brightness));border-radius:var(--scalar-radius);box-shadow:var(--scalar-shadow-2);border:none!important;outline:none!important;overflow:hidden!important}[data-v-9121d6e5] .cm-tooltip-autocomplete ul li{padding:3px 6px!important}[data-v-9121d6e5] .cm-completionIcon-type:after{color:var(--scalar-color-3)!important}[data-v-9121d6e5] .cm-tooltip-autocomplete ul li[aria-selected]{background:var(--scalar-background-2)!important;color:var(--scalar-color-1)!important}[data-v-9121d6e5] .cm-tooltip-autocomplete ul{padding:6px!important;position:relative}[data-v-9121d6e5] .cm-tooltip-autocomplete ul li:hover{border-radius:3px;color:var(--scalar-color-1)!important;background:var(--scalar-background-3)!important}[data-v-9121d6e5] .cm-activeLine,[data-v-9121d6e5] .cm-activeLineGutter{background-color:transparent}[data-v-9121d6e5] .cm-selectionMatch,[data-v-9121d6e5] .cm-matchingBracket{border-radius:var(--scalar-radius);background:var(--scalar-background-4)!important}[data-v-9121d6e5] .cm-css-color-picker-wrapper{display:inline-flex;outline:1px solid var(--scalar-background-3);border-radius:3px;overflow:hidden}[data-v-9121d6e5] .cm-gutters{background-color:var(--scalar-background-1);border-right:none;color:var(--scalar-color-3);font-size:var(--scalar-small);line-height:1.44;border-radius:0 0 0 3px}[data-v-9121d6e5] .cm-gutterElement{font-family:var(--scalar-font-code)!important;padding:0 6px 0 8px!important;display:flex;align-items:center;justify-content:flex-end}[data-v-9121d6e5] .cm-gutter+.cm-gutter :not(.cm-foldGutter) .cm-gutterElement{padding-left:0!important}[data-v-9121d6e5] .cm-scroller{overflow:auto}.cm-pill{--tw-bg-base: var(--scalar-color-1);color:var(--tw-bg-base);padding:0 9px;display:inline-block;border-radius:30px;font-size:var(--scalar-mini);background:color-mix(in srgb,var(--tw-bg-base),transparent 94%)!important}.cm-pill.bg-grey{background:var(--scalar-background-3)!important}.dark-mode .cm-pill{background:color-mix(in srgb,var(--tw-bg-base),transparent 80%)!important}.cm-pill:first-of-type{margin-left:0}.cm-editor .cm-widgetBuffer{display:none}.cm-foldPlaceholder:hover{color:var(--scalar-color-1)}.cm-foldGutter .cm-gutterElement{font-size:var(--scalar-heading-4);padding:2px!important}.cm-foldGutter .cm-gutterElement:first-of-type{display:none}.cm-foldGutter .cm-gutterElement .cm-foldMarker{padding:2px}.cm-foldGutter .cm-gutterElement:hover .cm-foldMarker{background:var(--scalar-background-2);border-radius:var(--scalar-radius);color:var(--scalar-color-1)}.cm-focused .cm-content ::-moz-selection{background:var(--scalar-selection-background)!important;color:var(--scalar-selection-color)}.cm-focused .cm-content ::selection{background:var(--scalar-selection-background)!important;color:var(--scalar-selection-color)}[data-v-1f355550] .cm-editor{padding:0}[data-v-1f355550] .cm-content{align-items:center;background-color:transparent;display:flex;font-family:var(--scalar-font);font-size:var(--scalar-mini);padding:6px 8px}[data-v-1f355550] .cm-content:has(.cm-pill){padding:4px 3px}[data-v-1f355550] .cm-content .cm-pill:not(:last-of-type){margin-right:.5px}[data-v-1f355550] .cm-content .cm-pill:not(:first-of-type){margin-left:.5px}[data-v-1f355550] .cm-line{padding:0}.filemask[data-v-1f355550]{-webkit-mask-image:linear-gradient(to right,transparent 0,var(--scalar-background-2) 20px);mask-image:linear-gradient(to right,transparent 0,var(--scalar-background-2) 20px)}[data-v-33e11d9f] .cm-content{font-size:var(--scalar-mini)}[data-v-0417d80a] .cm-editor{padding:0}[data-v-0417d80a] .cm-content{align-items:center;background-color:transparent;display:flex;font-family:var(--scalar-font);font-size:var(--scalar-mini);padding:6px 8px}[data-v-0417d80a] .cm-content:has(.cm-pill){padding:4px 3px}[data-v-0417d80a] .cm-content .cm-pill:not(:last-of-type){margin-right:.5px}[data-v-0417d80a] .cm-content .cm-pill:not(:first-of-type){margin-left:.5px}[data-v-0417d80a] .cm-line{padding:0}.required[data-v-0417d80a]:after{content:"Required"}input[data-v-0417d80a]::-moz-placeholder{color:var(--scalar-color-3)}input[data-v-0417d80a]::placeholder{color:var(--scalar-color-3)}.auth-combobox-position[data-v-4a75f9a1]{margin-left:120px}.scroll-timeline-x[data-v-4a75f9a1]{overflow:auto;scroll-timeline:--scroll-timeline x;scroll-timeline:--scroll-timeline horizontal;scrollbar-width:none;-ms-overflow-style:none}.fade-left[data-v-4a75f9a1],.fade-right[data-v-4a75f9a1]{position:sticky;content:"";height:100%;animation-name:fadein-4a75f9a1;animation-duration:1ms;animation-direction:reverse;animation-timeline:--scroll-timeline;min-height:24px;pointer-events:none}.fade-left[data-v-4a75f9a1]{background:linear-gradient(-90deg,color-mix(in srgb,var(--scalar-background-1),transparent 100%) 0%,color-mix(in srgb,var(--scalar-background-1),transparent 20%) 60%,var(--scalar-background-1) 100%);min-width:3px;left:-1px;animation-direction:normal}.fade-right[data-v-4a75f9a1]{background:linear-gradient(90deg,color-mix(in srgb,var(--scalar-background-1),transparent 100%) 0%,color-mix(in srgb,var(--scalar-background-1),transparent 20%) 60%,var(--scalar-background-1) 100%);margin-left:-20px;min-width:24px;right:-1px;top:0}@keyframes fadein-4a75f9a1{0%{opacity:0}15%{opacity:1}}.request-section-content{--scalar-border-width: .5px}.request-section-content-filter{box-shadow:0 -10px 0 10px var(--scalar-background-1)}.request-item:focus-within .request-meta-buttons{opacity:1}.addressbar-history-button[data-v-0e166ebf]:hover{background:var(--scalar-background-3)}.addressbar-history-button[data-v-0e166ebf]:focus-within{background:var(--scalar-background-2)}[data-v-19d5c366] .cm-editor{background-color:var(--scalar-background-1);height:100%;outline:none;width:100%}[data-v-19d5c366] .cm-content{padding:0;display:flex;align-items:center;font-size:var(--scalar-mini)}.scroll-timeline-x[data-v-19d5c366]{scroll-timeline:--scroll-timeline x;scroll-timeline:--scroll-timeline horizontal;-ms-overflow-style:none}.scroll-timeline-x-hidden[data-v-19d5c366]{overflow:hidden}.scroll-timeline-x-hidden[data-v-19d5c366] .cm-scroller{scrollbar-width:none;-ms-overflow-style:none;padding-right:20px;overflow:auto}.scroll-timeline-x-hidden[data-v-19d5c366]::-webkit-scrollbar{width:0;height:0;display:none}.scroll-timeline-x-hidden[data-v-19d5c366] .cm-scroller::-webkit-scrollbar{width:0;height:0;display:none}.scroll-timeline-x-address[data-v-19d5c366]{line-height:27px;scrollbar-width:none}.scroll-timeline-x-address[data-v-19d5c366]:after{content:"";position:absolute;height:100%;width:24px;right:0;cursor:text}.scroll-timeline-x-address[data-v-19d5c366]:empty:before{content:"Enter URL or cURL request";color:var(--scalar-color-3);pointer-events:none}.fade-left[data-v-19d5c366],.fade-right[data-v-19d5c366]{content:"";position:sticky;height:100%;animation-name:fadein-19d5c366;animation-duration:1ms;animation-direction:reverse;animation-timeline:--scroll-timeline;pointer-events:none}.fade-left[data-v-19d5c366]{background:linear-gradient(-90deg,color-mix(in srgb,var(--scalar-background-1),transparent 100%) 0%,color-mix(in srgb,var(--scalar-background-1),transparent 20%) 30%,var(--scalar-background-1) 100%);left:0;min-width:3px;animation-direction:normal}.fade-right[data-v-19d5c366]{background:linear-gradient(90deg,color-mix(in srgb,var(--scalar-background-1),transparent 100%) 0%,color-mix(in srgb,var(--scalar-background-1),transparent 20%) 30%,var(--scalar-background-1) 100%);right:0;min-width:24px}@keyframes fadein-19d5c366{0%{opacity:0}1%{opacity:1}}.codemirror-bg-switcher[data-v-19d5c366]{--scalar-background-1: var(--scalar-background-2)}.addressbar-bg-states:focus-within .codemirror-bg-switcher[data-v-19d5c366]{--scalar-background-1: var(--scalar-background-1)}.addressbar-bg-states[data-v-19d5c366]{background:var(--scalar-background-2);border-color:transparent}.addressbar-bg-states[data-v-19d5c366]:focus-within{background:var(--scalar-background-1);border-color:var(--scalar-border-color)}.delete-warning-button[data-v-c3d3d457]{background:color-mix(in srgb,var(--scalar-color-red),transparent 95%);color:var(--scalar-color-red)}.delete-warning-button[data-v-c3d3d457]:hover,.delete-warning-button[data-v-c3d3d457]:focus{background:color-mix(in srgb,var(--scalar-color-red),transparent 90%)}.gitbook-show[data-v-89f09c6b]{display:none}.light-mode .bg-preview[data-v-7fbe3767]{background-image:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'16\' height=\'16\' fill=\'%23000\' fill-opacity=\'10%25\'%3E%3Crect width=\'8\' height=\'8\' /%3E%3Crect x=\'8\' y=\'8\' width=\'8\' height=\'8\' /%3E%3C/svg%3E")}.dark-mode .bg-preview[data-v-7fbe3767]{background-image:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'16\' height=\'16\' fill=\'%23FFF\' fill-opacity=\'10%25\'%3E%3Crect width=\'8\' height=\'8\' /%3E%3Crect x=\'8\' y=\'8\' width=\'8\' height=\'8\' /%3E%3C/svg%3E")}[data-v-b7d4ba6e] .cm-editor{background-color:transparent;font-size:var(--scalar-mini);outline:none}[data-v-b7d4ba6e] .cm-gutters{background-color:var(--scalar-background-1);border-radius:var(--scalar-radius) 0 0 var(--scalar-radius)}.ascii-art-animate .ascii-art-line[data-v-93347509]{border-right:1ch solid transparent;animation:typewriter-93347509 4s steps(1) 1s 1 normal both,blinkTextCursor-93347509 .5s steps(1) infinite normal}@keyframes typewriter-93347509{0%{width:0}to{width:100%}}@keyframes blinkTextCursor-93347509{0%{border-right-color:currentColor}50%{border-right-color:transparent}}.scalar-version-number[data-v-cf8761cd]{transform:skew(0,16deg);width:66px;height:66px;position:absolute;margin-left:-33px;font-size:8px;font-family:var(--scalar-font-code);line-height:11px;margin-top:-110px}.scalar-version-number b[data-v-cf8761cd]{font-weight:700}.v-enter-active[data-v-ef5f83d8]{transition:opacity .5s ease}.v-enter-from[data-v-ef5f83d8]{opacity:0}.response-body-virtual[data-headlessui-state=open],.response-body-virtual[data-headlessui-state=open] .diclosure-panel{display:flex;flex-direction:column;flex-grow:1}.sidebar-height[data-v-6d244398]{min-height:100%}@media (min-width: 800px){.sidebar-mask[data-v-6d244398]{-webkit-mask-image:linear-gradient(0,transparent 0,transparent 0,var(--scalar-background-2) 30px);mask-image:linear-gradient(0,transparent 0,transparent 0,var(--scalar-background-2) 30px)}}.resizer[data-v-6d244398]{width:5px;cursor:col-resize;position:absolute;top:0;right:0;bottom:0;border-right:2px solid transparent;transition:border-right-color .3s}.resizer[data-v-6d244398]:hover,.dragging .resizer[data-v-6d244398]{border-right-color:var(--scalar-background-3)}.dragging[data-v-6d244398]{cursor:col-resize}.dragging[data-v-6d244398]:before{content:"";display:block;position:absolute;width:100%;height:100%}.ellipsis-position[data-v-dd8b3a7e]{transform:translate3d(calc(-100% - 4.5px),0,0)}.dragover-asChild[data-v-1c55d212],.dragover-above[data-v-1c55d212],.dragover-below[data-v-1c55d212]{position:relative}.dragover-above[data-v-1c55d212]:after,.dragover-below[data-v-1c55d212]:after{content:"";position:absolute;top:-1.5px;height:3px;width:100%;display:block;background:color-mix(in srgb,var(--scalar-color-blue),transparent 85%);pointer-events:none;border-radius:var(--scalar-radius)}.dragover-below[data-v-1c55d212]:after{top:initial;bottom:-1.5px}.dragover-asChild[data-v-1c55d212]:after{content:"";position:absolute;top:0;left:0;width:100%;height:100%;display:block;background:color-mix(in srgb,var(--scalar-color-blue),transparent 85%);pointer-events:none;border-radius:var(--scalar-radius)}.indent-border-line-offset[data-v-0eb4db04]:before{left:var(--7aec5b39)}.indent-padding-left[data-v-0eb4db04]{padding-left:calc(var(--296ea3e5) + 6px)}.editable-sidebar-hover:hover .editable-sidebar-hover-item[data-v-0eb4db04]{-webkit-mask-image:linear-gradient(to left,transparent 10px,var(--scalar-background-2) 30px);mask-image:linear-gradient(to left,transparent 10px,var(--scalar-background-2) 30px)}.sidebar-folderitem[data-v-0eb4db04] .ellipsis-position{right:6px;transform:none}.word-break-break-word[data-v-0eb4db04]{word-break:break-word}.search-button-fade[data-v-beea081e]{background:linear-gradient(var(--scalar-background-1) 44px,color-mix(in srgb,var(--scalar-background-1),transparent) 50px,transparent)}.empty-sidebar-item[data-v-beea081e] .scalar-button{background:var(--scalar-button-1);color:var(--scalar-button-1-color)}.empty-sidebar-item[data-v-beea081e] .scalar-button:hover{background:var(--scalar-button-1-hover)}.empty-sidebar-item[data-v-beea081e] .add-item-hotkey{color:var(--scalar-button-1-color);background:color-mix(in srgb,var(--scalar-button-1),white 20%);border-color:transparent}.empty-sidebar-item-content[data-v-beea081e]{display:none}.empty-sidebar-item .empty-sidebar-item-content[data-v-beea081e]{display:block}.rabbitjump[data-v-beea081e]{opacity:0}.empty-sidebar-item:hover .rabbitjump[data-v-beea081e]{opacity:1;animation:rabbitAnimation-beea081e .5s steps(1) infinite}.empty-sidebar-item:hover .rabbitsit[data-v-beea081e]{opacity:0;animation:rabbitAnimation2-beea081e .5s steps(1) infinite}.empty-sidebar-item:hover .rabbit-ascii[data-v-beea081e]{animation:rabbitRun-beea081e 8s infinite linear}@keyframes rabbitRun-beea081e{0%{transform:translateZ(0)}25%{transform:translate3d(250px,0,0)}25.01%{transform:translate3d(-250px,0,0)}75%{transform:translate3d(250px,0,0)}75.01%{transform:translate3d(-250px,0,0)}to{transform:translateZ(0)}}@keyframes rabbitAnimation-beea081e{0%,to{opacity:1}50%{opacity:0}}@keyframes rabbitAnimation2-beea081e{0%,to{opacity:0}50%{opacity:1;transform:translate3d(0,-8px,0)}}.request-text-color-text[data-v-e56f92be]{color:var(--scalar-color-1);background:linear-gradient(var(--scalar-background-1),var(--scalar-background-3));box-shadow:0 0 0 1px var(--scalar-border-color)}@media screen and (max-width: 800px){.sidebar-active-hide-layout[data-v-e56f92be]{display:none}.sidebar-active-width[data-v-e56f92be]{width:100%}}.active-link[data-v-271914bc]{background-color:var(--scalar-background-2);color:var(--scalar-color-1);--tw-bg-base: var(--scalar-background-2)}.empty-variable-name[data-v-271914bc]:empty:before{content:"No Name";color:var(--scalar-color-3)}.cookie>a[data-v-271914bc]{padding-left:40px}')),document.head.appendChild(a)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}}();
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
/**
* @vue/shared v3.5.12
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function makeMap(str) {
const map2 = /* @__PURE__ */ Object.create(null);
for (const key2 of str.split(",")) map2[key2] = 1;
return (val) => val in map2;
}
const EMPTY_OBJ = {};
const EMPTY_ARR = [];
const NOOP = () => {
};
const NO = () => false;
const isOn = (key2) => key2.charCodeAt(0) === 111 && key2.charCodeAt(1) === 110 && // uppercase letter
(key2.charCodeAt(2) > 122 || key2.charCodeAt(2) < 97);
const isModelListener = (key2) => key2.startsWith("onUpdate:");
const extend$3 = Object.assign;
const remove$1 = (arr, el) => {
const i2 = arr.indexOf(el);
if (i2 > -1) {
arr.splice(i2, 1);
}
};
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
const hasOwn$2 = (val, key2) => hasOwnProperty$1.call(val, key2);
const isArray$3 = Array.isArray;
const isMap$1 = (val) => toTypeString(val) === "[object Map]";
const isSet = (val) => toTypeString(val) === "[object Set]";
const isFunction = (val) => typeof val === "function";
const isString$1 = (val) => typeof val === "string";
const isSymbol = (val) => typeof val === "symbol";
const isObject$2 = (val) => val !== null && typeof val === "object";
const isPromise = (val) => {
return (isObject$2(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
};
const objectToString = Object.prototype.toString;
const toTypeString = (value) => objectToString.call(value);
const toRawType = (value) => {
return toTypeString(value).slice(8, -1);
};
const isPlainObject$2 = (val) => toTypeString(val) === "[object Object]";
const isIntegerKey = (key2) => isString$1(key2) && key2 !== "NaN" && key2[0] !== "-" && "" + parseInt(key2, 10) === key2;
const isReservedProp = /* @__PURE__ */ makeMap(
// the leading comma is intentional so empty string "" is also included
",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
);
const cacheStringFunction = (fn) => {
const cache2 = /* @__PURE__ */ Object.create(null);
return (str) => {
const hit = cache2[str];
return hit || (cache2[str] = fn(str));
};
};
const camelizeRE = /-(\w)/g;
const camelize = cacheStringFunction(
(str) => {
return str.replace(camelizeRE, (_2, c2) => c2 ? c2.toUpperCase() : "");
}
);
const hyphenateRE = /\B([A-Z])/g;
const hyphenate = cacheStringFunction(
(str) => str.replace(hyphenateRE, "-$1").toLowerCase()
);
const capitalize$1 = cacheStringFunction((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
const toHandlerKey = cacheStringFunction(
(str) => {
const s3 = str ? `on${capitalize$1(str)}` : ``;
return s3;
}
);
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
const invokeArrayFns = (fns, ...arg) => {
for (let i2 = 0; i2 < fns.length; i2++) {
fns[i2](...arg);
}
};
const def = (obj, key2, value, writable = false) => {
Object.defineProperty(obj, key2, {
configurable: true,
enumerable: false,
writable,
value
});
};
const looseToNumber = (val) => {
const n2 = parseFloat(val);
return isNaN(n2) ? val : n2;
};
const toNumber = (val) => {
const n2 = isString$1(val) ? Number(val) : NaN;
return isNaN(n2) ? val : n2;
};
let _globalThis;
const getGlobalThis = () => {
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
};
function normalizeStyle(value) {
if (isArray$3(value)) {
const res = {};
for (let i2 = 0; i2 < value.length; i2++) {
const item = value[i2];
const normalized = isString$1(item) ? parseStringStyle(item) : normalizeStyle(item);
if (normalized) {
for (const key2 in normalized) {
res[key2] = normalized[key2];
}
}
}
return res;
} else if (isString$1(value) || isObject$2(value)) {
return value;
}
}
const listDelimiterRE = /;(?![^(]*\))/g;
const propertyDelimiterRE = /:([^]+)/;
const styleCommentRE = /\/\*[^]*?\*\//g;
function parseStringStyle(cssText) {
const ret = {};
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
if (item) {
const tmp = item.split(propertyDelimiterRE);
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
}
});
return ret;
}
function normalizeClass(value) {
let res = "";
if (isString$1(value)) {
res = value;
} else if (isArray$3(value)) {
for (let i2 = 0; i2 < value.length; i2++) {
const normalized = normalizeClass(value[i2]);
if (normalized) {
res += normalized + " ";
}
}
} else if (isObject$2(value)) {
for (const name2 in value) {
if (value[name2]) {
res += name2 + " ";
}
}
}
return res.trim();
}
function normalizeProps(props) {
if (!props) return null;
let { class: klass, style: style2 } = props;
if (klass && !isString$1(klass)) {
props.class = normalizeClass(klass);
}
if (style2) {
props.style = normalizeStyle(style2);
}
return props;
}
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
function includeBooleanAttr(value) {
return !!value || value === "";
}
const isRef$1 = (val) => {
return !!(val && val["__v_isRef"] === true);
};
const toDisplayString = (val) => {
return isString$1(val) ? val : val == null ? "" : isArray$3(val) || isObject$2(val) && (val.toString === objectToString || !isFunction(val.toString)) ? isRef$1(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
};
const replacer = (_key, val) => {
if (isRef$1(val)) {
return replacer(_key, val.value);
} else if (isMap$1(val)) {
return {
[`Map(${val.size})`]: [...val.entries()].reduce(
(entries2, [key2, val2], i2) => {
entries2[stringifySymbol(key2, i2) + " =>"] = val2;
return entries2;
},
{}
)
};
} else if (isSet(val)) {
return {
[`Set(${val.size})`]: [...val.values()].map((v2) => stringifySymbol(v2))
};
} else if (isSymbol(val)) {
return stringifySymbol(val);
} else if (isObject$2(val) && !isArray$3(val) && !isPlainObject$2(val)) {
return String(val);
}
return val;
};
const stringifySymbol = (v2, i2 = "") => {
var _a2;
return (
// Symbol.description in es2019+ so we need to cast here to pass
// the lib: es2016 check
isSymbol(v2) ? `Symbol(${(_a2 = v2.description) != null ? _a2 : i2})` : v2
);
};
/**
* @vue/reactivity v3.5.12
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
let activeEffectScope;
class EffectScope {
constructor(detached = false) {
this.detached = detached;
this._active = true;
this.effects = [];
this.cleanups = [];
this._isPaused = false;
this.parent = activeEffectScope;
if (!detached && activeEffectScope) {
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
this
) - 1;
}
}
get active() {
return this._active;
}
pause() {
if (this._active) {
this._isPaused = true;
let i2, l2;
if (this.scopes) {
for (i2 = 0, l2 = this.scopes.length; i2 < l2; i2++) {
this.scopes[i2].pause();
}
}
for (i2 = 0, l2 = this.effects.length; i2 < l2; i2++) {
this.effects[i2].pause();
}
}
}
/**
* Resumes the effect scope, including all child scopes and effects.
*/
resume() {
if (this._active) {
if (this._isPaused) {
this._isPaused = false;
let i2, l2;
if (this.scopes) {
for (i2 = 0, l2 = this.scopes.length; i2 < l2; i2++) {
this.scopes[i2].resume();
}
}
for (i2 = 0, l2 = this.effects.length; i2 < l2; i2++) {
this.effects[i2].resume();
}
}
}
}
run(fn) {
if (this._active) {
const currentEffectScope = activeEffectScope;
try {
activeEffectScope = this;
return fn();
} finally {
activeEffectScope = currentEffectScope;
}
}
}
/**
* This should only be called on non-detached scopes
* @internal
*/
on() {
activeEffectScope = this;
}
/**
* This should only be called on non-detached scopes
* @internal
*/
off() {
activeEffectScope = this.parent;
}
stop(fromParent) {
if (this._active) {
let i2, l2;
for (i2 = 0, l2 = this.effects.length; i2 < l2; i2++) {
this.effects[i2].stop();
}
for (i2 = 0, l2 = this.cleanups.length; i2 < l2; i2++) {
this.cleanups[i2]();
}
if (this.scopes) {
for (i2 = 0, l2 = this.scopes.length; i2 < l2; i2++) {
this.scopes[i2].stop(true);
}
}
if (!this.detached && this.parent && !fromParent) {
const last = this.parent.scopes.pop();
if (last && last !== this) {
this.parent.scopes[this.index] = last;
last.index = this.index;
}
}
this.parent = void 0;
this._active = false;
}
}
}
function effectScope(detached) {
return new EffectScope(detached);
}
function getCurrentScope() {
return activeEffectScope;
}
function onScopeDispose(fn, failSilently = false) {
if (activeEffectScope) {
activeEffectScope.cleanups.push(fn);
}
}
let activeSub;
const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
class ReactiveEffect {
constructor(fn) {
this.fn = fn;
this.deps = void 0;
this.depsTail = void 0;
this.flags = 1 | 4;
this.next = void 0;
this.cleanup = void 0;
this.scheduler = void 0;
if (activeEffectScope && activeEffectScope.active) {
activeEffectScope.effects.push(this);
}
}
pause() {
this.flags |= 64;
}
resume() {
if (this.flags & 64) {
this.flags &= ~64;
if (pausedQueueEffects.has(this)) {
pausedQueueEffects.delete(this);
this.trigger();
}
}
}
/**
* @internal
*/
notify() {
if (this.flags & 2 && !(this.flags & 32)) {
return;
}
if (!(this.flags & 8)) {
batch(this);
}
}
run() {
if (!(this.flags & 1)) {
return this.fn();
}
this.flags |= 2;
cleanupEffect(this);
prepareDeps(this);
const prevEffect = activeSub;
const prevShouldTrack = shouldTrack;
activeSub = this;
shouldTrack = true;
try {
return this.fn();
} finally {
cleanupDeps(this);
activeSub = prevEffect;
shouldTrack = prevShouldTrack;
this.flags &= ~2;
}
}
stop() {
if (this.flags & 1) {
for (let link = this.deps; link; link = link.nextDep) {
removeSub(link);
}
this.deps = this.depsTail = void 0;
cleanupEffect(this);
this.onStop && this.onStop();
this.flags &= ~1;
}
}
trigger() {
if (this.flags & 64) {
pausedQueueEffects.add(this);
} else if (this.scheduler) {
this.scheduler();
} else {
this.runIfDirty();
}
}
/**
* @internal
*/
runIfDirty() {
if (isDirty$1(this)) {
this.run();
}
}
get dirty() {
return isDirty$1(this);
}
}
let batchDepth = 0;
let batchedSub;
let batchedComputed;
function batch(sub, isComputed = false) {
sub.flags |= 8;
if (isComputed) {
sub.next = batchedComputed;
batchedComputed = sub;
return;
}
sub.next = batchedSub;
batchedSub = sub;
}
function startBatch() {
batchDepth++;
}
function endBatch() {
if (--batchDepth > 0) {
return;
}
if (batchedComputed) {
let e2 = batchedComputed;
batchedComputed = void 0;
while (e2) {
const next = e2.next;
e2.next = void 0;
e2.flags &= ~8;
e2 = next;
}
}
let error2;
while (batchedSub) {
let e2 = batchedSub;
batchedSub = void 0;
while (e2) {
const next = e2.next;
e2.next = void 0;
e2.flags &= ~8;
if (e2.flags & 1) {
try {
;
e2.trigger();
} catch (err) {
if (!error2) error2 = err;
}
}
e2 = next;
}
}
if (error2) throw error2;
}
function prepareDeps(sub) {
for (let link = sub.deps; link; link = link.nextDep) {
link.version = -1;
link.prevActiveLink = link.dep.activeLink;
link.dep.activeLink = link;
}
}
function cleanupDeps(sub) {
let head2;
let tail = sub.depsTail;
let link = tail;
while (link) {
const prev = link.prevDep;
if (link.version === -1) {
if (link === tail) tail = prev;
removeSub(link);
removeDep(link);
} else {
head2 = link;
}
link.dep.activeLink = link.prevActiveLink;
link.prevActiveLink = void 0;
link = prev;
}
sub.deps = head2;
sub.depsTail = tail;
}
function isDirty$1(sub) {
for (let link = sub.deps; link; link = link.nextDep) {
if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
return true;
}
}
if (sub._dirty) {
return true;
}
return false;
}
function refreshComputed(computed2) {
if (computed2.flags & 4 && !(computed2.flags & 16)) {
return;
}
computed2.flags &= ~16;
if (computed2.globalVersion === globalVersion) {
return;
}
computed2.globalVersion = globalVersion;
const dep = computed2.dep;
computed2.flags |= 2;
if (dep.version > 0 && !computed2.isSSR && computed2.deps && !isDirty$1(computed2)) {
computed2.flags &= ~2;
return;
}
const prevSub = activeSub;
const prevShouldTrack = shouldTrack;
activeSub = computed2;
shouldTrack = true;
try {
prepareDeps(computed2);
const value = computed2.fn(computed2._value);
if (dep.version === 0 || hasChanged(value, computed2._value)) {
computed2._value = value;
dep.version++;
}
} catch (err) {
dep.version++;
throw err;
} finally {
activeSub = prevSub;
shouldTrack = prevShouldTrack;
cleanupDeps(computed2);
computed2.flags &= ~2;
}
}
function removeSub(link, soft = false) {
const { dep, prevSub, nextSub } = link;
if (prevSub) {
prevSub.nextSub = nextSub;
link.prevSub = void 0;
}
if (nextSub) {
nextSub.prevSub = prevSub;
link.nextSub = void 0;
}
if (dep.subs === link) {
dep.subs = prevSub;
if (!prevSub && dep.computed) {
dep.computed.flags &= ~4;
for (let l2 = dep.computed.deps; l2; l2 = l2.nextDep) {
removeSub(l2, true);
}
}
}
if (!soft && !--dep.sc && dep.map) {
dep.map.delete(dep.key);
}
}
function removeDep(link) {
const { prevDep, nextDep } = link;
if (prevDep) {
prevDep.nextDep = nextDep;
link.prevDep = void 0;
}
if (nextDep) {
nextDep.prevDep = prevDep;
link.nextDep = void 0;
}
}
let shouldTrack = true;
const trackStack = [];
function pauseTracking() {
trackStack.push(shouldTrack);
shouldTrack = false;
}
function resetTracking() {
const last = trackStack.pop();
shouldTrack = last === void 0 ? true : last;
}
function cleanupEffect(e2) {
const { cleanup } = e2;
e2.cleanup = void 0;
if (cleanup) {
const prevSub = activeSub;
activeSub = void 0;
try {
cleanup();
} finally {
activeSub = prevSub;
}
}
}
let globalVersion = 0;
class Link {
constructor(sub, dep) {
this.sub = sub;
this.dep = dep;
this.version = dep.version;
this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
}
}
class Dep {
constructor(computed2) {
this.computed = computed2;
this.version = 0;
this.activeLink = void 0;
this.subs = void 0;
this.map = void 0;
this.key = void 0;
this.sc = 0;
}
track(debugInfo) {
if (!activeSub || !shouldTrack || activeSub === this.computed) {
return;
}
let link = this.activeLink;
if (link === void 0 || link.sub !== activeSub) {
link = this.activeLink = new Link(activeSub, this);
if (!activeSub.deps) {
activeSub.deps = activeSub.depsTail = link;
} else {
link.prevDep = activeSub.depsTail;
activeSub.depsTail.nextDep = link;
activeSub.depsTail = link;
}
addSub(link);
} else if (link.version === -1) {
link.version = this.version;
if (link.nextDep) {
const next = link.nextDep;
next.prevDep = link.prevDep;
if (link.prevDep) {
link.prevDep.nextDep = next;
}
link.prevDep = activeSub.depsTail;
link.nextDep = void 0;
activeSub.depsTail.nextDep = link;
activeSub.depsTail = link;
if (activeSub.deps === link) {
activeSub.deps = next;
}
}
}
return link;
}
trigger(debugInfo) {
this.version++;
globalVersion++;
this.notify(debugInfo);
}
notify(debugInfo) {
startBatch();
try {
if (false) ;
for (let link = this.subs; link; link = link.prevSub) {
if (link.sub.notify()) {
;
link.sub.dep.notify();
}
}
} finally {
endBatch();
}
}
}
function addSub(link) {
link.dep.sc++;
if (link.sub.flags & 4) {
const computed2 = link.dep.computed;
if (computed2 && !link.dep.subs) {
computed2.flags |= 4 | 16;
for (let l2 = computed2.deps; l2; l2 = l2.nextDep) {
addSub(l2);
}
}
const currentTail = link.dep.subs;
if (currentTail !== link) {
link.prevSub = currentTail;
if (currentTail) currentTail.nextSub = link;
}
link.dep.subs = link;
}
}
const targetMap = /* @__PURE__ */ new WeakMap();
const ITERATE_KEY = Symbol(
""
);
const MAP_KEY_ITERATE_KEY = Symbol(
""
);
const ARRAY_ITERATE_KEY = Symbol(
""
);
function track(target, type2, key2) {
if (shouldTrack && activeSub) {
let depsMap = targetMap.get(target);
if (!depsMap) {
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
}
let dep = depsMap.get(key2);
if (!dep) {
depsMap.set(key2, dep = new Dep());
dep.map = depsMap;
dep.key = key2;
}
{
dep.track();
}
}
}
function trigger(target, type2, key2, newValue, oldValue, oldTarget) {
const depsMap = targetMap.get(target);
if (!depsMap) {
globalVersion++;
return;
}
const run = (dep) => {
if (dep) {
{
dep.trigger();
}
}
};
startBatch();
if (type2 === "clear") {
depsMap.forEach(run);
} else {
const targetIsArray = isArray$3(target);
const isArrayIndex = targetIsArray && isIntegerKey(key2);
if (targetIsArray && key2 === "length") {
const newLength = Number(newValue);
depsMap.forEach((dep, key22) => {
if (key22 === "length" || key22 === ARRAY_ITERATE_KEY || !isSymbol(key22) && key22 >= newLength) {
run(dep);
}
});
} else {
if (key2 !== void 0 || depsMap.has(void 0)) {
run(depsMap.get(key2));
}
if (isArrayIndex) {
run(depsMap.get(ARRAY_ITERATE_KEY));
}
switch (type2) {
case "add":
if (!targetIsArray) {
run(depsMap.get(ITERATE_KEY));
if (isMap$1(target)) {
run(depsMap.get(MAP_KEY_ITERATE_KEY));
}
} else if (isArrayIndex) {
run(depsMap.get("length"));
}
break;
case "delete":
if (!targetIsArray) {
run(depsMap.get(ITERATE_KEY));
if (isMap$1(target)) {
run(depsMap.get(MAP_KEY_ITERATE_KEY));
}
}
break;
case "set":
if (isMap$1(target)) {
run(depsMap.get(ITERATE_KEY));
}
break;
}
}
}
endBatch();
}
function getDepFromReactive(object2, key2) {
const depMap = targetMap.get(object2);
return depMap && depMap.get(key2);
}
function reactiveReadArray(array) {
const raw2 = toRaw(array);
if (raw2 === array) return raw2;
track(raw2, "iterate", ARRAY_ITERATE_KEY);
return isShallow(array) ? raw2 : raw2.map(toReactive);
}
function shallowReadArray(arr) {
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
return arr;
}
const arrayInstrumentations = {
__proto__: null,
[Symbol.iterator]() {
return iterator(this, Symbol.iterator, toReactive);
},
concat(...args) {
return reactiveReadArray(this).concat(
...args.map((x2) => isArray$3(x2) ? reactiveReadArray(x2) : x2)
);
},
entries() {
return iterator(this, "entries", (value) => {
value[1] = toReactive(value[1]);
return value;
});
},
every(fn, thisArg) {
return apply(this, "every", fn, thisArg, void 0, arguments);
},
filter(fn, thisArg) {
return apply(this, "filter", fn, thisArg, (v2) => v2.map(toReactive), arguments);
},
find(fn, thisArg) {
return apply(this, "find", fn, thisArg, toReactive, arguments);
},
findIndex(fn, thisArg) {
return apply(this, "findIndex", fn, thisArg, void 0, arguments);
},
findLast(fn, thisArg) {
return apply(this, "findLast", fn, thisArg, toReactive, arguments);
},
findLastIndex(fn, thisArg) {
return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
},
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
forEach(fn, thisArg) {
return apply(this, "forEach", fn, thisArg, void 0, arguments);
},
includes(...args) {
return searchProxy(this, "includes", args);
},
indexOf(...args) {
return searchProxy(this, "indexOf", args);
},
join(separator) {
return reactiveReadArray(this).join(separator);
},
// keys() iterator only reads `length`, no optimisation required
lastIndexOf(...args) {
return searchProxy(this, "lastIndexOf", args);
},
map(fn, thisArg) {
return apply(this, "map", fn, thisArg, void 0, arguments);
},
pop() {
return noTracking(this, "pop");
},
push(...args) {
return noTracking(this, "push", args);
},
reduce(fn, ...args) {
return reduce(this, "reduce", fn, args);
},
reduceRight(fn, ...args) {
return reduce(this, "reduceRight", fn, args);
},
shift() {
return noTracking(this, "shift");
},
// slice could use ARRAY_ITERATE but also seems to beg for range tracking
some(fn, thisArg) {
return apply(this, "some", fn, thisArg, void 0, arguments);
},
splice(...args) {
return noTracking(this, "splice", args);
},
toReversed() {
return reactiveReadArray(this).toReversed();
},
toSorted(comparer) {
return reactiveReadArray(this).toSorted(comparer);
},
toSpliced(...args) {
return reactiveReadArray(this).toSpliced(...args);
},
unshift(...args) {
return noTracking(this, "unshift", args);
},
values() {
return iterator(this, "values", toReactive);
}
};
function iterator(self2, method, wrapValue) {
const arr = shallowReadArray(self2);
const iter = arr[method]();
if (arr !== self2 && !isShallow(self2)) {
iter._next = iter.next;
iter.next = () => {
const result = iter._next();
if (result.value) {
result.value = wrapValue(result.value);
}
return result;
};
}
return iter;
}
const arrayProto = Array.prototype;
function apply(self2, method, fn, thisArg, wrappedRetFn, args) {
const arr = shallowReadArray(self2);
const needsWrap = arr !== self2 && !isShallow(self2);
const methodFn = arr[method];
if (methodFn !== arrayProto[method]) {
const result2 = methodFn.apply(self2, args);
return needsWrap ? toReactive(result2) : result2;
}
let wrappedFn = fn;
if (arr !== self2) {
if (needsWrap) {
wrappedFn = function(item, index2) {
return fn.call(this, toReactive(item), index2, self2);
};
} else if (fn.length > 2) {
wrappedFn = function(item, index2) {
return fn.call(this, item, index2, self2);
};
}
}
const result = methodFn.call(arr, wrappedFn, thisArg);
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
}
function reduce(self2, method, fn, args) {
const arr = shallowReadArray(self2);
let wrappedFn = fn;
if (arr !== self2) {
if (!isShallow(self2)) {
wrappedFn = function(acc, item, index2) {
return fn.call(this, acc, toReactive(item), index2, self2);
};
} else if (fn.length > 3) {
wrappedFn = function(acc, item, index2) {
return fn.call(this, acc, item, index2, self2);
};
}
}
return arr[method](wrappedFn, ...args);
}
function searchProxy(self2, method, args) {
const arr = toRaw(self2);
track(arr, "iterate", ARRAY_ITERATE_KEY);
const res = arr[method](...args);
if ((res === -1 || res === false) && isProxy(args[0])) {
args[0] = toRaw(args[0]);
return arr[method](...args);
}
return res;
}
function noTracking(self2, method, args = []) {
pauseTracking();
startBatch();
const res = toRaw(self2)[method].apply(self2, args);
endBatch();
resetTracking();
return res;
}
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key2) => key2 !== "arguments" && key2 !== "caller").map((key2) => Symbol[key2]).filter(isSymbol)
);
function hasOwnProperty(key2) {
if (!isSymbol(key2)) key2 = String(key2);
const obj = toRaw(this);
track(obj, "has", key2);
return obj.hasOwnProperty(key2);
}
class BaseReactiveHandler {
constructor(_isReadonly = false, _isShallow = false) {
this._isReadonly = _isReadonly;
this._isShallow = _isShallow;
}
get(target, key2, receiver) {
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
if (key2 === "__v_isReactive") {
return !isReadonly2;
} else if (key2 === "__v_isReadonly") {
return isReadonly2;
} else if (key2 === "__v_isShallow") {
return isShallow2;
} else if (key2 === "__v_raw") {
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
// this means the receiver is a user proxy of the reactive proxy
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
return target;
}
return;
}
const targetIsArray = isArray$3(target);
if (!isReadonly2) {
let fn;
if (targetIsArray && (fn = arrayInstrumentations[key2])) {
return fn;
}
if (key2 === "hasOwnProperty") {
return hasOwnProperty;
}
}
const res = Reflect.get(
target,
key2,
// if this is a proxy wrapping a ref, return methods using the raw ref
// as receiver so that we don't have to call `toRaw` on the ref in all
// its class methods
isRef(target) ? target : receiver
);
if (isSymbol(key2) ? builtInSymbols.has(key2) : isNonTrackableKeys(key2)) {
return res;
}
if (!isReadonly2) {
track(target, "get", key2);
}
if (isShallow2) {
return res;
}
if (isRef(res)) {
return targetIsArray && isIntegerKey(key2) ? res : res.value;
}
if (isObject$2(res)) {
return isReadonly2 ? readonly(res) : reactive(res);
}
return res;
}
}
class MutableReactiveHandler extends BaseReactiveHandler {
constructor(isShallow2 = false) {
super(false, isShallow2);
}
set(target, key2, value, receiver) {
let oldValue = target[key2];
if (!this._isShallow) {
const isOldValueReadonly = isReadonly(oldValue);
if (!isShallow(value) && !isReadonly(value)) {
oldValue = toRaw(oldValue);
value = toRaw(value);
}
if (!isArray$3(target) && isRef(oldValue) && !isRef(value)) {
if (isOldValueReadonly) {
return false;
} else {
oldValue.value = value;
return true;
}
}
}
const hadKey = isArray$3(target) && isIntegerKey(key2) ? Number(key2) < target.length : hasOwn$2(target, key2);
const result = Reflect.set(
target,
key2,
value,
isRef(target) ? target : receiver
);
if (target === toRaw(receiver)) {
if (!hadKey) {
trigger(target, "add", key2, value);
} else if (hasChanged(value, oldValue)) {
trigger(target, "set", key2, value);
}
}
return result;
}
deleteProperty(target, key2) {
const hadKey = hasOwn$2(target, key2);
target[key2];
const result = Reflect.deleteProperty(target, key2);
if (result && hadKey) {
trigger(target, "delete", key2, void 0);
}
return result;
}
has(target, key2) {
const result = Reflect.has(target, key2);
if (!isSymbol(key2) || !builtInSymbols.has(key2)) {
track(target, "has", key2);
}
return result;
}
ownKeys(target) {
track(
target,
"iterate",
isArray$3(target) ? "length" : ITERATE_KEY
);
return Reflect.ownKeys(target);
}
}
class ReadonlyReactiveHandler extends BaseReactiveHandler {
constructor(isShallow2 = false) {
super(true, isShallow2);
}
set(target, key2) {
return true;
}
deleteProperty(target, key2) {
return true;
}
}
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
const toShallow = (value) => value;
const getProto = (v2) => Reflect.getPrototypeOf(v2);
function createIterableMethod(method, isReadonly2, isShallow2) {
return function(...args) {
const target = this["__v_raw"];
const rawTarget = toRaw(target);
const targetIsMap = isMap$1(rawTarget);
const isPair2 = method === "entries" || method === Symbol.iterator && targetIsMap;
const isKeyOnly = method === "keys" && targetIsMap;
const innerIterator = target[method](...args);
const wrap2 = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
!isReadonly2 && track(
rawTarget,
"iterate",
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
);
return {
// iterator protocol
next() {
const { value, done } = innerIterator.next();
return done ? { value, done } : {
value: isPair2 ? [wrap2(value[0]), wrap2(value[1])] : wrap2(value),
done
};
},
// iterable protocol
[Symbol.iterator]() {
return this;
}
};
};
}
function createReadonlyMethod(type2) {
return function(...args) {
return type2 === "delete" ? false : type2 === "clear" ? void 0 : this;
};
}
function createInstrumentations(readonly2, shallow) {
const instrumentations = {
get(key2) {
const target = this["__v_raw"];
const rawTarget = toRaw(target);
const rawKey = toRaw(key2);
if (!readonly2) {
if (hasChanged(key2, rawKey)) {
track(rawTarget, "get", key2);
}
track(rawTarget, "get", rawKey);
}
const { has } = getProto(rawTarget);
const wrap2 = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
if (has.call(rawTarget, key2)) {
return wrap2(target.get(key2));
} else if (has.call(rawTarget, rawKey)) {
return wrap2(target.get(rawKey));
} else if (target !== rawTarget) {
target.get(key2);
}
},
get size() {
const target = this["__v_raw"];
!readonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
return Reflect.get(target, "size", target);
},
has(key2) {
const target = this["__v_raw"];
const rawTarget = toRaw(target);
const rawKey = toRaw(key2);
if (!readonly2) {
if (hasChanged(key2, rawKey)) {
track(rawTarget, "has", key2);
}
track(rawTarget, "has", rawKey);
}
return key2 === rawKey ? target.has(key2) : target.has(key2) || target.has(rawKey);
},
forEach(callback, thisArg) {
const observed = this;
const target = observed["__v_raw"];
const rawTarget = toRaw(target);
const wrap2 = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
!readonly2 && track(rawTarget, "iterate", ITERATE_KEY);
return target.forEach((value, key2) => {
return callback.call(thisArg, wrap2(value), wrap2(key2), observed);
});
}
};
extend$3(
instrumentations,
readonly2 ? {
add: createReadonlyMethod("add"),
set: createReadonlyMethod("set"),
delete: createReadonlyMethod("delete"),
clear: createReadonlyMethod("clear")
} : {
add(value) {
if (!shallow && !isShallow(value) && !isReadonly(value)) {
value = toRaw(value);
}
const target = toRaw(this);
const proto2 = getProto(target);
const hadKey = proto2.has.call(target, value);
if (!hadKey) {
target.add(value);
trigger(target, "add", value, value);
}
return this;
},
set(key2, value) {
if (!shallow && !isShallow(value) && !isReadonly(value)) {
value = toRaw(value);
}
const target = toRaw(this);
const { has, get: get2 } = getProto(target);
let hadKey = has.call(target, key2);
if (!hadKey) {
key2 = toRaw(key2);
hadKey = has.call(target, key2);
}
const oldValue = get2.call(target, key2);
target.set(key2, value);
if (!hadKey) {
trigger(target, "add", key2, value);
} else if (hasChanged(value, oldValue)) {
trigger(target, "set", key2, value);
}
return this;
},
delete(key2) {
const target = toRaw(this);
const { has, get: get2 } = getProto(target);
let hadKey = has.call(target, key2);
if (!hadKey) {
key2 = toRaw(key2);
hadKey = has.call(target, key2);
}
get2 ? get2.call(target, key2) : void 0;
const result = target.delete(key2);
if (hadKey) {
trigger(target, "delete", key2, void 0);
}
return result;
},
clear() {
const target = toRaw(this);
const hadItems = target.size !== 0;
const result = target.clear();
if (hadItems) {
trigger(
target,
"clear",
void 0,
void 0
);
}
return result;
}
}
);
const iteratorMethods = [
"keys",
"values",
"entries",
Symbol.iterator
];
iteratorMethods.forEach((method) => {
instrumentations[method] = createIterableMethod(method, readonly2, shallow);
});
return instrumentations;
}
function createInstrumentationGetter(isReadonly2, shallow) {
const instrumentations = createInstrumentations(isReadonly2, shallow);
return (target, key2, receiver) => {
if (key2 === "__v_isReactive") {
return !isReadonly2;
} else if (key2 === "__v_isReadonly") {
return isReadonly2;
} else if (key2 === "__v_raw") {
return target;
}
return Reflect.get(
hasOwn$2(instrumentations, key2) && key2 in target ? instrumentations : target,
key2,
receiver
);
};
}
const mutableCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
};
const shallowCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
};
const readonlyCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
};
const shallowReadonlyCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
};
const reactiveMap = /* @__PURE__ */ new WeakMap();
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
const readonlyMap = /* @__PURE__ */ new WeakMap();
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
function targetTypeMap(rawType) {
switch (rawType) {
case "Object":
case "Array":
return 1;
case "Map":
case "Set":
case "WeakMap":
case "WeakSet":
return 2;
default:
return 0;
}
}
function getTargetType(value) {
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
}
function reactive(target) {
if (isReadonly(target)) {
return target;
}
return createReactiveObject(
target,
false,
mutableHandlers,
mutableCollectionHandlers,
reactiveMap
);
}
function shallowReactive(target) {
return createReactiveObject(
target,
false,
shallowReactiveHandlers,
shallowCollectionHandlers,
shallowReactiveMap
);
}
function readonly(target) {
return createReactiveObject(
target,
true,
readonlyHandlers,
readonlyCollectionHandlers,
readonlyMap
);
}
function shallowReadonly(target) {
return createReactiveObject(
target,
true,
shallowReadonlyHandlers,
shallowReadonlyCollectionHandlers,
shallowReadonlyMap
);
}
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
if (!isObject$2(target)) {
return target;
}
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
return target;
}
const existingProxy = proxyMap.get(target);
if (existingProxy) {
return existingProxy;
}
const targetType = getTargetType(target);
if (targetType === 0) {
return target;
}
const proxy = new Proxy(
target,
targetType === 2 ? collectionHandlers : baseHandlers
);
proxyMap.set(target, proxy);
return proxy;
}
function isReactive(value) {
if (isReadonly(value)) {
return isReactive(value["__v_raw"]);
}
return !!(value && value["__v_isReactive"]);
}
function isReadonly(value) {
return !!(value && value["__v_isReadonly"]);
}
function isShallow(value) {
return !!(value && value["__v_isShallow"]);
}
function isProxy(value) {
return value ? !!value["__v_raw"] : false;
}
function toRaw(observed) {
const raw2 = observed && observed["__v_raw"];
return raw2 ? toRaw(raw2) : observed;
}
function markRaw(value) {
if (!hasOwn$2(value, "__v_skip") && Object.isExtensible(value)) {
def(value, "__v_skip", true);
}
return value;
}
const toReactive = (value) => isObject$2(value) ? reactive(value) : value;
const toReadonly = (value) => isObject$2(value) ? readonly(value) : value;
function isRef(r2) {
return r2 ? r2["__v_isRef"] === true : false;
}
function ref(value) {
return createRef(value, false);
}
function shallowRef(value) {
return createRef(value, true);
}
function createRef(rawValue, shallow) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
class RefImpl {
constructor(value, isShallow2) {
this.dep = new Dep();
this["__v_isRef"] = true;
this["__v_isShallow"] = false;
this._rawValue = isShallow2 ? value : toRaw(value);
this._value = isShallow2 ? value : toReactive(value);
this["__v_isShallow"] = isShallow2;
}
get value() {
{
this.dep.track();
}
return this._value;
}
set value(newValue) {
const oldValue = this._rawValue;
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
newValue = useDirectValue ? newValue : toRaw(newValue);
if (hasChanged(newValue, oldValue)) {
this._rawValue = newValue;
this._value = useDirectValue ? newValue : toReactive(newValue);
{
this.dep.trigger();
}
}
}
}
function unref(ref2) {
return isRef(ref2) ? ref2.value : ref2;
}
function toValue$3(source2) {
return isFunction(source2) ? source2() : unref(source2);
}
const shallowUnwrapHandlers = {
get: (target, key2, receiver) => key2 === "__v_raw" ? target : unref(Reflect.get(target, key2, receiver)),
set: (target, key2, value, receiver) => {
const oldValue = target[key2];
if (isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
} else {
return Reflect.set(target, key2, value, receiver);
}
}
};
function proxyRefs(objectWithRefs) {
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
}
class CustomRefImpl {
constructor(factory) {
this["__v_isRef"] = true;
this._value = void 0;
const dep = this.dep = new Dep();
const { get: get2, set: set2 } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
this._get = get2;
this._set = set2;
}
get value() {
return this._value = this._get();
}
set value(newVal) {
this._set(newVal);
}
}
function customRef(factory) {
return new CustomRefImpl(factory);
}
function toRefs(object2) {
const ret = isArray$3(object2) ? new Array(object2.length) : {};
for (const key2 in object2) {
ret[key2] = propertyToRef(object2, key2);
}
return ret;
}
class ObjectRefImpl {
constructor(_object, _key, _defaultValue) {
this._object = _object;
this._key = _key;
this._defaultValue = _defaultValue;
this["__v_isRef"] = true;
this._value = void 0;
}
get value() {
const val = this._object[this._key];
return this._value = val === void 0 ? this._defaultValue : val;
}
set value(newVal) {
this._object[this._key] = newVal;
}
get dep() {
return getDepFromReactive(toRaw(this._object), this._key);
}
}
class GetterRefImpl {
constructor(_getter) {
this._getter = _getter;
this["__v_isRef"] = true;
this["__v_isReadonly"] = true;
this._value = void 0;
}
get value() {
return this._value = this._getter();
}
}
function toRef(source2, key2, defaultValue) {
if (isRef(source2)) {
return source2;
} else if (isFunction(source2)) {
return new GetterRefImpl(source2);
} else if (isObject$2(source2) && arguments.length > 1) {
return propertyToRef(source2, key2, defaultValue);
} else {
return ref(source2);
}
}
function propertyToRef(source2, key2, defaultValue) {
const val = source2[key2];
return isRef(val) ? val : new ObjectRefImpl(source2, key2, defaultValue);
}
class ComputedRefImpl {
constructor(fn, setter, isSSR) {
this.fn = fn;
this.setter = setter;
this._value = void 0;
this.dep = new Dep(this);
this.__v_isRef = true;
this.deps = void 0;
this.depsTail = void 0;
this.flags = 16;
this.globalVersion = globalVersion - 1;
this.next = void 0;
this.effect = this;
this["__v_isReadonly"] = !setter;
this.isSSR = isSSR;
}
/**
* @internal
*/
notify() {
this.flags |= 16;
if (!(this.flags & 8) && // avoid infinite self recursion
activeSub !== this) {
batch(this, true);
return true;
}
}
get value() {
const link = this.dep.track();
refreshComputed(this);
if (link) {
link.version = this.dep.version;
}
return this._value;
}
set value(newValue) {
if (this.setter) {
this.setter(newValue);
}
}
}
function computed$1(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
if (isFunction(getterOrOptions)) {
getter = getterOrOptions;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, isSSR);
return cRef;
}
const INITIAL_WATCHER_VALUE = {};
const cleanupMap = /* @__PURE__ */ new WeakMap();
let activeWatcher = void 0;
function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
if (owner) {
let cleanups = cleanupMap.get(owner);
if (!cleanups) cleanupMap.set(owner, cleanups = []);
cleanups.push(cleanupFn);
}
}
function watch$1(source2, cb, options = EMPTY_OBJ) {
const { immediate, deep, once, scheduler, augmentJob, call } = options;
const reactiveGetter = (source22) => {
if (deep) return source22;
if (isShallow(source22) || deep === false || deep === 0)
return traverse$1(source22, 1);
return traverse$1(source22);
};
let effect2;
let getter;
let cleanup;
let boundCleanup;
let forceTrigger = false;
let isMultiSource = false;
if (isRef(source2)) {
getter = () => source2.value;
forceTrigger = isShallow(source2);
} else if (isReactive(source2)) {
getter = () => reactiveGetter(source2);
forceTrigger = true;
} else if (isArray$3(source2)) {
isMultiSource = true;
forceTrigger = source2.some((s3) => isReactive(s3) || isShallow(s3));
getter = () => source2.map((s3) => {
if (isRef(s3)) {
return s3.value;
} else if (isReactive(s3)) {
return reactiveGetter(s3);
} else if (isFunction(s3)) {
return call ? call(s3, 2) : s3();
} else ;
});
} else if (isFunction(source2)) {
if (cb) {
getter = call ? () => call(source2, 2) : source2;
} else {
getter = () => {
if (cleanup) {
pauseTracking();
try {
cleanup();
} finally {
resetTracking();
}
}
const currentEffect = activeWatcher;
activeWatcher = effect2;
try {
return call ? call(source2, 3, [boundCleanup]) : source2(boundCleanup);
} finally {
activeWatcher = currentEffect;
}
};
}
} else {
getter = NOOP;
}
if (cb && deep) {
const baseGetter = getter;
const depth = deep === true ? Infinity : deep;
getter = () => traverse$1(baseGetter(), depth);
}
const scope = getCurrentScope();
const watchHandle = () => {
effect2.stop();
if (scope) {
remove$1(scope.effects, effect2);
}
};
if (once && cb) {
const _cb = cb;
cb = (...args) => {
_cb(...args);
watchHandle();
};
}
let oldValue = isMultiSource ? new Array(source2.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
const job = (immediateFirstRun) => {
if (!(effect2.flags & 1) || !effect2.dirty && !immediateFirstRun) {
return;
}
if (cb) {
const newValue = effect2.run();
if (deep || forceTrigger || (isMultiSource ? newValue.some((v2, i2) => hasChanged(v2, oldValue[i2])) : hasChanged(newValue, oldValue))) {
if (cleanup) {
cleanup();
}
const currentWatcher = activeWatcher;
activeWatcher = effect2;
try {
const args = [
newValue,
// pass undefined as the old value when it's changed for the first time
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
boundCleanup
];
call ? call(cb, 3, args) : (
// @ts-expect-error
cb(...args)
);
oldValue = newValue;
} finally {
activeWatcher = currentWatcher;
}
}
} else {
effect2.run();
}
};
if (augmentJob) {
augmentJob(job);
}
effect2 = new ReactiveEffect(getter);
effect2.scheduler = scheduler ? () => scheduler(job, false) : job;
boundCleanup = (fn) => onWatcherCleanup(fn, false, effect2);
cleanup = effect2.onStop = () => {
const cleanups = cleanupMap.get(effect2);
if (cleanups) {
if (call) {
call(cleanups, 4);
} else {
for (const cleanup2 of cleanups) cleanup2();
}
cleanupMap.delete(effect2);
}
};
if (cb) {
if (immediate) {
job(true);
} else {
oldValue = effect2.run();
}
} else if (scheduler) {
scheduler(job.bind(null, true), true);
} else {
effect2.run();
}
watchHandle.pause = effect2.pause.bind(effect2);
watchHandle.resume = effect2.resume.bind(effect2);
watchHandle.stop = watchHandle;
return watchHandle;
}
function traverse$1(value, depth = Infinity, seen) {
if (depth <= 0 || !isObject$2(value) || value["__v_skip"]) {
return value;
}
seen = seen || /* @__PURE__ */ new Set();
if (seen.has(value)) {
return value;
}
seen.add(value);
depth--;
if (isRef(value)) {
traverse$1(value.value, depth, seen);
} else if (isArray$3(value)) {
for (let i2 = 0; i2 < value.length; i2++) {
traverse$1(value[i2], depth, seen);
}
} else if (isSet(value) || isMap$1(value)) {
value.forEach((v2) => {
traverse$1(v2, depth, seen);
});
} else if (isPlainObject$2(value)) {
for (const key2 in value) {
traverse$1(value[key2], depth, seen);
}
for (const key2 of Object.getOwnPropertySymbols(value)) {
if (Object.prototype.propertyIsEnumerable.call(value, key2)) {
traverse$1(value[key2], depth, seen);
}
}
}
return value;
}
/**
* @vue/runtime-core v3.5.12
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
const stack = [];
let isWarning = false;
function warn$1$1(msg, ...args) {
if (isWarning) return;
isWarning = true;
pauseTracking();
const instance = stack.length ? stack[stack.length - 1].component : null;
const appWarnHandler = instance && instance.appContext.config.warnHandler;
const trace = getComponentTrace();
if (appWarnHandler) {
callWithErrorHandling(
appWarnHandler,
instance,
11,
[
// eslint-disable-next-line no-restricted-syntax
msg + args.map((a2) => {
var _a2, _b;
return (_b = (_a2 = a2.toString) == null ? void 0 : _a2.call(a2)) != null ? _b : JSON.stringify(a2);
}).join(""),
instance && instance.proxy,
trace.map(
({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
).join("\n"),
trace
]
);
} else {
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
if (trace.length && // avoid spamming console during tests
true) {
warnArgs.push(`
`, ...formatTrace(trace));
}
console.warn(...warnArgs);
}
resetTracking();
isWarning = false;
}
function getComponentTrace() {
let currentVNode = stack[stack.length - 1];
if (!currentVNode) {
return [];
}
const normalizedStack = [];
while (currentVNode) {
const last = normalizedStack[0];
if (last && last.vnode === currentVNode) {
last.recurseCount++;
} else {
normalizedStack.push({
vnode: currentVNode,
recurseCount: 0
});
}
const parentInstance = currentVNode.component && currentVNode.component.parent;
currentVNode = parentInstance && parentInstance.vnode;
}
return normalizedStack;
}
function formatTrace(trace) {
const logs = [];
trace.forEach((entry, i2) => {
logs.push(...i2 === 0 ? [] : [`
`], ...formatTraceEntry(entry));
});
return logs;
}
function formatTraceEntry({ vnode, recurseCount }) {
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
const isRoot = vnode.component ? vnode.component.parent == null : false;
const open = ` at <${formatComponentName(
vnode.component,
vnode.type,
isRoot
)}`;
const close = `>` + postfix;
return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
}
function formatProps(props) {
const res = [];
const keys2 = Object.keys(props);
keys2.slice(0, 3).forEach((key2) => {
res.push(...formatProp(key2, props[key2]));
});
if (keys2.length > 3) {
res.push(` ...`);
}
return res;
}
function formatProp(key2, value, raw2) {
if (isString$1(value)) {
value = JSON.stringify(value);
return raw2 ? value : [`${key2}=${value}`];
} else if (typeof value === "number" || typeof value === "boolean" || value == null) {
return raw2 ? value : [`${key2}=${value}`];
} else if (isRef(value)) {
value = formatProp(key2, toRaw(value.value), true);
return raw2 ? value : [`${key2}=Ref<`, value, `>`];
} else if (isFunction(value)) {
return [`${key2}=fn${value.name ? `<${value.name}>` : ``}`];
} else {
value = toRaw(value);
return raw2 ? value : [`${key2}=`, value];
}
}
function callWithErrorHandling(fn, instance, type2, args) {
try {
return args ? fn(...args) : fn();
} catch (err) {
handleError(err, instance, type2);
}
}
function callWithAsyncErrorHandling(fn, instance, type2, args) {
if (isFunction(fn)) {
const res = callWithErrorHandling(fn, instance, type2, args);
if (res && isPromise(res)) {
res.catch((err) => {
handleError(err, instance, type2);
});
}
return res;
}
if (isArray$3(fn)) {
const values2 = [];
for (let i2 = 0; i2 < fn.length; i2++) {
values2.push(callWithAsyncErrorHandling(fn[i2], instance, type2, args));
}
return values2;
}
}
function handleError(err, instance, type2, throwInDev = true) {
const contextVNode = instance ? instance.vnode : null;
const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || EMPTY_OBJ;
if (instance) {
let cur2 = instance.parent;
const exposedInstance = instance.proxy;
const errorInfo = `https://vuejs.org/error-reference/#runtime-${type2}`;
while (cur2) {
const errorCapturedHooks = cur2.ec;
if (errorCapturedHooks) {
for (let i2 = 0; i2 < errorCapturedHooks.length; i2++) {
if (errorCapturedHooks[i2](err, exposedInstance, errorInfo) === false) {
return;
}
}
}
cur2 = cur2.parent;
}
if (errorHandler) {
pauseTracking();
callWithErrorHandling(errorHandler, null, 10, [
err,
exposedInstance,
errorInfo
]);
resetTracking();
return;
}
}
logError(err, type2, contextVNode, throwInDev, throwUnhandledErrorInProduction);
}
function logError(err, type2, contextVNode, throwInDev = true, throwInProd = false) {
if (throwInProd) {
throw err;
} else {
console.error(err);
}
}
const queue = [];
let flushIndex = -1;
const pendingPostFlushCbs = [];
let activePostFlushCbs = null;
let postFlushIndex = 0;
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
let currentFlushPromise = null;
function nextTick(fn) {
const p2 = currentFlushPromise || resolvedPromise;
return fn ? p2.then(this ? fn.bind(this) : fn) : p2;
}
function findInsertionIndex$1(id2) {
let start = flushIndex + 1;
let end = queue.length;
while (start < end) {
const middle = start + end >>> 1;
const middleJob = queue[middle];
const middleJobId = getId(middleJob);
if (middleJobId < id2 || middleJobId === id2 && middleJob.flags & 2) {
start = middle + 1;
} else {
end = middle;
}
}
return start;
}
function queueJob(job) {
if (!(job.flags & 1)) {
const jobId = getId(job);
const lastJob = queue[queue.length - 1];
if (!lastJob || // fast path when the job id is larger than the tail
!(job.flags & 2) && jobId >= getId(lastJob)) {
queue.push(job);
} else {
queue.splice(findInsertionIndex$1(jobId), 0, job);
}
job.flags |= 1;
queueFlush();
}
}
function queueFlush() {
if (!currentFlushPromise) {
currentFlushPromise = resolvedPromise.then(flushJobs);
}
}
function queuePostFlushCb(cb) {
if (!isArray$3(cb)) {
if (activePostFlushCbs && cb.id === -1) {
activePostFlushCbs.splice(postFlushIndex + 1, 0, cb);
} else if (!(cb.flags & 1)) {
pendingPostFlushCbs.push(cb);
cb.flags |= 1;
}
} else {
pendingPostFlushCbs.push(...cb);
}
queueFlush();
}
function flushPreFlushCbs(instance, seen, i2 = flushIndex + 1) {
for (; i2 < queue.length; i2++) {
const cb = queue[i2];
if (cb && cb.flags & 2) {
if (instance && cb.id !== instance.uid) {
continue;
}
queue.splice(i2, 1);
i2--;
if (cb.flags & 4) {
cb.flags &= ~1;
}
cb();
if (!(cb.flags & 4)) {
cb.flags &= ~1;
}
}
}
}
function flushPostFlushCbs(seen) {
if (pendingPostFlushCbs.length) {
const deduped = [...new Set(pendingPostFlushCbs)].sort(
(a2, b2) => getId(a2) - getId(b2)
);
pendingPostFlushCbs.length = 0;
if (activePostFlushCbs) {
activePostFlushCbs.push(...deduped);
return;
}
activePostFlushCbs = deduped;
for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
const cb = activePostFlushCbs[postFlushIndex];
if (cb.flags & 4) {
cb.flags &= ~1;
}
if (!(cb.flags & 8)) cb();
cb.flags &= ~1;
}
activePostFlushCbs = null;
postFlushIndex = 0;
}
}
const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
function flushJobs(seen) {
try {
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
const job = queue[flushIndex];
if (job && !(job.flags & 8)) {
if (false) ;
if (job.flags & 4) {
job.flags &= ~1;
}
callWithErrorHandling(
job,
job.i,
job.i ? 15 : 14
);
if (!(job.flags & 4)) {
job.flags &= ~1;
}
}
}
} finally {
for (; flushIndex < queue.length; flushIndex++) {
const job = queue[flushIndex];
if (job) {
job.flags &= ~1;
}
}
flushIndex = -1;
queue.length = 0;
flushPostFlushCbs();
currentFlushPromise = null;
if (queue.length || pendingPostFlushCbs.length) {
flushJobs();
}
}
}
let currentRenderingInstance = null;
let currentScopeId = null;
function setCurrentRenderingInstance(instance) {
const prev = currentRenderingInstance;
currentRenderingInstance = instance;
currentScopeId = instance && instance.type.__scopeId || null;
return prev;
}
function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
if (!ctx) return fn;
if (fn._n) {
return fn;
}
const renderFnWithContext = (...args) => {
if (renderFnWithContext._d) {
setBlockTracking(-1);
}
const prevInstance = setCurrentRenderingInstance(ctx);
let res;
try {
res = fn(...args);
} finally {
setCurrentRenderingInstance(prevInstance);
if (renderFnWithContext._d) {
setBlockTracking(1);
}
}
return res;
};
renderFnWithContext._n = true;
renderFnWithContext._c = true;
renderFnWithContext._d = true;
return renderFnWithContext;
}
function withDirectives(vnode, directives) {
if (currentRenderingInstance === null) {
return vnode;
}
const instance = getComponentPublicInstance(currentRenderingInstance);
const bindings = vnode.dirs || (vnode.dirs = []);
for (let i2 = 0; i2 < directives.length; i2++) {
let [dir, value, arg, modifiers2 = EMPTY_OBJ] = directives[i2];
if (dir) {
if (isFunction(dir)) {
dir = {
mounted: dir,
updated: dir
};
}
if (dir.deep) {
traverse$1(value);
}
bindings.push({
dir,
instance,
value,
oldValue: void 0,
arg,
modifiers: modifiers2
});
}
}
return vnode;
}
function invokeDirectiveHook(vnode, prevVNode, instance, name2) {
const bindings = vnode.dirs;
const oldBindings = prevVNode && prevVNode.dirs;
for (let i2 = 0; i2 < bindings.length; i2++) {
const binding = bindings[i2];
if (oldBindings) {
binding.oldValue = oldBindings[i2].value;
}
let hook = binding.dir[name2];
if (hook) {
pauseTracking();
callWithAsyncErrorHandling(hook, instance, 8, [
vnode.el,
binding,
vnode,
prevVNode
]);
resetTracking();
}
}
}
const TeleportEndKey = Symbol("_vte");
const isTeleport = (type2) => type2.__isTeleport;
const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
const isTeleportDeferred = (props) => props && (props.defer || props.defer === "");
const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
const resolveTarget = (props, select) => {
const targetSelector = props && props.to;
if (isString$1(targetSelector)) {
if (!select) {
return null;
} else {
const target = select(targetSelector);
return target;
}
} else {
return targetSelector;
}
};
const TeleportImpl = {
name: "Teleport",
__isTeleport: true,
process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
const {
mc: mountChildren,
pc: patchChildren,
pbc: patchBlockChildren,
o: { insert: insert2, querySelector, createText, createComment }
} = internals;
const disabled = isTeleportDisabled(n2.props);
let { shapeFlag, children, dynamicChildren } = n2;
if (n1 == null) {
const placeholder2 = n2.el = createText("");
const mainAnchor = n2.anchor = createText("");
insert2(placeholder2, container, anchor);
insert2(mainAnchor, container, anchor);
const mount = (container2, anchor2) => {
if (shapeFlag & 16) {
if (parentComponent && parentComponent.isCE) {
parentComponent.ce._teleportTarget = container2;
}
mountChildren(
children,
container2,
anchor2,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
}
};
const mountToTarget = () => {
const target = n2.target = resolveTarget(n2.props, querySelector);
const targetAnchor = prepareAnchor(target, n2, createText, insert2);
if (target) {
if (namespace !== "svg" && isTargetSVG(target)) {
namespace = "svg";
} else if (namespace !== "mathml" && isTargetMathML(target)) {
namespace = "mathml";
}
if (!disabled) {
mount(target, targetAnchor);
updateCssVars(n2, false);
}
}
};
if (disabled) {
mount(container, mainAnchor);
updateCssVars(n2, true);
}
if (isTeleportDeferred(n2.props)) {
queuePostRenderEffect(mountToTarget, parentSuspense);
} else {
mountToTarget();
}
} else {
n2.el = n1.el;
n2.targetStart = n1.targetStart;
const mainAnchor = n2.anchor = n1.anchor;
const target = n2.target = n1.target;
const targetAnchor = n2.targetAnchor = n1.targetAnchor;
const wasDisabled = isTeleportDisabled(n1.props);
const currentContainer = wasDisabled ? container : target;
const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
if (namespace === "svg" || isTargetSVG(target)) {
namespace = "svg";
} else if (namespace === "mathml" || isTargetMathML(target)) {
namespace = "mathml";
}
if (dynamicChildren) {
patchBlockChildren(
n1.dynamicChildren,
dynamicChildren,
currentContainer,
parentComponent,
parentSuspense,
namespace,
slotScopeIds
);
traverseStaticChildren(n1, n2, true);
} else if (!optimized) {
patchChildren(
n1,
n2,
currentContainer,
currentAnchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
false
);
}
if (disabled) {
if (!wasDisabled) {
moveTeleport(
n2,
container,
mainAnchor,
internals,
1
);
} else {
if (n2.props && n1.props && n2.props.to !== n1.props.to) {
n2.props.to = n1.props.to;
}
}
} else {
if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
const nextTarget = n2.target = resolveTarget(
n2.props,
querySelector
);
if (nextTarget) {
moveTeleport(
n2,
nextTarget,
null,
internals,
0
);
}
} else if (wasDisabled) {
moveTeleport(
n2,
target,
targetAnchor,
internals,
1
);
}
}
updateCssVars(n2, disabled);
}
},
remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) {
const {
shapeFlag,
children,
anchor,
targetStart,
targetAnchor,
target,
props
} = vnode;
if (target) {
hostRemove(targetStart);
hostRemove(targetAnchor);
}
doRemove && hostRemove(anchor);
if (shapeFlag & 16) {
const shouldRemove = doRemove || !isTeleportDisabled(props);
for (let i2 = 0; i2 < children.length; i2++) {
const child = children[i2];
unmount(
child,
parentComponent,
parentSuspense,
shouldRemove,
!!child.dynamicChildren
);
}
}
},
move: moveTeleport,
hydrate: hydrateTeleport
};
function moveTeleport(vnode, container, parentAnchor, { o: { insert: insert2 }, m: move }, moveType = 2) {
if (moveType === 0) {
insert2(vnode.targetAnchor, container, parentAnchor);
}
const { el, anchor, shapeFlag, children, props } = vnode;
const isReorder = moveType === 2;
if (isReorder) {
insert2(el, container, parentAnchor);
}
if (!isReorder || isTeleportDisabled(props)) {
if (shapeFlag & 16) {
for (let i2 = 0; i2 < children.length; i2++) {
move(
children[i2],
container,
parentAnchor,
2
);
}
}
}
if (isReorder) {
insert2(anchor, container, parentAnchor);
}
}
function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
o: { nextSibling, parentNode, querySelector, insert: insert2, createText }
}, hydrateChildren) {
const target = vnode.target = resolveTarget(
vnode.props,
querySelector
);
if (target) {
const disabled = isTeleportDisabled(vnode.props);
const targetNode = target._lpa || target.firstChild;
if (vnode.shapeFlag & 16) {
if (disabled) {
vnode.anchor = hydrateChildren(
nextSibling(node),
vnode,
parentNode(node),
parentComponent,
parentSuspense,
slotScopeIds,
optimized
);
vnode.targetStart = targetNode;
vnode.targetAnchor = targetNode && nextSibling(targetNode);
} else {
vnode.anchor = nextSibling(node);
let targetAnchor = targetNode;
while (targetAnchor) {
if (targetAnchor && targetAnchor.nodeType === 8) {
if (targetAnchor.data === "teleport start anchor") {
vnode.targetStart = targetAnchor;
} else if (targetAnchor.data === "teleport anchor") {
vnode.targetAnchor = targetAnchor;
target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
break;
}
}
targetAnchor = nextSibling(targetAnchor);
}
if (!vnode.targetAnchor) {
prepareAnchor(target, vnode, createText, insert2);
}
hydrateChildren(
targetNode && nextSibling(targetNode),
vnode,
target,
parentComponent,
parentSuspense,
slotScopeIds,
optimized
);
}
}
updateCssVars(vnode, disabled);
}
return vnode.anchor && nextSibling(vnode.anchor);
}
const Teleport = TeleportImpl;
function updateCssVars(vnode, isDisabled) {
const ctx = vnode.ctx;
if (ctx && ctx.ut) {
let node, anchor;
if (isDisabled) {
node = vnode.el;
anchor = vnode.anchor;
} else {
node = vnode.targetStart;
anchor = vnode.targetAnchor;
}
while (node && node !== anchor) {
if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid);
node = node.nextSibling;
}
ctx.ut();
}
}
function prepareAnchor(target, vnode, createText, insert2) {
const targetStart = vnode.targetStart = createText("");
const targetAnchor = vnode.targetAnchor = createText("");
targetStart[TeleportEndKey] = targetAnchor;
if (target) {
insert2(targetStart, target);
insert2(targetAnchor, target);
}
return targetAnchor;
}
const leaveCbKey = Symbol("_leaveCb");
const enterCbKey = Symbol("_enterCb");
function useTransitionState() {
const state = {
isMounted: false,
isLeaving: false,
isUnmounting: false,
leavingVNodes: /* @__PURE__ */ new Map()
};
onMounted(() => {
state.isMounted = true;
});
onBeforeUnmount(() => {
state.isUnmounting = true;
});
return state;
}
const TransitionHookValidator = [Function, Array];
const BaseTransitionPropsValidators = {
mode: String,
appear: Boolean,
persisted: Boolean,
// enter
onBeforeEnter: TransitionHookValidator,
onEnter: TransitionHookValidator,
onAfterEnter: TransitionHookValidator,
onEnterCancelled: TransitionHookValidator,
// leave
onBeforeLeave: TransitionHookValidator,
onLeave: TransitionHookValidator,
onAfterLeave: TransitionHookValidator,
onLeaveCancelled: TransitionHookValidator,
// appear
onBeforeAppear: TransitionHookValidator,
onAppear: TransitionHookValidator,
onAfterAppear: TransitionHookValidator,
onAppearCancelled: TransitionHookValidator
};
const recursiveGetSubtree = (instance) => {
const subTree = instance.subTree;
return subTree.component ? recursiveGetSubtree(subTree.component) : subTree;
};
const BaseTransitionImpl = {
name: `BaseTransition`,
props: BaseTransitionPropsValidators,
setup(props, { slots }) {
const instance = getCurrentInstance();
const state = useTransitionState();
return () => {
const children = slots.default && getTransitionRawChildren(slots.default(), true);
if (!children || !children.length) {
return;
}
const child = findNonCommentChild(children);
const rawProps = toRaw(props);
const { mode } = rawProps;
if (state.isLeaving) {
return emptyPlaceholder(child);
}
const innerChild = getInnerChild$1(child);
if (!innerChild) {
return emptyPlaceholder(child);
}
let enterHooks = resolveTransitionHooks(
innerChild,
rawProps,
state,
instance,
// #11061, ensure enterHooks is fresh after clone
(hooks) => enterHooks = hooks
);
if (innerChild.type !== Comment) {
setTransitionHooks(innerChild, enterHooks);
}
const oldChild = instance.subTree;
const oldInnerChild = oldChild && getInnerChild$1(oldChild);
if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild) && recursiveGetSubtree(instance).type !== Comment) {
const leavingHooks = resolveTransitionHooks(
oldInnerChild,
rawProps,
state,
instance
);
setTransitionHooks(oldInnerChild, leavingHooks);
if (mode === "out-in" && innerChild.type !== Comment) {
state.isLeaving = true;
leavingHooks.afterLeave = () => {
state.isLeaving = false;
if (!(instance.job.flags & 8)) {
instance.update();
}
delete leavingHooks.afterLeave;
};
return emptyPlaceholder(child);
} else if (mode === "in-out" && innerChild.type !== Comment) {
leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
const leavingVNodesCache = getLeavingNodesForType(
state,
oldInnerChild
);
leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
el[leaveCbKey] = () => {
earlyRemove();
el[leaveCbKey] = void 0;
delete enterHooks.delayedLeave;
};
enterHooks.delayedLeave = delayedLeave;
};
}
}
return child;
};
}
};
function findNonCommentChild(children) {
let child = children[0];
if (children.length > 1) {
for (const c2 of children) {
if (c2.type !== Comment) {
child = c2;
break;
}
}
}
return child;
}
const BaseTransition = BaseTransitionImpl;
function getLeavingNodesForType(state, vnode) {
const { leavingVNodes } = state;
let leavingVNodesCache = leavingVNodes.get(vnode.type);
if (!leavingVNodesCache) {
leavingVNodesCache = /* @__PURE__ */ Object.create(null);
leavingVNodes.set(vnode.type, leavingVNodesCache);
}
return leavingVNodesCache;
}
function resolveTransitionHooks(vnode, props, state, instance, postClone) {
const {
appear,
mode,
persisted = false,
onBeforeEnter,
onEnter,
onAfterEnter,
onEnterCancelled,
onBeforeLeave,
onLeave,
onAfterLeave,
onLeaveCancelled,
onBeforeAppear,
onAppear,
onAfterAppear,
onAppearCancelled
} = props;
const key2 = String(vnode.key);
const leavingVNodesCache = getLeavingNodesForType(state, vnode);
const callHook2 = (hook, args) => {
hook && callWithAsyncErrorHandling(
hook,
instance,
9,
args
);
};
const callAsyncHook = (hook, args) => {
const done = args[1];
callHook2(hook, args);
if (isArray$3(hook)) {
if (hook.every((hook2) => hook2.length <= 1)) done();
} else if (hook.length <= 1) {
done();
}
};
const hooks = {
mode,
persisted,
beforeEnter(el) {
let hook = onBeforeEnter;
if (!state.isMounted) {
if (appear) {
hook = onBeforeAppear || onBeforeEnter;
} else {
return;
}
}
if (el[leaveCbKey]) {
el[leaveCbKey](
true
/* cancelled */
);
}
const leavingVNode = leavingVNodesCache[key2];
if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
leavingVNode.el[leaveCbKey]();
}
callHook2(hook, [el]);
},
enter(el) {
let hook = onEnter;
let afterHook = onAfterEnter;
let cancelHook = onEnterCancelled;
if (!state.isMounted) {
if (appear) {
hook = onAppear || onEnter;
afterHook = onAfterAppear || onAfterEnter;
cancelHook = onAppearCancelled || onEnterCancelled;
} else {
return;
}
}
let called = false;
const done = el[enterCbKey] = (cancelled) => {
if (called) return;
called = true;
if (cancelled) {
callHook2(cancelHook, [el]);
} else {
callHook2(afterHook, [el]);
}
if (hooks.delayedLeave) {
hooks.delayedLeave();
}
el[enterCbKey] = void 0;
};
if (hook) {
callAsyncHook(hook, [el, done]);
} else {
done();
}
},
leave(el, remove2) {
const key22 = String(vnode.key);
if (el[enterCbKey]) {
el[enterCbKey](
true
/* cancelled */
);
}
if (state.isUnmounting) {
return remove2();
}
callHook2(onBeforeLeave, [el]);
let called = false;
const done = el[leaveCbKey] = (cancelled) => {
if (called) return;
called = true;
remove2();
if (cancelled) {
callHook2(onLeaveCancelled, [el]);
} else {
callHook2(onAfterLeave, [el]);
}
el[leaveCbKey] = void 0;
if (leavingVNodesCache[key22] === vnode) {
delete leavingVNodesCache[key22];
}
};
leavingVNodesCache[key22] = vnode;
if (onLeave) {
callAsyncHook(onLeave, [el, done]);
} else {
done();
}
},
clone(vnode2) {
const hooks2 = resolveTransitionHooks(
vnode2,
props,
state,
instance,
postClone
);
if (postClone) postClone(hooks2);
return hooks2;
}
};
return hooks;
}
function emptyPlaceholder(vnode) {
if (isKeepAlive(vnode)) {
vnode = cloneVNode(vnode);
vnode.children = null;
return vnode;
}
}
function getInnerChild$1(vnode) {
if (!isKeepAlive(vnode)) {
if (isTeleport(vnode.type) && vnode.children) {
return findNonCommentChild(vnode.children);
}
return vnode;
}
const { shapeFlag, children } = vnode;
if (children) {
if (shapeFlag & 16) {
return children[0];
}
if (shapeFlag & 32 && isFunction(children.default)) {
return children.default();
}
}
}
function setTransitionHooks(vnode, hooks) {
if (vnode.shapeFlag & 6 && vnode.component) {
vnode.transition = hooks;
setTransitionHooks(vnode.component.subTree, hooks);
} else if (vnode.shapeFlag & 128) {
vnode.ssContent.transition = hooks.clone(vnode.ssContent);
vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
} else {
vnode.transition = hooks;
}
}
function getTransitionRawChildren(children, keepComment = false, parentKey) {
let ret = [];
let keyedFragmentCount = 0;
for (let i2 = 0; i2 < children.length; i2++) {
let child = children[i2];
const key2 = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i2);
if (child.type === Fragment) {
if (child.patchFlag & 128) keyedFragmentCount++;
ret = ret.concat(
getTransitionRawChildren(child.children, keepComment, key2)
);
} else if (keepComment || child.type !== Comment) {
ret.push(key2 != null ? cloneVNode(child, { key: key2 }) : child);
}
}
if (keyedFragmentCount > 1) {
for (let i2 = 0; i2 < ret.length; i2++) {
ret[i2].patchFlag = -2;
}
}
return ret;
}
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function defineComponent(options, extraOptions) {
return isFunction(options) ? (
// #8236: extend call and options.name access are considered side-effects
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
/* @__PURE__ */ (() => extend$3({ name: options.name }, extraOptions, { setup: options }))()
) : options;
}
function markAsyncBoundary(instance) {
instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
}
function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
if (isArray$3(rawRef)) {
rawRef.forEach(
(r2, i2) => setRef(
r2,
oldRawRef && (isArray$3(oldRawRef) ? oldRawRef[i2] : oldRawRef),
parentSuspense,
vnode,
isUnmount
)
);
return;
}
if (isAsyncWrapper(vnode) && !isUnmount) {
return;
}
const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
const value = isUnmount ? null : refValue;
const { i: owner, r: ref3 } = rawRef;
const oldRef = oldRawRef && oldRawRef.r;
const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
const setupState = owner.setupState;
const rawSetupState = toRaw(setupState);
const canSetSetupRef = setupState === EMPTY_OBJ ? () => false : (key2) => {
return hasOwn$2(rawSetupState, key2);
};
if (oldRef != null && oldRef !== ref3) {
if (isString$1(oldRef)) {
refs[oldRef] = null;
if (canSetSetupRef(oldRef)) {
setupState[oldRef] = null;
}
} else if (isRef(oldRef)) {
oldRef.value = null;
}
}
if (isFunction(ref3)) {
callWithErrorHandling(ref3, owner, 12, [value, refs]);
} else {
const _isString = isString$1(ref3);
const _isRef = isRef(ref3);
if (_isString || _isRef) {
const doSet = () => {
if (rawRef.f) {
const existing = _isString ? canSetSetupRef(ref3) ? setupState[ref3] : refs[ref3] : ref3.value;
if (isUnmount) {
isArray$3(existing) && remove$1(existing, refValue);
} else {
if (!isArray$3(existing)) {
if (_isString) {
refs[ref3] = [refValue];
if (canSetSetupRef(ref3)) {
setupState[ref3] = refs[ref3];
}
} else {
ref3.value = [refValue];
if (rawRef.k) refs[rawRef.k] = ref3.value;
}
} else if (!existing.includes(refValue)) {
existing.push(refValue);
}
}
} else if (_isString) {
refs[ref3] = value;
if (canSetSetupRef(ref3)) {
setupState[ref3] = value;
}
} else if (_isRef) {
ref3.value = value;
if (rawRef.k) refs[rawRef.k] = value;
} else ;
};
if (value) {
doSet.id = -1;
queuePostRenderEffect(doSet, parentSuspense);
} else {
doSet();
}
}
}
}
getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
getGlobalThis().cancelIdleCallback || ((id2) => clearTimeout(id2));
const isAsyncWrapper = (i2) => !!i2.type.__asyncLoader;
const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
function onActivated(hook, target) {
registerKeepAliveHook(hook, "a", target);
}
function onDeactivated(hook, target) {
registerKeepAliveHook(hook, "da", target);
}
function registerKeepAliveHook(hook, type2, target = currentInstance) {
const wrappedHook = hook.__wdc || (hook.__wdc = () => {
let current = target;
while (current) {
if (current.isDeactivated) {
return;
}
current = current.parent;
}
return hook();
});
injectHook(type2, wrappedHook, target);
if (target) {
let current = target.parent;
while (current && current.parent) {
if (isKeepAlive(current.parent.vnode)) {
injectToKeepAliveRoot(wrappedHook, type2, target, current);
}
current = current.parent;
}
}
}
function injectToKeepAliveRoot(hook, type2, target, keepAliveRoot) {
const injected = injectHook(
type2,
hook,
keepAliveRoot,
true
/* prepend */
);
onUnmounted(() => {
remove$1(keepAliveRoot[type2], injected);
}, target);
}
function injectHook(type2, hook, target = currentInstance, prepend = false) {
if (target) {
const hooks = target[type2] || (target[type2] = []);
const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
pauseTracking();
const reset = setCurrentInstance(target);
const res = callWithAsyncErrorHandling(hook, target, type2, args);
reset();
resetTracking();
return res;
});
if (prepend) {
hooks.unshift(wrappedHook);
} else {
hooks.push(wrappedHook);
}
return wrappedHook;
}
}
const createHook = (lifecycle) => (hook, target = currentInstance) => {
if (!isInSSRComponentSetup || lifecycle === "sp") {
injectHook(lifecycle, (...args) => hook(...args), target);
}
};
const onBeforeMount = createHook("bm");
const onMounted = createHook("m");
const onBeforeUpdate = createHook(
"bu"
);
const onUpdated = createHook("u");
const onBeforeUnmount = createHook(
"bum"
);
const onUnmounted = createHook("um");
const onServerPrefetch = createHook(
"sp"
);
const onRenderTriggered = createHook("rtg");
const onRenderTracked = createHook("rtc");
function onErrorCaptured(hook, target = currentInstance) {
injectHook("ec", hook, target);
}
const COMPONENTS = "components";
function resolveComponent(name2, maybeSelfReference) {
return resolveAsset(COMPONENTS, name2, true, maybeSelfReference) || name2;
}
const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
function resolveDynamicComponent(component) {
if (isString$1(component)) {
return resolveAsset(COMPONENTS, component, false) || component;
} else {
return component || NULL_DYNAMIC_COMPONENT;
}
}
function resolveAsset(type2, name2, warnMissing = true, maybeSelfReference = false) {
const instance = currentRenderingInstance || currentInstance;
if (instance) {
const Component = instance.type;
{
const selfName = getComponentName(
Component,
false
);
if (selfName && (selfName === name2 || selfName === camelize(name2) || selfName === capitalize$1(camelize(name2)))) {
return Component;
}
}
const res = (
// local registration
// check instance[type] first which is resolved for options API
resolve(instance[type2] || Component[type2], name2) || // global registration
resolve(instance.appContext[type2], name2)
);
if (!res && maybeSelfReference) {
return Component;
}
return res;
}
}
function resolve(registry, name2) {
return registry && (registry[name2] || registry[camelize(name2)] || registry[capitalize$1(camelize(name2))]);
}
function renderList(source2, renderItem, cache2, index2) {
let ret;
const cached = cache2;
const sourceIsArray = isArray$3(source2);
if (sourceIsArray || isString$1(source2)) {
const sourceIsReactiveArray = sourceIsArray && isReactive(source2);
let needsWrap = false;
if (sourceIsReactiveArray) {
needsWrap = !isShallow(source2);
source2 = shallowReadArray(source2);
}
ret = new Array(source2.length);
for (let i2 = 0, l2 = source2.length; i2 < l2; i2++) {
ret[i2] = renderItem(
needsWrap ? toReactive(source2[i2]) : source2[i2],
i2,
void 0,
cached
);
}
} else if (typeof source2 === "number") {
ret = new Array(source2);
for (let i2 = 0; i2 < source2; i2++) {
ret[i2] = renderItem(i2 + 1, i2, void 0, cached);
}
} else if (isObject$2(source2)) {
if (source2[Symbol.iterator]) {
ret = Array.from(
source2,
(item, i2) => renderItem(item, i2, void 0, cached)
);
} else {
const keys2 = Object.keys(source2);
ret = new Array(keys2.length);
for (let i2 = 0, l2 = keys2.length; i2 < l2; i2++) {
const key2 = keys2[i2];
ret[i2] = renderItem(source2[key2], key2, i2, cached);
}
}
} else {
ret = [];
}
return ret;
}
function createSlots(slots, dynamicSlots) {
for (let i2 = 0; i2 < dynamicSlots.length; i2++) {
const slot = dynamicSlots[i2];
if (isArray$3(slot)) {
for (let j2 = 0; j2 < slot.length; j2++) {
slots[slot[j2].name] = slot[j2].fn;
}
} else if (slot) {
slots[slot.name] = slot.key ? (...args) => {
const res = slot.fn(...args);
if (res) res.key = slot.key;
return res;
} : slot.fn;
}
}
return slots;
}
function renderSlot(slots, name2, props = {}, fallback, noSlotted) {
if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
if (name2 !== "default") props.name = name2;
return openBlock(), createBlock(
Fragment,
null,
[createVNode("slot", props, fallback && fallback())],
64
);
}
let slot = slots[name2];
if (slot && slot._c) {
slot._d = false;
}
openBlock();
const validSlotContent = slot && ensureValidVNode(slot(props));
const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
// key attached in the `createSlots` helper, respect that
validSlotContent && validSlotContent.key;
const rendered = createBlock(
Fragment,
{
key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name2}`) + // #7256 force differentiate fallback content from actual content
(!validSlotContent && fallback ? "_fb" : "")
},
validSlotContent || (fallback ? fallback() : []),
validSlotContent && slots._ === 1 ? 64 : -2
);
if (!noSlotted && rendered.scopeId) {
rendered.slotScopeIds = [rendered.scopeId + "-s"];
}
if (slot && slot._c) {
slot._d = true;
}
return rendered;
}
function ensureValidVNode(vnodes) {
return vnodes.some((child) => {
if (!isVNode(child)) return true;
if (child.type === Comment) return false;
if (child.type === Fragment && !ensureValidVNode(child.children))
return false;
return true;
}) ? vnodes : null;
}
function toHandlers(obj, preserveCaseIfNecessary) {
const ret = {};
for (const key2 in obj) {
ret[toHandlerKey(key2)] = obj[key2];
}
return ret;
}
const getPublicInstance = (i2) => {
if (!i2) return null;
if (isStatefulComponent(i2)) return getComponentPublicInstance(i2);
return getPublicInstance(i2.parent);
};
const publicPropertiesMap = (
// Move PURE marker to new line to workaround compiler discarding it
// due to type annotation
/* @__PURE__ */ extend$3(/* @__PURE__ */ Object.create(null), {
$: (i2) => i2,
$el: (i2) => i2.vnode.el,
$data: (i2) => i2.data,
$props: (i2) => i2.props,
$attrs: (i2) => i2.attrs,
$slots: (i2) => i2.slots,
$refs: (i2) => i2.refs,
$parent: (i2) => getPublicInstance(i2.parent),
$root: (i2) => getPublicInstance(i2.root),
$host: (i2) => i2.ce,
$emit: (i2) => i2.emit,
$options: (i2) => resolveMergedOptions(i2),
$forceUpdate: (i2) => i2.f || (i2.f = () => {
queueJob(i2.update);
}),
$nextTick: (i2) => i2.n || (i2.n = nextTick.bind(i2.proxy)),
$watch: (i2) => instanceWatch.bind(i2)
})
);
const hasSetupBinding = (state, key2) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn$2(state, key2);
const PublicInstanceProxyHandlers = {
get({ _: instance }, key2) {
if (key2 === "__v_skip") {
return true;
}
const { ctx, setupState, data, props, accessCache, type: type2, appContext } = instance;
let normalizedProps;
if (key2[0] !== "$") {
const n2 = accessCache[key2];
if (n2 !== void 0) {
switch (n2) {
case 1:
return setupState[key2];
case 2:
return data[key2];
case 4:
return ctx[key2];
case 3:
return props[key2];
}
} else if (hasSetupBinding(setupState, key2)) {
accessCache[key2] = 1;
return setupState[key2];
} else if (data !== EMPTY_OBJ && hasOwn$2(data, key2)) {
accessCache[key2] = 2;
return data[key2];
} else if (
// only cache other properties when instance has declared (thus stable)
// props
(normalizedProps = instance.propsOptions[0]) && hasOwn$2(normalizedProps, key2)
) {
accessCache[key2] = 3;
return props[key2];
} else if (ctx !== EMPTY_OBJ && hasOwn$2(ctx, key2)) {
accessCache[key2] = 4;
return ctx[key2];
} else if (shouldCacheAccess) {
accessCache[key2] = 0;
}
}
const publicGetter = publicPropertiesMap[key2];
let cssModule, globalProperties;
if (publicGetter) {
if (key2 === "$attrs") {
track(instance.attrs, "get", "");
}
return publicGetter(instance);
} else if (
// css module (injected by vue-loader)
(cssModule = type2.__cssModules) && (cssModule = cssModule[key2])
) {
return cssModule;
} else if (ctx !== EMPTY_OBJ && hasOwn$2(ctx, key2)) {
accessCache[key2] = 4;
return ctx[key2];
} else if (
// global properties
globalProperties = appContext.config.globalProperties, hasOwn$2(globalProperties, key2)
) {
{
return globalProperties[key2];
}
} else ;
},
set({ _: instance }, key2, value) {
const { data, setupState, ctx } = instance;
if (hasSetupBinding(setupState, key2)) {
setupState[key2] = value;
return true;
} else if (data !== EMPTY_OBJ && hasOwn$2(data, key2)) {
data[key2] = value;
return true;
} else if (hasOwn$2(instance.props, key2)) {
return false;
}
if (key2[0] === "$" && key2.slice(1) in instance) {
return false;
} else {
{
ctx[key2] = value;
}
}
return true;
},
has({
_: { data, setupState, accessCache, ctx, appContext, propsOptions }
}, key2) {
let normalizedProps;
return !!accessCache[key2] || data !== EMPTY_OBJ && hasOwn$2(data, key2) || hasSetupBinding(setupState, key2) || (normalizedProps = propsOptions[0]) && hasOwn$2(normalizedProps, key2) || hasOwn$2(ctx, key2) || hasOwn$2(publicPropertiesMap, key2) || hasOwn$2(appContext.config.globalProperties, key2);
},
defineProperty(target, key2, descriptor) {
if (descriptor.get != null) {
target._.accessCache[key2] = 0;
} else if (hasOwn$2(descriptor, "value")) {
this.set(target, key2, descriptor.value, null);
}
return Reflect.defineProperty(target, key2, descriptor);
}
};
function useSlots() {
return getContext().slots;
}
function useAttrs() {
return getContext().attrs;
}
function getContext() {
const i2 = getCurrentInstance();
return i2.setupContext || (i2.setupContext = createSetupContext(i2));
}
function normalizePropsOrEmits(props) {
return isArray$3(props) ? props.reduce(
(normalized, p2) => (normalized[p2] = null, normalized),
{}
) : props;
}
function mergeDefaults(raw2, defaults2) {
const props = normalizePropsOrEmits(raw2);
for (const key2 in defaults2) {
if (key2.startsWith("__skip")) continue;
let opt = props[key2];
if (opt) {
if (isArray$3(opt) || isFunction(opt)) {
opt = props[key2] = { type: opt, default: defaults2[key2] };
} else {
opt.default = defaults2[key2];
}
} else if (opt === null) {
opt = props[key2] = { default: defaults2[key2] };
} else ;
if (opt && defaults2[`__skip_${key2}`]) {
opt.skipFactory = true;
}
}
return props;
}
let shouldCacheAccess = true;
function applyOptions(instance) {
const options = resolveMergedOptions(instance);
const publicThis = instance.proxy;
const ctx = instance.ctx;
shouldCacheAccess = false;
if (options.beforeCreate) {
callHook$1(options.beforeCreate, instance, "bc");
}
const {
// state
data: dataOptions,
computed: computedOptions,
methods,
watch: watchOptions,
provide: provideOptions,
inject: injectOptions,
// lifecycle
created,
beforeMount,
mounted,
beforeUpdate,
updated,
activated,
deactivated,
beforeDestroy,
beforeUnmount,
destroyed,
unmounted,
render: render2,
renderTracked,
renderTriggered,
errorCaptured,
serverPrefetch,
// public API
expose,
inheritAttrs,
// assets
components,
directives,
filters
} = options;
const checkDuplicateProperties = null;
if (injectOptions) {
resolveInjections(injectOptions, ctx, checkDuplicateProperties);
}
if (methods) {
for (const key2 in methods) {
const methodHandler = methods[key2];
if (isFunction(methodHandler)) {
{
ctx[key2] = methodHandler.bind(publicThis);
}
}
}
}
if (dataOptions) {
const data = dataOptions.call(publicThis, publicThis);
if (!isObject$2(data)) ;
else {
instance.data = reactive(data);
}
}
shouldCacheAccess = true;
if (computedOptions) {
for (const key2 in computedOptions) {
const opt = computedOptions[key2];
const get2 = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
const set2 = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : NOOP;
const c2 = computed({
get: get2,
set: set2
});
Object.defineProperty(ctx, key2, {
enumerable: true,
configurable: true,
get: () => c2.value,
set: (v2) => c2.value = v2
});
}
}
if (watchOptions) {
for (const key2 in watchOptions) {
createWatcher(watchOptions[key2], ctx, publicThis, key2);
}
}
if (provideOptions) {
const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
Reflect.ownKeys(provides).forEach((key2) => {
provide(key2, provides[key2]);
});
}
if (created) {
callHook$1(created, instance, "c");
}
function registerLifecycleHook(register2, hook) {
if (isArray$3(hook)) {
hook.forEach((_hook) => register2(_hook.bind(publicThis)));
} else if (hook) {
register2(hook.bind(publicThis));
}
}
registerLifecycleHook(onBeforeMount, beforeMount);
registerLifecycleHook(onMounted, mounted);
registerLifecycleHook(onBeforeUpdate, beforeUpdate);
registerLifecycleHook(onUpdated, updated);
registerLifecycleHook(onActivated, activated);
registerLifecycleHook(onDeactivated, deactivated);
registerLifecycleHook(onErrorCaptured, errorCaptured);
registerLifecycleHook(onRenderTracked, renderTracked);
registerLifecycleHook(onRenderTriggered, renderTriggered);
registerLifecycleHook(onBeforeUnmount, beforeUnmount);
registerLifecycleHook(onUnmounted, unmounted);
registerLifecycleHook(onServerPrefetch, serverPrefetch);
if (isArray$3(expose)) {
if (expose.length) {
const exposed = instance.exposed || (instance.exposed = {});
expose.forEach((key2) => {
Object.defineProperty(exposed, key2, {
get: () => publicThis[key2],
set: (val) => publicThis[key2] = val
});
});
} else if (!instance.exposed) {
instance.exposed = {};
}
}
if (render2 && instance.render === NOOP) {
instance.render = render2;
}
if (inheritAttrs != null) {
instance.inheritAttrs = inheritAttrs;
}
if (components) instance.components = components;
if (directives) instance.directives = directives;
if (serverPrefetch) {
markAsyncBoundary(instance);
}
}
function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
if (isArray$3(injectOptions)) {
injectOptions = normalizeInject(injectOptions);
}
for (const key2 in injectOptions) {
const opt = injectOptions[key2];
let injected;
if (isObject$2(opt)) {
if ("default" in opt) {
injected = inject(
opt.from || key2,
opt.default,
true
);
} else {
injected = inject(opt.from || key2);
}
} else {
injected = inject(opt);
}
if (isRef(injected)) {
Object.defineProperty(ctx, key2, {
enumerable: true,
configurable: true,
get: () => injected.value,
set: (v2) => injected.value = v2
});
} else {
ctx[key2] = injected;
}
}
}
function callHook$1(hook, instance, type2) {
callWithAsyncErrorHandling(
isArray$3(hook) ? hook.map((h2) => h2.bind(instance.proxy)) : hook.bind(instance.proxy),
instance,
type2
);
}
function createWatcher(raw2, ctx, publicThis, key2) {
let getter = key2.includes(".") ? createPathGetter(publicThis, key2) : () => publicThis[key2];
if (isString$1(raw2)) {
const handler = ctx[raw2];
if (isFunction(handler)) {
{
watch(getter, handler);
}
}
} else if (isFunction(raw2)) {
{
watch(getter, raw2.bind(publicThis));
}
} else if (isObject$2(raw2)) {
if (isArray$3(raw2)) {
raw2.forEach((r2) => createWatcher(r2, ctx, publicThis, key2));
} else {
const handler = isFunction(raw2.handler) ? raw2.handler.bind(publicThis) : ctx[raw2.handler];
if (isFunction(handler)) {
watch(getter, handler, raw2);
}
}
} else ;
}
function resolveMergedOptions(instance) {
const base2 = instance.type;
const { mixins, extends: extendsOptions } = base2;
const {
mixins: globalMixins,
optionsCache: cache2,
config: { optionMergeStrategies }
} = instance.appContext;
const cached = cache2.get(base2);
let resolved;
if (cached) {
resolved = cached;
} else if (!globalMixins.length && !mixins && !extendsOptions) {
{
resolved = base2;
}
} else {
resolved = {};
if (globalMixins.length) {
globalMixins.forEach(
(m2) => mergeOptions$1(resolved, m2, optionMergeStrategies, true)
);
}
mergeOptions$1(resolved, base2, optionMergeStrategies);
}
if (isObject$2(base2)) {
cache2.set(base2, resolved);
}
return resolved;
}
function mergeOptions$1(to2, from, strats, asMixin = false) {
const { mixins, extends: extendsOptions } = from;
if (extendsOptions) {
mergeOptions$1(to2, extendsOptions, strats, true);
}
if (mixins) {
mixins.forEach(
(m2) => mergeOptions$1(to2, m2, strats, true)
);
}
for (const key2 in from) {
if (asMixin && key2 === "expose") ;
else {
const strat = internalOptionMergeStrats[key2] || strats && strats[key2];
to2[key2] = strat ? strat(to2[key2], from[key2]) : from[key2];
}
}
return to2;
}
const internalOptionMergeStrats = {
data: mergeDataFn,
props: mergeEmitsOrPropsOptions,
emits: mergeEmitsOrPropsOptions,
// objects
methods: mergeObjectOptions,
computed: mergeObjectOptions,
// lifecycle
beforeCreate: mergeAsArray,
created: mergeAsArray,
beforeMount: mergeAsArray,
mounted: mergeAsArray,
beforeUpdate: mergeAsArray,
updated: mergeAsArray,
beforeDestroy: mergeAsArray,
beforeUnmount: mergeAsArray,
destroyed: mergeAsArray,
unmounted: mergeAsArray,
activated: mergeAsArray,
deactivated: mergeAsArray,
errorCaptured: mergeAsArray,
serverPrefetch: mergeAsArray,
// assets
components: mergeObjectOptions,
directives: mergeObjectOptions,
// watch
watch: mergeWatchOptions,
// provide / inject
provide: mergeDataFn,
inject: mergeInject
};
function mergeDataFn(to2, from) {
if (!from) {
return to2;
}
if (!to2) {
return from;
}
return function mergedDataFn() {
return extend$3(
isFunction(to2) ? to2.call(this, this) : to2,
isFunction(from) ? from.call(this, this) : from
);
};
}
function mergeInject(to2, from) {
return mergeObjectOptions(normalizeInject(to2), normalizeInject(from));
}
function normalizeInject(raw2) {
if (isArray$3(raw2)) {
const res = {};
for (let i2 = 0; i2 < raw2.length; i2++) {
res[raw2[i2]] = raw2[i2];
}
return res;
}
return raw2;
}
function mergeAsArray(to2, from) {
return to2 ? [...new Set([].concat(to2, from))] : from;
}
function mergeObjectOptions(to2, from) {
return to2 ? extend$3(/* @__PURE__ */ Object.create(null), to2, from) : from;
}
function mergeEmitsOrPropsOptions(to2, from) {
if (to2) {
if (isArray$3(to2) && isArray$3(from)) {
return [.../* @__PURE__ */ new Set([...to2, ...from])];
}
return extend$3(
/* @__PURE__ */ Object.create(null),
normalizePropsOrEmits(to2),
normalizePropsOrEmits(from != null ? from : {})
);
} else {
return from;
}
}
function mergeWatchOptions(to2, from) {
if (!to2) return from;
if (!from) return to2;
const merged = extend$3(/* @__PURE__ */ Object.create(null), to2);
for (const key2 in from) {
merged[key2] = mergeAsArray(to2[key2], from[key2]);
}
return merged;
}
function createAppContext() {
return {
app: null,
config: {
isNativeTag: NO,
performance: false,
globalProperties: {},
optionMergeStrategies: {},
errorHandler: void 0,
warnHandler: void 0,
compilerOptions: {}
},
mixins: [],
components: {},
directives: {},
provides: /* @__PURE__ */ Object.create(null),
optionsCache: /* @__PURE__ */ new WeakMap(),
propsCache: /* @__PURE__ */ new WeakMap(),
emitsCache: /* @__PURE__ */ new WeakMap()
};
}
let uid$1 = 0;
function createAppAPI(render2, hydrate) {
return function createApp2(rootComponent, rootProps = null) {
if (!isFunction(rootComponent)) {
rootComponent = extend$3({}, rootComponent);
}
if (rootProps != null && !isObject$2(rootProps)) {
rootProps = null;
}
const context = createAppContext();
const installedPlugins = /* @__PURE__ */ new WeakSet();
const pluginCleanupFns = [];
let isMounted = false;
const app = context.app = {
_uid: uid$1++,
_component: rootComponent,
_props: rootProps,
_container: null,
_context: context,
_instance: null,
version: version$1,
get config() {
return context.config;
},
set config(v2) {
},
use(plugin, ...options) {
if (installedPlugins.has(plugin)) ;
else if (plugin && isFunction(plugin.install)) {
installedPlugins.add(plugin);
plugin.install(app, ...options);
} else if (isFunction(plugin)) {
installedPlugins.add(plugin);
plugin(app, ...options);
} else ;
return app;
},
mixin(mixin) {
{
if (!context.mixins.includes(mixin)) {
context.mixins.push(mixin);
}
}
return app;
},
component(name2, component) {
if (!component) {
return context.components[name2];
}
context.components[name2] = component;
return app;
},
directive(name2, directive) {
if (!directive) {
return context.directives[name2];
}
context.directives[name2] = directive;
return app;
},
mount(rootContainer, isHydrate, namespace) {
if (!isMounted) {
const vnode = app._ceVNode || createVNode(rootComponent, rootProps);
vnode.appContext = context;
if (namespace === true) {
namespace = "svg";
} else if (namespace === false) {
namespace = void 0;
}
if (isHydrate && hydrate) {
hydrate(vnode, rootContainer);
} else {
render2(vnode, rootContainer, namespace);
}
isMounted = true;
app._container = rootContainer;
rootContainer.__vue_app__ = app;
return getComponentPublicInstance(vnode.component);
}
},
onUnmount(cleanupFn) {
pluginCleanupFns.push(cleanupFn);
},
unmount() {
if (isMounted) {
callWithAsyncErrorHandling(
pluginCleanupFns,
app._instance,
16
);
render2(null, app._container);
delete app._container.__vue_app__;
}
},
provide(key2, value) {
context.provides[key2] = value;
return app;
},
runWithContext(fn) {
const lastApp = currentApp;
currentApp = app;
try {
return fn();
} finally {
currentApp = lastApp;
}
}
};
return app;
};
}
let currentApp = null;
function provide(key2, value) {
if (!currentInstance) ;
else {
let provides = currentInstance.provides;
const parentProvides = currentInstance.parent && currentInstance.parent.provides;
if (parentProvides === provides) {
provides = currentInstance.provides = Object.create(parentProvides);
}
provides[key2] = value;
}
}
function inject(key2, defaultValue, treatDefaultAsFactory = false) {
const instance = currentInstance || currentRenderingInstance;
if (instance || currentApp) {
const provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
if (provides && key2 in provides) {
return provides[key2];
} else if (arguments.length > 1) {
return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
} else ;
}
}
const internalObjectProto = {};
const createInternalObject = () => Object.create(internalObjectProto);
const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
function initProps(instance, rawProps, isStateful, isSSR = false) {
const props = {};
const attrs = createInternalObject();
instance.propsDefaults = /* @__PURE__ */ Object.create(null);
setFullProps(instance, rawProps, props, attrs);
for (const key2 in instance.propsOptions[0]) {
if (!(key2 in props)) {
props[key2] = void 0;
}
}
if (isStateful) {
instance.props = isSSR ? props : shallowReactive(props);
} else {
if (!instance.type.props) {
instance.props = attrs;
} else {
instance.props = props;
}
}
instance.attrs = attrs;
}
function updateProps(instance, rawProps, rawPrevProps, optimized) {
const {
props,
attrs,
vnode: { patchFlag }
} = instance;
const rawCurrentProps = toRaw(props);
const [options] = instance.propsOptions;
let hasAttrsChanged = false;
if (
// always force full diff in dev
// - #1942 if hmr is enabled with sfc component
// - vite#872 non-sfc component used by sfc component
(optimized || patchFlag > 0) && !(patchFlag & 16)
) {
if (patchFlag & 8) {
const propsToUpdate = instance.vnode.dynamicProps;
for (let i2 = 0; i2 < propsToUpdate.length; i2++) {
let key2 = propsToUpdate[i2];
if (isEmitListener(instance.emitsOptions, key2)) {
continue;
}
const value = rawProps[key2];
if (options) {
if (hasOwn$2(attrs, key2)) {
if (value !== attrs[key2]) {
attrs[key2] = value;
hasAttrsChanged = true;
}
} else {
const camelizedKey = camelize(key2);
props[camelizedKey] = resolvePropValue(
options,
rawCurrentProps,
camelizedKey,
value,
instance,
false
);
}
} else {
if (value !== attrs[key2]) {
attrs[key2] = value;
hasAttrsChanged = true;
}
}
}
}
} else {
if (setFullProps(instance, rawProps, props, attrs)) {
hasAttrsChanged = true;
}
let kebabKey;
for (const key2 in rawCurrentProps) {
if (!rawProps || // for camelCase
!hasOwn$2(rawProps, key2) && // it's possible the original props was passed in as kebab-case
// and converted to camelCase (#955)
((kebabKey = hyphenate(key2)) === key2 || !hasOwn$2(rawProps, kebabKey))) {
if (options) {
if (rawPrevProps && // for camelCase
(rawPrevProps[key2] !== void 0 || // for kebab-case
rawPrevProps[kebabKey] !== void 0)) {
props[key2] = resolvePropValue(
options,
rawCurrentProps,
key2,
void 0,
instance,
true
);
}
} else {
delete props[key2];
}
}
}
if (attrs !== rawCurrentProps) {
for (const key2 in attrs) {
if (!rawProps || !hasOwn$2(rawProps, key2) && true) {
delete attrs[key2];
hasAttrsChanged = true;
}
}
}
}
if (hasAttrsChanged) {
trigger(instance.attrs, "set", "");
}
}
function setFullProps(instance, rawProps, props, attrs) {
const [options, needCastKeys] = instance.propsOptions;
let hasAttrsChanged = false;
let rawCastValues;
if (rawProps) {
for (let key2 in rawProps) {
if (isReservedProp(key2)) {
continue;
}
const value = rawProps[key2];
let camelKey;
if (options && hasOwn$2(options, camelKey = camelize(key2))) {
if (!needCastKeys || !needCastKeys.includes(camelKey)) {
props[camelKey] = value;
} else {
(rawCastValues || (rawCastValues = {}))[camelKey] = value;
}
} else if (!isEmitListener(instance.emitsOptions, key2)) {
if (!(key2 in attrs) || value !== attrs[key2]) {
attrs[key2] = value;
hasAttrsChanged = true;
}
}
}
}
if (needCastKeys) {
const rawCurrentProps = toRaw(props);
const castValues = rawCastValues || EMPTY_OBJ;
for (let i2 = 0; i2 < needCastKeys.length; i2++) {
const key2 = needCastKeys[i2];
props[key2] = resolvePropValue(
options,
rawCurrentProps,
key2,
castValues[key2],
instance,
!hasOwn$2(castValues, key2)
);
}
}
return hasAttrsChanged;
}
function resolvePropValue(options, props, key2, value, instance, isAbsent) {
const opt = options[key2];
if (opt != null) {
const hasDefault = hasOwn$2(opt, "default");
if (hasDefault && value === void 0) {
const defaultValue = opt.default;
if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
const { propsDefaults } = instance;
if (key2 in propsDefaults) {
value = propsDefaults[key2];
} else {
const reset = setCurrentInstance(instance);
value = propsDefaults[key2] = defaultValue.call(
null,
props
);
reset();
}
} else {
value = defaultValue;
}
if (instance.ce) {
instance.ce._setProp(key2, value);
}
}
if (opt[
0
/* shouldCast */
]) {
if (isAbsent && !hasDefault) {
value = false;
} else if (opt[
1
/* shouldCastTrue */
] && (value === "" || value === hyphenate(key2))) {
value = true;
}
}
}
return value;
}
const mixinPropsCache = /* @__PURE__ */ new WeakMap();
function normalizePropsOptions(comp, appContext, asMixin = false) {
const cache2 = asMixin ? mixinPropsCache : appContext.propsCache;
const cached = cache2.get(comp);
if (cached) {
return cached;
}
const raw2 = comp.props;
const normalized = {};
const needCastKeys = [];
let hasExtends = false;
if (!isFunction(comp)) {
const extendProps = (raw22) => {
hasExtends = true;
const [props, keys2] = normalizePropsOptions(raw22, appContext, true);
extend$3(normalized, props);
if (keys2) needCastKeys.push(...keys2);
};
if (!asMixin && appContext.mixins.length) {
appContext.mixins.forEach(extendProps);
}
if (comp.extends) {
extendProps(comp.extends);
}
if (comp.mixins) {
comp.mixins.forEach(extendProps);
}
}
if (!raw2 && !hasExtends) {
if (isObject$2(comp)) {
cache2.set(comp, EMPTY_ARR);
}
return EMPTY_ARR;
}
if (isArray$3(raw2)) {
for (let i2 = 0; i2 < raw2.length; i2++) {
const normalizedKey = camelize(raw2[i2]);
if (validatePropName(normalizedKey)) {
normalized[normalizedKey] = EMPTY_OBJ;
}
}
} else if (raw2) {
for (const key2 in raw2) {
const normalizedKey = camelize(key2);
if (validatePropName(normalizedKey)) {
const opt = raw2[key2];
const prop = normalized[normalizedKey] = isArray$3(opt) || isFunction(opt) ? { type: opt } : extend$3({}, opt);
const propType = prop.type;
let shouldCast = false;
let shouldCastTrue = true;
if (isArray$3(propType)) {
for (let index2 = 0; index2 < propType.length; ++index2) {
const type2 = propType[index2];
const typeName2 = isFunction(type2) && type2.name;
if (typeName2 === "Boolean") {
shouldCast = true;
break;
} else if (typeName2 === "String") {
shouldCastTrue = false;
}
}
} else {
shouldCast = isFunction(propType) && propType.name === "Boolean";
}
prop[
0
/* shouldCast */
] = shouldCast;
prop[
1
/* shouldCastTrue */
] = shouldCastTrue;
if (shouldCast || hasOwn$2(prop, "default")) {
needCastKeys.push(normalizedKey);
}
}
}
}
const res = [normalized, needCastKeys];
if (isObject$2(comp)) {
cache2.set(comp, res);
}
return res;
}
function validatePropName(key2) {
if (key2[0] !== "$" && !isReservedProp(key2)) {
return true;
}
return false;
}
const isInternalKey = (key2) => key2[0] === "_" || key2 === "$stable";
const normalizeSlotValue = (value) => isArray$3(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
const normalizeSlot$1 = (key2, rawSlot, ctx) => {
if (rawSlot._n) {
return rawSlot;
}
const normalized = withCtx((...args) => {
if (false) ;
return normalizeSlotValue(rawSlot(...args));
}, ctx);
normalized._c = false;
return normalized;
};
const normalizeObjectSlots = (rawSlots, slots, instance) => {
const ctx = rawSlots._ctx;
for (const key2 in rawSlots) {
if (isInternalKey(key2)) continue;
const value = rawSlots[key2];
if (isFunction(value)) {
slots[key2] = normalizeSlot$1(key2, value, ctx);
} else if (value != null) {
const normalized = normalizeSlotValue(value);
slots[key2] = () => normalized;
}
}
};
const normalizeVNodeSlots = (instance, children) => {
const normalized = normalizeSlotValue(children);
instance.slots.default = () => normalized;
};
const assignSlots = (slots, children, optimized) => {
for (const key2 in children) {
if (optimized || key2 !== "_") {
slots[key2] = children[key2];
}
}
};
const initSlots = (instance, children, optimized) => {
const slots = instance.slots = createInternalObject();
if (instance.vnode.shapeFlag & 32) {
const type2 = children._;
if (type2) {
assignSlots(slots, children, optimized);
if (optimized) {
def(slots, "_", type2, true);
}
} else {
normalizeObjectSlots(children, slots);
}
} else if (children) {
normalizeVNodeSlots(instance, children);
}
};
const updateSlots = (instance, children, optimized) => {
const { vnode, slots } = instance;
let needDeletionCheck = true;
let deletionComparisonTarget = EMPTY_OBJ;
if (vnode.shapeFlag & 32) {
const type2 = children._;
if (type2) {
if (optimized && type2 === 1) {
needDeletionCheck = false;
} else {
assignSlots(slots, children, optimized);
}
} else {
needDeletionCheck = !children.$stable;
normalizeObjectSlots(children, slots);
}
deletionComparisonTarget = children;
} else if (children) {
normalizeVNodeSlots(instance, children);
deletionComparisonTarget = { default: 1 };
}
if (needDeletionCheck) {
for (const key2 in slots) {
if (!isInternalKey(key2) && deletionComparisonTarget[key2] == null) {
delete slots[key2];
}
}
}
};
const queuePostRenderEffect = queueEffectWithSuspense;
function createRenderer(options) {
return baseCreateRenderer(options);
}
function baseCreateRenderer(options, createHydrationFns) {
const target = getGlobalThis();
target.__VUE__ = true;
const {
insert: hostInsert,
remove: hostRemove,
patchProp: hostPatchProp,
createElement: hostCreateElement,
createText: hostCreateText,
createComment: hostCreateComment,
setText: hostSetText,
setElementText: hostSetElementText,
parentNode: hostParentNode,
nextSibling: hostNextSibling,
setScopeId: hostSetScopeId = NOOP,
insertStaticContent: hostInsertStaticContent
} = options;
const patch2 = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
if (n1 === n2) {
return;
}
if (n1 && !isSameVNodeType(n1, n2)) {
anchor = getNextHostNode(n1);
unmount(n1, parentComponent, parentSuspense, true);
n1 = null;
}
if (n2.patchFlag === -2) {
optimized = false;
n2.dynamicChildren = null;
}
const { type: type2, ref: ref3, shapeFlag } = n2;
switch (type2) {
case Text$1:
processText(n1, n2, container, anchor);
break;
case Comment:
processCommentNode(n1, n2, container, anchor);
break;
case Static:
if (n1 == null) {
mountStaticNode(n2, container, anchor, namespace);
}
break;
case Fragment:
processFragment(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
break;
default:
if (shapeFlag & 1) {
processElement(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
} else if (shapeFlag & 6) {
processComponent(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
} else if (shapeFlag & 64) {
type2.process(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized,
internals
);
} else if (shapeFlag & 128) {
type2.process(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized,
internals
);
} else ;
}
if (ref3 != null && parentComponent) {
setRef(ref3, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
}
};
const processText = (n1, n2, container, anchor) => {
if (n1 == null) {
hostInsert(
n2.el = hostCreateText(n2.children),
container,
anchor
);
} else {
const el = n2.el = n1.el;
if (n2.children !== n1.children) {
hostSetText(el, n2.children);
}
}
};
const processCommentNode = (n1, n2, container, anchor) => {
if (n1 == null) {
hostInsert(
n2.el = hostCreateComment(n2.children || ""),
container,
anchor
);
} else {
n2.el = n1.el;
}
};
const mountStaticNode = (n2, container, anchor, namespace) => {
[n2.el, n2.anchor] = hostInsertStaticContent(
n2.children,
container,
anchor,
namespace,
n2.el,
n2.anchor
);
};
const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
let next;
while (el && el !== anchor) {
next = hostNextSibling(el);
hostInsert(el, container, nextSibling);
el = next;
}
hostInsert(anchor, container, nextSibling);
};
const removeStaticNode = ({ el, anchor }) => {
let next;
while (el && el !== anchor) {
next = hostNextSibling(el);
hostRemove(el);
el = next;
}
hostRemove(anchor);
};
const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
if (n2.type === "svg") {
namespace = "svg";
} else if (n2.type === "math") {
namespace = "mathml";
}
if (n1 == null) {
mountElement(
n2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
} else {
patchElement(
n1,
n2,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
}
};
const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
let el;
let vnodeHook;
const { props, shapeFlag, transition, dirs } = vnode;
el = vnode.el = hostCreateElement(
vnode.type,
namespace,
props && props.is,
props
);
if (shapeFlag & 8) {
hostSetElementText(el, vnode.children);
} else if (shapeFlag & 16) {
mountChildren(
vnode.children,
el,
null,
parentComponent,
parentSuspense,
resolveChildrenNamespace(vnode, namespace),
slotScopeIds,
optimized
);
}
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, "created");
}
setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
if (props) {
for (const key2 in props) {
if (key2 !== "value" && !isReservedProp(key2)) {
hostPatchProp(el, key2, null, props[key2], namespace, parentComponent);
}
}
if ("value" in props) {
hostPatchProp(el, "value", null, props.value, namespace);
}
if (vnodeHook = props.onVnodeBeforeMount) {
invokeVNodeHook(vnodeHook, parentComponent, vnode);
}
}
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
}
const needCallTransitionHooks = needTransition(parentSuspense, transition);
if (needCallTransitionHooks) {
transition.beforeEnter(el);
}
hostInsert(el, container, anchor);
if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
queuePostRenderEffect(() => {
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
needCallTransitionHooks && transition.enter(el);
dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
}, parentSuspense);
}
};
const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
if (scopeId) {
hostSetScopeId(el, scopeId);
}
if (slotScopeIds) {
for (let i2 = 0; i2 < slotScopeIds.length; i2++) {
hostSetScopeId(el, slotScopeIds[i2]);
}
}
if (parentComponent) {
let subTree = parentComponent.subTree;
if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
const parentVNode = parentComponent.vnode;
setScopeId(
el,
parentVNode,
parentVNode.scopeId,
parentVNode.slotScopeIds,
parentComponent.parent
);
}
}
};
const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
for (let i2 = start; i2 < children.length; i2++) {
const child = children[i2] = optimized ? cloneIfMounted(children[i2]) : normalizeVNode(children[i2]);
patch2(
null,
child,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
}
};
const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
const el = n2.el = n1.el;
let { patchFlag, dynamicChildren, dirs } = n2;
patchFlag |= n1.patchFlag & 16;
const oldProps = n1.props || EMPTY_OBJ;
const newProps = n2.props || EMPTY_OBJ;
let vnodeHook;
parentComponent && toggleRecurse(parentComponent, false);
if (vnodeHook = newProps.onVnodeBeforeUpdate) {
invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
}
if (dirs) {
invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
}
parentComponent && toggleRecurse(parentComponent, true);
if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
hostSetElementText(el, "");
}
if (dynamicChildren) {
patchBlockChildren(
n1.dynamicChildren,
dynamicChildren,
el,
parentComponent,
parentSuspense,
resolveChildrenNamespace(n2, namespace),
slotScopeIds
);
} else if (!optimized) {
patchChildren(
n1,
n2,
el,
null,
parentComponent,
parentSuspense,
resolveChildrenNamespace(n2, namespace),
slotScopeIds,
false
);
}
if (patchFlag > 0) {
if (patchFlag & 16) {
patchProps(el, oldProps, newProps, parentComponent, namespace);
} else {
if (patchFlag & 2) {
if (oldProps.class !== newProps.class) {
hostPatchProp(el, "class", null, newProps.class, namespace);
}
}
if (patchFlag & 4) {
hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
}
if (patchFlag & 8) {
const propsToUpdate = n2.dynamicProps;
for (let i2 = 0; i2 < propsToUpdate.length; i2++) {
const key2 = propsToUpdate[i2];
const prev = oldProps[key2];
const next = newProps[key2];
if (next !== prev || key2 === "value") {
hostPatchProp(el, key2, prev, next, namespace, parentComponent);
}
}
}
}
if (patchFlag & 1) {
if (n1.children !== n2.children) {
hostSetElementText(el, n2.children);
}
}
} else if (!optimized && dynamicChildren == null) {
patchProps(el, oldProps, newProps, parentComponent, namespace);
}
if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
queuePostRenderEffect(() => {
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
}, parentSuspense);
}
};
const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
for (let i2 = 0; i2 < newChildren.length; i2++) {
const oldVNode = oldChildren[i2];
const newVNode = newChildren[i2];
const container = (
// oldVNode may be an errored async setup() component inside Suspense
// which will not have a mounted element
oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
// of the Fragment itself so it can move its children.
(oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
// which also requires the correct parent container
!isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
// In other cases, the parent container is not actually used so we
// just pass the block element here to avoid a DOM parentNode call.
fallbackContainer
)
);
patch2(
oldVNode,
newVNode,
container,
null,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
true
);
}
};
const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
if (oldProps !== newProps) {
if (oldProps !== EMPTY_OBJ) {
for (const key2 in oldProps) {
if (!isReservedProp(key2) && !(key2 in newProps)) {
hostPatchProp(
el,
key2,
oldProps[key2],
null,
namespace,
parentComponent
);
}
}
}
for (const key2 in newProps) {
if (isReservedProp(key2)) continue;
const next = newProps[key2];
const prev = oldProps[key2];
if (next !== prev && key2 !== "value") {
hostPatchProp(el, key2, prev, next, namespace, parentComponent);
}
}
if ("value" in newProps) {
hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
}
}
};
const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
if (fragmentSlotScopeIds) {
slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
}
if (n1 == null) {
hostInsert(fragmentStartAnchor, container, anchor);
hostInsert(fragmentEndAnchor, container, anchor);
mountChildren(
// #10007
// such fragment like `<></>` will be compiled into
// a fragment which doesn't have a children.
// In this case fallback to an empty array
n2.children || [],
container,
fragmentEndAnchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
} else {
if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
// of renderSlot() with no valid children
n1.dynamicChildren) {
patchBlockChildren(
n1.dynamicChildren,
dynamicChildren,
container,
parentComponent,
parentSuspense,
namespace,
slotScopeIds
);
if (
// #2080 if the stable fragment has a key, it's a <template v-for> that may
// get moved around. Make sure all root level vnodes inherit el.
// #2134 or if it's a component root, it may also get moved around
// as the component is being moved.
n2.key != null || parentComponent && n2 === parentComponent.subTree
) {
traverseStaticChildren(
n1,
n2,
true
/* shallow */
);
}
} else {
patchChildren(
n1,
n2,
container,
fragmentEndAnchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
}
}
};
const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
n2.slotScopeIds = slotScopeIds;
if (n1 == null) {
if (n2.shapeFlag & 512) {
parentComponent.ctx.activate(
n2,
container,
anchor,
namespace,
optimized
);
} else {
mountComponent(
n2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
optimized
);
}
} else {
updateComponent(n1, n2, optimized);
}
};
const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
const instance = initialVNode.component = createComponentInstance(
initialVNode,
parentComponent,
parentSuspense
);
if (isKeepAlive(initialVNode)) {
instance.ctx.renderer = internals;
}
{
setupComponent(instance, false, optimized);
}
if (instance.asyncDep) {
parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
if (!initialVNode.el) {
const placeholder2 = instance.subTree = createVNode(Comment);
processCommentNode(null, placeholder2, container, anchor);
}
} else {
setupRenderEffect(
instance,
initialVNode,
container,
anchor,
parentSuspense,
namespace,
optimized
);
}
};
const updateComponent = (n1, n2, optimized) => {
const instance = n2.component = n1.component;
if (shouldUpdateComponent(n1, n2, optimized)) {
if (instance.asyncDep && !instance.asyncResolved) {
updateComponentPreRender(instance, n2, optimized);
return;
} else {
instance.next = n2;
instance.update();
}
} else {
n2.el = n1.el;
instance.vnode = n2;
}
};
const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
const componentUpdateFn = () => {
if (!instance.isMounted) {
let vnodeHook;
const { el, props } = initialVNode;
const { bm, m: m2, parent, root: root2, type: type2 } = instance;
const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
toggleRecurse(instance, false);
if (bm) {
invokeArrayFns(bm);
}
if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
invokeVNodeHook(vnodeHook, parent, initialVNode);
}
toggleRecurse(instance, true);
if (el && hydrateNode) {
const hydrateSubTree = () => {
instance.subTree = renderComponentRoot(instance);
hydrateNode(
el,
instance.subTree,
instance,
parentSuspense,
null
);
};
if (isAsyncWrapperVNode && type2.__asyncHydrate) {
type2.__asyncHydrate(
el,
instance,
hydrateSubTree
);
} else {
hydrateSubTree();
}
} else {
if (root2.ce) {
root2.ce._injectChildStyle(type2);
}
const subTree = instance.subTree = renderComponentRoot(instance);
patch2(
null,
subTree,
container,
anchor,
instance,
parentSuspense,
namespace
);
initialVNode.el = subTree.el;
}
if (m2) {
queuePostRenderEffect(m2, parentSuspense);
}
if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
const scopedInitialVNode = initialVNode;
queuePostRenderEffect(
() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
parentSuspense
);
}
if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
instance.a && queuePostRenderEffect(instance.a, parentSuspense);
}
instance.isMounted = true;
initialVNode = container = anchor = null;
} else {
let { next, bu, u: u2, parent, vnode } = instance;
{
const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
if (nonHydratedAsyncRoot) {
if (next) {
next.el = vnode.el;
updateComponentPreRender(instance, next, optimized);
}
nonHydratedAsyncRoot.asyncDep.then(() => {
if (!instance.isUnmounted) {
componentUpdateFn();
}
});
return;
}
}
let originNext = next;
let vnodeHook;
toggleRecurse(instance, false);
if (next) {
next.el = vnode.el;
updateComponentPreRender(instance, next, optimized);
} else {
next = vnode;
}
if (bu) {
invokeArrayFns(bu);
}
if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
invokeVNodeHook(vnodeHook, parent, next, vnode);
}
toggleRecurse(instance, true);
const nextTree = renderComponentRoot(instance);
const prevTree = instance.subTree;
instance.subTree = nextTree;
patch2(
prevTree,
nextTree,
// parent may have changed if it's in a teleport
hostParentNode(prevTree.el),
// anchor may have changed if it's in a fragment
getNextHostNode(prevTree),
instance,
parentSuspense,
namespace
);
next.el = nextTree.el;
if (originNext === null) {
updateHOCHostEl(instance, nextTree.el);
}
if (u2) {
queuePostRenderEffect(u2, parentSuspense);
}
if (vnodeHook = next.props && next.props.onVnodeUpdated) {
queuePostRenderEffect(
() => invokeVNodeHook(vnodeHook, parent, next, vnode),
parentSuspense
);
}
}
};
instance.scope.on();
const effect2 = instance.effect = new ReactiveEffect(componentUpdateFn);
instance.scope.off();
const update = instance.update = effect2.run.bind(effect2);
const job = instance.job = effect2.runIfDirty.bind(effect2);
job.i = instance;
job.id = instance.uid;
effect2.scheduler = () => queueJob(job);
toggleRecurse(instance, true);
update();
};
const updateComponentPreRender = (instance, nextVNode, optimized) => {
nextVNode.component = instance;
const prevProps = instance.vnode.props;
instance.vnode = nextVNode;
instance.next = null;
updateProps(instance, nextVNode.props, prevProps, optimized);
updateSlots(instance, nextVNode.children, optimized);
pauseTracking();
flushPreFlushCbs(instance);
resetTracking();
};
const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
const c1 = n1 && n1.children;
const prevShapeFlag = n1 ? n1.shapeFlag : 0;
const c2 = n2.children;
const { patchFlag, shapeFlag } = n2;
if (patchFlag > 0) {
if (patchFlag & 128) {
patchKeyedChildren(
c1,
c2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
return;
} else if (patchFlag & 256) {
patchUnkeyedChildren(
c1,
c2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
return;
}
}
if (shapeFlag & 8) {
if (prevShapeFlag & 16) {
unmountChildren(c1, parentComponent, parentSuspense);
}
if (c2 !== c1) {
hostSetElementText(container, c2);
}
} else {
if (prevShapeFlag & 16) {
if (shapeFlag & 16) {
patchKeyedChildren(
c1,
c2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
} else {
unmountChildren(c1, parentComponent, parentSuspense, true);
}
} else {
if (prevShapeFlag & 8) {
hostSetElementText(container, "");
}
if (shapeFlag & 16) {
mountChildren(
c2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
}
}
}
};
const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
c1 = c1 || EMPTY_ARR;
c2 = c2 || EMPTY_ARR;
const oldLength = c1.length;
const newLength = c2.length;
const commonLength = Math.min(oldLength, newLength);
let i2;
for (i2 = 0; i2 < commonLength; i2++) {
const nextChild = c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]);
patch2(
c1[i2],
nextChild,
container,
null,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
}
if (oldLength > newLength) {
unmountChildren(
c1,
parentComponent,
parentSuspense,
true,
false,
commonLength
);
} else {
mountChildren(
c2,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized,
commonLength
);
}
};
const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
let i2 = 0;
const l2 = c2.length;
let e1 = c1.length - 1;
let e2 = l2 - 1;
while (i2 <= e1 && i2 <= e2) {
const n1 = c1[i2];
const n2 = c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]);
if (isSameVNodeType(n1, n2)) {
patch2(
n1,
n2,
container,
null,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
} else {
break;
}
i2++;
}
while (i2 <= e1 && i2 <= e2) {
const n1 = c1[e1];
const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
if (isSameVNodeType(n1, n2)) {
patch2(
n1,
n2,
container,
null,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
} else {
break;
}
e1--;
e2--;
}
if (i2 > e1) {
if (i2 <= e2) {
const nextPos = e2 + 1;
const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
while (i2 <= e2) {
patch2(
null,
c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]),
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
i2++;
}
}
} else if (i2 > e2) {
while (i2 <= e1) {
unmount(c1[i2], parentComponent, parentSuspense, true);
i2++;
}
} else {
const s1 = i2;
const s22 = i2;
const keyToNewIndexMap = /* @__PURE__ */ new Map();
for (i2 = s22; i2 <= e2; i2++) {
const nextChild = c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]);
if (nextChild.key != null) {
keyToNewIndexMap.set(nextChild.key, i2);
}
}
let j2;
let patched = 0;
const toBePatched = e2 - s22 + 1;
let moved = false;
let maxNewIndexSoFar = 0;
const newIndexToOldIndexMap = new Array(toBePatched);
for (i2 = 0; i2 < toBePatched; i2++) newIndexToOldIndexMap[i2] = 0;
for (i2 = s1; i2 <= e1; i2++) {
const prevChild = c1[i2];
if (patched >= toBePatched) {
unmount(prevChild, parentComponent, parentSuspense, true);
continue;
}
let newIndex;
if (prevChild.key != null) {
newIndex = keyToNewIndexMap.get(prevChild.key);
} else {
for (j2 = s22; j2 <= e2; j2++) {
if (newIndexToOldIndexMap[j2 - s22] === 0 && isSameVNodeType(prevChild, c2[j2])) {
newIndex = j2;
break;
}
}
}
if (newIndex === void 0) {
unmount(prevChild, parentComponent, parentSuspense, true);
} else {
newIndexToOldIndexMap[newIndex - s22] = i2 + 1;
if (newIndex >= maxNewIndexSoFar) {
maxNewIndexSoFar = newIndex;
} else {
moved = true;
}
patch2(
prevChild,
c2[newIndex],
container,
null,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
patched++;
}
}
const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
j2 = increasingNewIndexSequence.length - 1;
for (i2 = toBePatched - 1; i2 >= 0; i2--) {
const nextIndex = s22 + i2;
const nextChild = c2[nextIndex];
const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
if (newIndexToOldIndexMap[i2] === 0) {
patch2(
null,
nextChild,
container,
anchor,
parentComponent,
parentSuspense,
namespace,
slotScopeIds,
optimized
);
} else if (moved) {
if (j2 < 0 || i2 !== increasingNewIndexSequence[j2]) {
move(nextChild, container, anchor, 2);
} else {
j2--;
}
}
}
}
};
const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
const { el, type: type2, transition, children, shapeFlag } = vnode;
if (shapeFlag & 6) {
move(vnode.component.subTree, container, anchor, moveType);
return;
}
if (shapeFlag & 128) {
vnode.suspense.move(container, anchor, moveType);
return;
}
if (shapeFlag & 64) {
type2.move(vnode, container, anchor, internals);
return;
}
if (type2 === Fragment) {
hostInsert(el, container, anchor);
for (let i2 = 0; i2 < children.length; i2++) {
move(children[i2], container, anchor, moveType);
}
hostInsert(vnode.anchor, container, anchor);
return;
}
if (type2 === Static) {
moveStaticNode(vnode, container, anchor);
return;
}
const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
if (needTransition2) {
if (moveType === 0) {
transition.beforeEnter(el);
hostInsert(el, container, anchor);
queuePostRenderEffect(() => transition.enter(el), parentSuspense);
} else {
const { leave, delayLeave, afterLeave } = transition;
const remove22 = () => hostInsert(el, container, anchor);
const performLeave = () => {
leave(el, () => {
remove22();
afterLeave && afterLeave();
});
};
if (delayLeave) {
delayLeave(el, remove22, performLeave);
} else {
performLeave();
}
}
} else {
hostInsert(el, container, anchor);
}
};
const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
const {
type: type2,
props,
ref: ref3,
children,
dynamicChildren,
shapeFlag,
patchFlag,
dirs,
cacheIndex
} = vnode;
if (patchFlag === -2) {
optimized = false;
}
if (ref3 != null) {
setRef(ref3, null, parentSuspense, vnode, true);
}
if (cacheIndex != null) {
parentComponent.renderCache[cacheIndex] = void 0;
}
if (shapeFlag & 256) {
parentComponent.ctx.deactivate(vnode);
return;
}
const shouldInvokeDirs = shapeFlag & 1 && dirs;
const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
let vnodeHook;
if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
invokeVNodeHook(vnodeHook, parentComponent, vnode);
}
if (shapeFlag & 6) {
unmountComponent(vnode.component, parentSuspense, doRemove);
} else {
if (shapeFlag & 128) {
vnode.suspense.unmount(parentSuspense, doRemove);
return;
}
if (shouldInvokeDirs) {
invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
}
if (shapeFlag & 64) {
vnode.type.remove(
vnode,
parentComponent,
parentSuspense,
internals,
doRemove
);
} else if (dynamicChildren && // #5154
// when v-once is used inside a block, setBlockTracking(-1) marks the
// parent block with hasOnce: true
// so that it doesn't take the fast path during unmount - otherwise
// components nested in v-once are never unmounted.
!dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
(type2 !== Fragment || patchFlag > 0 && patchFlag & 64)) {
unmountChildren(
dynamicChildren,
parentComponent,
parentSuspense,
false,
true
);
} else if (type2 === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
unmountChildren(children, parentComponent, parentSuspense);
}
if (doRemove) {
remove2(vnode);
}
}
if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
queuePostRenderEffect(() => {
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
}, parentSuspense);
}
};
const remove2 = (vnode) => {
const { type: type2, el, anchor, transition } = vnode;
if (type2 === Fragment) {
{
removeFragment(el, anchor);
}
return;
}
if (type2 === Static) {
removeStaticNode(vnode);
return;
}
const performRemove = () => {
hostRemove(el);
if (transition && !transition.persisted && transition.afterLeave) {
transition.afterLeave();
}
};
if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
const { leave, delayLeave } = transition;
const performLeave = () => leave(el, performRemove);
if (delayLeave) {
delayLeave(vnode.el, performRemove, performLeave);
} else {
performLeave();
}
} else {
performRemove();
}
};
const removeFragment = (cur2, end) => {
let next;
while (cur2 !== end) {
next = hostNextSibling(cur2);
hostRemove(cur2);
cur2 = next;
}
hostRemove(end);
};
const unmountComponent = (instance, parentSuspense, doRemove) => {
const { bum, scope, job, subTree, um, m: m2, a: a2 } = instance;
invalidateMount(m2);
invalidateMount(a2);
if (bum) {
invokeArrayFns(bum);
}
scope.stop();
if (job) {
job.flags |= 8;
unmount(subTree, instance, parentSuspense, doRemove);
}
if (um) {
queuePostRenderEffect(um, parentSuspense);
}
queuePostRenderEffect(() => {
instance.isUnmounted = true;
}, parentSuspense);
if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
parentSuspense.deps--;
if (parentSuspense.deps === 0) {
parentSuspense.resolve();
}
}
};
const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
for (let i2 = start; i2 < children.length; i2++) {
unmount(children[i2], parentComponent, parentSuspense, doRemove, optimized);
}
};
const getNextHostNode = (vnode) => {
if (vnode.shapeFlag & 6) {
return getNextHostNode(vnode.component.subTree);
}
if (vnode.shapeFlag & 128) {
return vnode.suspense.next();
}
const el = hostNextSibling(vnode.anchor || vnode.el);
const teleportEnd = el && el[TeleportEndKey];
return teleportEnd ? hostNextSibling(teleportEnd) : el;
};
let isFlushing = false;
const render2 = (vnode, container, namespace) => {
if (vnode == null) {
if (container._vnode) {
unmount(container._vnode, null, null, true);
}
} else {
patch2(
container._vnode || null,
vnode,
container,
null,
null,
null,
namespace
);
}
container._vnode = vnode;
if (!isFlushing) {
isFlushing = true;
flushPreFlushCbs();
flushPostFlushCbs();
isFlushing = false;
}
};
const internals = {
p: patch2,
um: unmount,
m: move,
r: remove2,
mt: mountComponent,
mc: mountChildren,
pc: patchChildren,
pbc: patchBlockChildren,
n: getNextHostNode,
o: options
};
let hydrate;
let hydrateNode;
return {
render: render2,
hydrate,
createApp: createAppAPI(render2, hydrate)
};
}
function resolveChildrenNamespace({ type: type2, props }, currentNamespace) {
return currentNamespace === "svg" && type2 === "foreignObject" || currentNamespace === "mathml" && type2 === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
}
function toggleRecurse({ effect: effect2, job }, allowed) {
if (allowed) {
effect2.flags |= 32;
job.flags |= 4;
} else {
effect2.flags &= ~32;
job.flags &= ~4;
}
}
function needTransition(parentSuspense, transition) {
return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
}
function traverseStaticChildren(n1, n2, shallow = false) {
const ch1 = n1.children;
const ch2 = n2.children;
if (isArray$3(ch1) && isArray$3(ch2)) {
for (let i2 = 0; i2 < ch1.length; i2++) {
const c1 = ch1[i2];
let c2 = ch2[i2];
if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
c2 = ch2[i2] = cloneIfMounted(ch2[i2]);
c2.el = c1.el;
}
if (!shallow && c2.patchFlag !== -2)
traverseStaticChildren(c1, c2);
}
if (c2.type === Text$1) {
c2.el = c1.el;
}
}
}
}
function getSequence(arr) {
const p2 = arr.slice();
const result = [0];
let i2, j2, u2, v2, c2;
const len = arr.length;
for (i2 = 0; i2 < len; i2++) {
const arrI = arr[i2];
if (arrI !== 0) {
j2 = result[result.length - 1];
if (arr[j2] < arrI) {
p2[i2] = j2;
result.push(i2);
continue;
}
u2 = 0;
v2 = result.length - 1;
while (u2 < v2) {
c2 = u2 + v2 >> 1;
if (arr[result[c2]] < arrI) {
u2 = c2 + 1;
} else {
v2 = c2;
}
}
if (arrI < arr[result[u2]]) {
if (u2 > 0) {
p2[i2] = result[u2 - 1];
}
result[u2] = i2;
}
}
}
u2 = result.length;
v2 = result[u2 - 1];
while (u2-- > 0) {
result[u2] = v2;
v2 = p2[v2];
}
return result;
}
function locateNonHydratedAsyncRoot(instance) {
const subComponent = instance.subTree.component;
if (subComponent) {
if (subComponent.asyncDep && !subComponent.asyncResolved) {
return subComponent;
} else {
return locateNonHydratedAsyncRoot(subComponent);
}
}
}
function invalidateMount(hooks) {
if (hooks) {
for (let i2 = 0; i2 < hooks.length; i2++)
hooks[i2].flags |= 8;
}
}
const ssrContextKey = Symbol.for("v-scx");
const useSSRContext = () => {
{
const ctx = inject(ssrContextKey);
return ctx;
}
};
function watchEffect(effect2, options) {
return doWatch(effect2, null, options);
}
function watchPostEffect(effect2, options) {
return doWatch(
effect2,
null,
{ flush: "post" }
);
}
function watch(source2, cb, options) {
return doWatch(source2, cb, options);
}
function doWatch(source2, cb, options = EMPTY_OBJ) {
const { immediate, deep, flush, once } = options;
const baseWatchOptions = extend$3({}, options);
const runsImmediately = cb && immediate || !cb && flush !== "post";
let ssrCleanup;
if (isInSSRComponentSetup) {
if (flush === "sync") {
const ctx = useSSRContext();
ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
} else if (!runsImmediately) {
const watchStopHandle = () => {
};
watchStopHandle.stop = NOOP;
watchStopHandle.resume = NOOP;
watchStopHandle.pause = NOOP;
return watchStopHandle;
}
}
const instance = currentInstance;
baseWatchOptions.call = (fn, type2, args) => callWithAsyncErrorHandling(fn, instance, type2, args);
let isPre = false;
if (flush === "post") {
baseWatchOptions.scheduler = (job) => {
queuePostRenderEffect(job, instance && instance.suspense);
};
} else if (flush !== "sync") {
isPre = true;
baseWatchOptions.scheduler = (job, isFirstRun) => {
if (isFirstRun) {
job();
} else {
queueJob(job);
}
};
}
baseWatchOptions.augmentJob = (job) => {
if (cb) {
job.flags |= 4;
}
if (isPre) {
job.flags |= 2;
if (instance) {
job.id = instance.uid;
job.i = instance;
}
}
};
const watchHandle = watch$1(source2, cb, baseWatchOptions);
if (isInSSRComponentSetup) {
if (ssrCleanup) {
ssrCleanup.push(watchHandle);
} else if (runsImmediately) {
watchHandle();
}
}
return watchHandle;
}
function instanceWatch(source2, value, options) {
const publicThis = this.proxy;
const getter = isString$1(source2) ? source2.includes(".") ? createPathGetter(publicThis, source2) : () => publicThis[source2] : source2.bind(publicThis, publicThis);
let cb;
if (isFunction(value)) {
cb = value;
} else {
cb = value.handler;
options = value;
}
const reset = setCurrentInstance(this);
const res = doWatch(getter, cb.bind(publicThis), options);
reset();
return res;
}
function createPathGetter(ctx, path2) {
const segments = path2.split(".");
return () => {
let cur2 = ctx;
for (let i2 = 0; i2 < segments.length && cur2; i2++) {
cur2 = cur2[segments[i2]];
}
return cur2;
};
}
const getModelModifiers = (props, modelName) => {
return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${camelize(modelName)}Modifiers`] || props[`${hyphenate(modelName)}Modifiers`];
};
function emit(instance, event, ...rawArgs) {
if (instance.isUnmounted) return;
const props = instance.vnode.props || EMPTY_OBJ;
let args = rawArgs;
const isModelListener2 = event.startsWith("update:");
const modifiers2 = isModelListener2 && getModelModifiers(props, event.slice(7));
if (modifiers2) {
if (modifiers2.trim) {
args = rawArgs.map((a2) => isString$1(a2) ? a2.trim() : a2);
}
if (modifiers2.number) {
args = rawArgs.map(looseToNumber);
}
}
let handlerName;
let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
props[handlerName = toHandlerKey(camelize(event))];
if (!handler && isModelListener2) {
handler = props[handlerName = toHandlerKey(hyphenate(event))];
}
if (handler) {
callWithAsyncErrorHandling(
handler,
instance,
6,
args
);
}
const onceHandler = props[handlerName + `Once`];
if (onceHandler) {
if (!instance.emitted) {
instance.emitted = {};
} else if (instance.emitted[handlerName]) {
return;
}
instance.emitted[handlerName] = true;
callWithAsyncErrorHandling(
onceHandler,
instance,
6,
args
);
}
}
function normalizeEmitsOptions(comp, appContext, asMixin = false) {
const cache2 = appContext.emitsCache;
const cached = cache2.get(comp);
if (cached !== void 0) {
return cached;
}
const raw2 = comp.emits;
let normalized = {};
let hasExtends = false;
if (!isFunction(comp)) {
const extendEmits = (raw22) => {
const normalizedFromExtend = normalizeEmitsOptions(raw22, appContext, true);
if (normalizedFromExtend) {
hasExtends = true;
extend$3(normalized, normalizedFromExtend);
}
};
if (!asMixin && appContext.mixins.length) {
appContext.mixins.forEach(extendEmits);
}
if (comp.extends) {
extendEmits(comp.extends);
}
if (comp.mixins) {
comp.mixins.forEach(extendEmits);
}
}
if (!raw2 && !hasExtends) {
if (isObject$2(comp)) {
cache2.set(comp, null);
}
return null;
}
if (isArray$3(raw2)) {
raw2.forEach((key2) => normalized[key2] = null);
} else {
extend$3(normalized, raw2);
}
if (isObject$2(comp)) {
cache2.set(comp, normalized);
}
return normalized;
}
function isEmitListener(options, key2) {
if (!options || !isOn(key2)) {
return false;
}
key2 = key2.slice(2).replace(/Once$/, "");
return hasOwn$2(options, key2[0].toLowerCase() + key2.slice(1)) || hasOwn$2(options, hyphenate(key2)) || hasOwn$2(options, key2);
}
function markAttrsAccessed() {
}
function renderComponentRoot(instance) {
const {
type: Component,
vnode,
proxy,
withProxy,
propsOptions: [propsOptions],
slots,
attrs,
emit: emit2,
render: render2,
renderCache,
props,
data,
setupState,
ctx,
inheritAttrs
} = instance;
const prev = setCurrentRenderingInstance(instance);
let result;
let fallthroughAttrs;
try {
if (vnode.shapeFlag & 4) {
const proxyToUse = withProxy || proxy;
const thisProxy = false ? new Proxy(proxyToUse, {
get(target, key2, receiver) {
warn$1$1(
`Property '${String(
key2
)}' was accessed via 'this'. Avoid using 'this' in templates.`
);
return Reflect.get(target, key2, receiver);
}
}) : proxyToUse;
result = normalizeVNode(
render2.call(
thisProxy,
proxyToUse,
renderCache,
false ? shallowReadonly(props) : props,
setupState,
data,
ctx
)
);
fallthroughAttrs = attrs;
} else {
const render22 = Component;
if (false) ;
result = normalizeVNode(
render22.length > 1 ? render22(
false ? shallowReadonly(props) : props,
false ? {
get attrs() {
markAttrsAccessed();
return shallowReadonly(attrs);
},
slots,
emit: emit2
} : { attrs, slots, emit: emit2 }
) : render22(
false ? shallowReadonly(props) : props,
null
)
);
fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
}
} catch (err) {
blockStack.length = 0;
handleError(err, instance, 1);
result = createVNode(Comment);
}
let root2 = result;
if (fallthroughAttrs && inheritAttrs !== false) {
const keys2 = Object.keys(fallthroughAttrs);
const { shapeFlag } = root2;
if (keys2.length) {
if (shapeFlag & (1 | 6)) {
if (propsOptions && keys2.some(isModelListener)) {
fallthroughAttrs = filterModelListeners(
fallthroughAttrs,
propsOptions
);
}
root2 = cloneVNode(root2, fallthroughAttrs, false, true);
}
}
}
if (vnode.dirs) {
root2 = cloneVNode(root2, null, false, true);
root2.dirs = root2.dirs ? root2.dirs.concat(vnode.dirs) : vnode.dirs;
}
if (vnode.transition) {
setTransitionHooks(root2, vnode.transition);
}
{
result = root2;
}
setCurrentRenderingInstance(prev);
return result;
}
const getFunctionalFallthrough = (attrs) => {
let res;
for (const key2 in attrs) {
if (key2 === "class" || key2 === "style" || isOn(key2)) {
(res || (res = {}))[key2] = attrs[key2];
}
}
return res;
};
const filterModelListeners = (attrs, props) => {
const res = {};
for (const key2 in attrs) {
if (!isModelListener(key2) || !(key2.slice(9) in props)) {
res[key2] = attrs[key2];
}
}
return res;
};
function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
const { props: prevProps, children: prevChildren, component } = prevVNode;
const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
const emits = component.emitsOptions;
if (nextVNode.dirs || nextVNode.transition) {
return true;
}
if (optimized && patchFlag >= 0) {
if (patchFlag & 1024) {
return true;
}
if (patchFlag & 16) {
if (!prevProps) {
return !!nextProps;
}
return hasPropsChanged(prevProps, nextProps, emits);
} else if (patchFlag & 8) {
const dynamicProps = nextVNode.dynamicProps;
for (let i2 = 0; i2 < dynamicProps.length; i2++) {
const key2 = dynamicProps[i2];
if (nextProps[key2] !== prevProps[key2] && !isEmitListener(emits, key2)) {
return true;
}
}
}
} else {
if (prevChildren || nextChildren) {
if (!nextChildren || !nextChildren.$stable) {
return true;
}
}
if (prevProps === nextProps) {
return false;
}
if (!prevProps) {
return !!nextProps;
}
if (!nextProps) {
return true;
}
return hasPropsChanged(prevProps, nextProps, emits);
}
return false;
}
function hasPropsChanged(prevProps, nextProps, emitsOptions) {
const nextKeys = Object.keys(nextProps);
if (nextKeys.length !== Object.keys(prevProps).length) {
return true;
}
for (let i2 = 0; i2 < nextKeys.length; i2++) {
const key2 = nextKeys[i2];
if (nextProps[key2] !== prevProps[key2] && !isEmitListener(emitsOptions, key2)) {
return true;
}
}
return false;
}
function updateHOCHostEl({ vnode, parent }, el) {
while (parent) {
const root2 = parent.subTree;
if (root2.suspense && root2.suspense.activeBranch === vnode) {
root2.el = vnode.el;
}
if (root2 === vnode) {
(vnode = parent.vnode).el = el;
parent = parent.parent;
} else {
break;
}
}
}
const isSuspense = (type2) => type2.__isSuspense;
function queueEffectWithSuspense(fn, suspense) {
if (suspense && suspense.pendingBranch) {
if (isArray$3(fn)) {
suspense.effects.push(...fn);
} else {
suspense.effects.push(fn);
}
} else {
queuePostFlushCb(fn);
}
}
const Fragment = Symbol.for("v-fgt");
const Text$1 = Symbol.for("v-txt");
const Comment = Symbol.for("v-cmt");
const Static = Symbol.for("v-stc");
const blockStack = [];
let currentBlock = null;
function openBlock(disableTracking = false) {
blockStack.push(currentBlock = disableTracking ? null : []);
}
function closeBlock() {
blockStack.pop();
currentBlock = blockStack[blockStack.length - 1] || null;
}
let isBlockTreeEnabled = 1;
function setBlockTracking(value) {
isBlockTreeEnabled += value;
if (value < 0 && currentBlock) {
currentBlock.hasOnce = true;
}
}
function setupBlock(vnode) {
vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
closeBlock();
if (isBlockTreeEnabled > 0 && currentBlock) {
currentBlock.push(vnode);
}
return vnode;
}
function createElementBlock(type2, props, children, patchFlag, dynamicProps, shapeFlag) {
return setupBlock(
createBaseVNode(
type2,
props,
children,
patchFlag,
dynamicProps,
shapeFlag,
true
)
);
}
function createBlock(type2, props, children, patchFlag, dynamicProps) {
return setupBlock(
createVNode(
type2,
props,
children,
patchFlag,
dynamicProps,
true
)
);
}
function isVNode(value) {
return value ? value.__v_isVNode === true : false;
}
function isSameVNodeType(n1, n2) {
return n1.type === n2.type && n1.key === n2.key;
}
const normalizeKey = ({ key: key2 }) => key2 != null ? key2 : null;
const normalizeRef = ({
ref: ref3,
ref_key,
ref_for
}) => {
if (typeof ref3 === "number") {
ref3 = "" + ref3;
}
return ref3 != null ? isString$1(ref3) || isRef(ref3) || isFunction(ref3) ? { i: currentRenderingInstance, r: ref3, k: ref_key, f: !!ref_for } : ref3 : null;
};
function createBaseVNode(type2, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type2 === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
const vnode = {
__v_isVNode: true,
__v_skip: true,
type: type2,
props,
key: props && normalizeKey(props),
ref: props && normalizeRef(props),
scopeId: currentScopeId,
slotScopeIds: null,
children,
component: null,
suspense: null,
ssContent: null,
ssFallback: null,
dirs: null,
transition: null,
el: null,
anchor: null,
target: null,
targetStart: null,
targetAnchor: null,
staticCount: 0,
shapeFlag,
patchFlag,
dynamicProps,
dynamicChildren: null,
appContext: null,
ctx: currentRenderingInstance
};
if (needFullChildrenNormalization) {
normalizeChildren(vnode, children);
if (shapeFlag & 128) {
type2.normalize(vnode);
}
} else if (children) {
vnode.shapeFlag |= isString$1(children) ? 8 : 16;
}
if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
!isBlockNode && // has current parent block
currentBlock && // presence of a patch flag indicates this node needs patching on updates.
// component nodes also should always be patched, because even if the
// component doesn't need to update, it needs to persist the instance on to
// the next vnode so that it can be properly unmounted later.
(vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
// vnode should not be considered dynamic due to handler caching.
vnode.patchFlag !== 32) {
currentBlock.push(vnode);
}
return vnode;
}
const createVNode = _createVNode;
function _createVNode(type2, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
if (!type2 || type2 === NULL_DYNAMIC_COMPONENT) {
type2 = Comment;
}
if (isVNode(type2)) {
const cloned = cloneVNode(
type2,
props,
true
/* mergeRef: true */
);
if (children) {
normalizeChildren(cloned, children);
}
if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
if (cloned.shapeFlag & 6) {
currentBlock[currentBlock.indexOf(type2)] = cloned;
} else {
currentBlock.push(cloned);
}
}
cloned.patchFlag = -2;
return cloned;
}
if (isClassComponent(type2)) {
type2 = type2.__vccOpts;
}
if (props) {
props = guardReactiveProps(props);
let { class: klass, style: style2 } = props;
if (klass && !isString$1(klass)) {
props.class = normalizeClass(klass);
}
if (isObject$2(style2)) {
if (isProxy(style2) && !isArray$3(style2)) {
style2 = extend$3({}, style2);
}
props.style = normalizeStyle(style2);
}
}
const shapeFlag = isString$1(type2) ? 1 : isSuspense(type2) ? 128 : isTeleport(type2) ? 64 : isObject$2(type2) ? 4 : isFunction(type2) ? 2 : 0;
return createBaseVNode(
type2,
props,
children,
patchFlag,
dynamicProps,
shapeFlag,
isBlockNode,
true
);
}
function guardReactiveProps(props) {
if (!props) return null;
return isProxy(props) || isInternalObject(props) ? extend$3({}, props) : props;
}
function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
const { props, ref: ref3, patchFlag, children, transition } = vnode;
const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
const cloned = {
__v_isVNode: true,
__v_skip: true,
type: vnode.type,
props: mergedProps,
key: mergedProps && normalizeKey(mergedProps),
ref: extraProps && extraProps.ref ? (
// #2078 in the case of <component :is="vnode" ref="extra"/>
// if the vnode itself already has a ref, cloneVNode will need to merge
// the refs so the single vnode can be set on multiple refs
mergeRef && ref3 ? isArray$3(ref3) ? ref3.concat(normalizeRef(extraProps)) : [ref3, normalizeRef(extraProps)] : normalizeRef(extraProps)
) : ref3,
scopeId: vnode.scopeId,
slotScopeIds: vnode.slotScopeIds,
children,
target: vnode.target,
targetStart: vnode.targetStart,
targetAnchor: vnode.targetAnchor,
staticCount: vnode.staticCount,
shapeFlag: vnode.shapeFlag,
// if the vnode is cloned with extra props, we can no longer assume its
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
// note: preserve flag for fragments since they use the flag for children
// fast paths only.
patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
dynamicProps: vnode.dynamicProps,
dynamicChildren: vnode.dynamicChildren,
appContext: vnode.appContext,
dirs: vnode.dirs,
transition,
// These should technically only be non-null on mounted VNodes. However,
// they *should* be copied for kept-alive vnodes. So we just always copy
// them since them being non-null during a mount doesn't affect the logic as
// they will simply be overwritten.
component: vnode.component,
suspense: vnode.suspense,
ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
el: vnode.el,
anchor: vnode.anchor,
ctx: vnode.ctx,
ce: vnode.ce
};
if (transition && cloneTransition) {
setTransitionHooks(
cloned,
transition.clone(cloned)
);
}
return cloned;
}
function createTextVNode(text2 = " ", flag = 0) {
return createVNode(Text$1, null, text2, flag);
}
function createStaticVNode(content2, numberOfNodes) {
const vnode = createVNode(Static, null, content2);
vnode.staticCount = numberOfNodes;
return vnode;
}
function createCommentVNode(text2 = "", asBlock = false) {
return asBlock ? (openBlock(), createBlock(Comment, null, text2)) : createVNode(Comment, null, text2);
}
function normalizeVNode(child) {
if (child == null || typeof child === "boolean") {
return createVNode(Comment);
} else if (isArray$3(child)) {
return createVNode(
Fragment,
null,
// #3666, avoid reference pollution when reusing vnode
child.slice()
);
} else if (isVNode(child)) {
return cloneIfMounted(child);
} else {
return createVNode(Text$1, null, String(child));
}
}
function cloneIfMounted(child) {
return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
}
function normalizeChildren(vnode, children) {
let type2 = 0;
const { shapeFlag } = vnode;
if (children == null) {
children = null;
} else if (isArray$3(children)) {
type2 = 16;
} else if (typeof children === "object") {
if (shapeFlag & (1 | 64)) {
const slot = children.default;
if (slot) {
slot._c && (slot._d = false);
normalizeChildren(vnode, slot());
slot._c && (slot._d = true);
}
return;
} else {
type2 = 32;
const slotFlag = children._;
if (!slotFlag && !isInternalObject(children)) {
children._ctx = currentRenderingInstance;
} else if (slotFlag === 3 && currentRenderingInstance) {
if (currentRenderingInstance.slots._ === 1) {
children._ = 1;
} else {
children._ = 2;
vnode.patchFlag |= 1024;
}
}
}
} else if (isFunction(children)) {
children = { default: children, _ctx: currentRenderingInstance };
type2 = 32;
} else {
children = String(children);
if (shapeFlag & 64) {
type2 = 16;
children = [createTextVNode(children)];
} else {
type2 = 8;
}
}
vnode.children = children;
vnode.shapeFlag |= type2;
}
function mergeProps(...args) {
const ret = {};
for (let i2 = 0; i2 < args.length; i2++) {
const toMerge = args[i2];
for (const key2 in toMerge) {
if (key2 === "class") {
if (ret.class !== toMerge.class) {
ret.class = normalizeClass([ret.class, toMerge.class]);
}
} else if (key2 === "style") {
ret.style = normalizeStyle([ret.style, toMerge.style]);
} else if (isOn(key2)) {
const existing = ret[key2];
const incoming = toMerge[key2];
if (incoming && existing !== incoming && !(isArray$3(existing) && existing.includes(incoming))) {
ret[key2] = existing ? [].concat(existing, incoming) : incoming;
}
} else if (key2 !== "") {
ret[key2] = toMerge[key2];
}
}
}
return ret;
}
function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
callWithAsyncErrorHandling(hook, instance, 7, [
vnode,
prevVNode
]);
}
const emptyAppContext = createAppContext();
let uid = 0;
function createComponentInstance(vnode, parent, suspense) {
const type2 = vnode.type;
const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
const instance = {
uid: uid++,
vnode,
type: type2,
parent,
appContext,
root: null,
// to be immediately set
next: null,
subTree: null,
// will be set synchronously right after creation
effect: null,
update: null,
// will be set synchronously right after creation
job: null,
scope: new EffectScope(
true
/* detached */
),
render: null,
proxy: null,
exposed: null,
exposeProxy: null,
withProxy: null,
provides: parent ? parent.provides : Object.create(appContext.provides),
ids: parent ? parent.ids : ["", 0, 0],
accessCache: null,
renderCache: [],
// local resolved assets
components: null,
directives: null,
// resolved props and emits options
propsOptions: normalizePropsOptions(type2, appContext),
emitsOptions: normalizeEmitsOptions(type2, appContext),
// emit
emit: null,
// to be set immediately
emitted: null,
// props default value
propsDefaults: EMPTY_OBJ,
// inheritAttrs
inheritAttrs: type2.inheritAttrs,
// state
ctx: EMPTY_OBJ,
data: EMPTY_OBJ,
props: EMPTY_OBJ,
attrs: EMPTY_OBJ,
slots: EMPTY_OBJ,
refs: EMPTY_OBJ,
setupState: EMPTY_OBJ,
setupContext: null,
// suspense related
suspense,
suspenseId: suspense ? suspense.pendingId : 0,
asyncDep: null,
asyncResolved: false,
// lifecycle hooks
// not using enums here because it results in computed properties
isMounted: false,
isUnmounted: false,
isDeactivated: false,
bc: null,
c: null,
bm: null,
m: null,
bu: null,
u: null,
um: null,
bum: null,
da: null,
a: null,
rtg: null,
rtc: null,
ec: null,
sp: null
};
{
instance.ctx = { _: instance };
}
instance.root = parent ? parent.root : instance;
instance.emit = emit.bind(null, instance);
if (vnode.ce) {
vnode.ce(instance);
}
return instance;
}
let currentInstance = null;
const getCurrentInstance = () => currentInstance || currentRenderingInstance;
let internalSetCurrentInstance;
let setInSSRSetupState;
{
const g2 = getGlobalThis();
const registerGlobalSetter = (key2, setter) => {
let setters;
if (!(setters = g2[key2])) setters = g2[key2] = [];
setters.push(setter);
return (v2) => {
if (setters.length > 1) setters.forEach((set2) => set2(v2));
else setters[0](v2);
};
};
internalSetCurrentInstance = registerGlobalSetter(
`__VUE_INSTANCE_SETTERS__`,
(v2) => currentInstance = v2
);
setInSSRSetupState = registerGlobalSetter(
`__VUE_SSR_SETTERS__`,
(v2) => isInSSRComponentSetup = v2
);
}
const setCurrentInstance = (instance) => {
const prev = currentInstance;
internalSetCurrentInstance(instance);
instance.scope.on();
return () => {
instance.scope.off();
internalSetCurrentInstance(prev);
};
};
const unsetCurrentInstance = () => {
currentInstance && currentInstance.scope.off();
internalSetCurrentInstance(null);
};
function isStatefulComponent(instance) {
return instance.vnode.shapeFlag & 4;
}
let isInSSRComponentSetup = false;
function setupComponent(instance, isSSR = false, optimized = false) {
isSSR && setInSSRSetupState(isSSR);
const { props, children } = instance.vnode;
const isStateful = isStatefulComponent(instance);
initProps(instance, props, isStateful, isSSR);
initSlots(instance, children, optimized);
const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
isSSR && setInSSRSetupState(false);
return setupResult;
}
function setupStatefulComponent(instance, isSSR) {
const Component = instance.type;
instance.accessCache = /* @__PURE__ */ Object.create(null);
instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
const { setup } = Component;
if (setup) {
pauseTracking();
const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
const reset = setCurrentInstance(instance);
const setupResult = callWithErrorHandling(
setup,
instance,
0,
[
instance.props,
setupContext
]
);
const isAsyncSetup = isPromise(setupResult);
resetTracking();
reset();
if ((isAsyncSetup || instance.sp) && !isAsyncWrapper(instance)) {
markAsyncBoundary(instance);
}
if (isAsyncSetup) {
setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
if (isSSR) {
return setupResult.then((resolvedResult) => {
handleSetupResult(instance, resolvedResult, isSSR);
}).catch((e2) => {
handleError(e2, instance, 0);
});
} else {
instance.asyncDep = setupResult;
}
} else {
handleSetupResult(instance, setupResult, isSSR);
}
} else {
finishComponentSetup(instance, isSSR);
}
}
function handleSetupResult(instance, setupResult, isSSR) {
if (isFunction(setupResult)) {
if (instance.type.__ssrInlineRender) {
instance.ssrRender = setupResult;
} else {
instance.render = setupResult;
}
} else if (isObject$2(setupResult)) {
instance.setupState = proxyRefs(setupResult);
} else ;
finishComponentSetup(instance, isSSR);
}
let compile;
function finishComponentSetup(instance, isSSR, skipOptions) {
const Component = instance.type;
if (!instance.render) {
if (!isSSR && compile && !Component.render) {
const template = Component.template || resolveMergedOptions(instance).template;
if (template) {
const { isCustomElement, compilerOptions } = instance.appContext.config;
const { delimiters, compilerOptions: componentCompilerOptions } = Component;
const finalCompilerOptions = extend$3(
extend$3(
{
isCustomElement,
delimiters
},
compilerOptions
),
componentCompilerOptions
);
Component.render = compile(template, finalCompilerOptions);
}
}
instance.render = Component.render || NOOP;
}
{
const reset = setCurrentInstance(instance);
pauseTracking();
try {
applyOptions(instance);
} finally {
resetTracking();
reset();
}
}
}
const attrsProxyHandlers = {
get(target, key2) {
track(target, "get", "");
return target[key2];
}
};
function createSetupContext(instance) {
const expose = (exposed) => {
instance.exposed = exposed || {};
};
{
return {
attrs: new Proxy(instance.attrs, attrsProxyHandlers),
slots: instance.slots,
emit: instance.emit,
expose
};
}
}
function getComponentPublicInstance(instance) {
if (instance.exposed) {
return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
get(target, key2) {
if (key2 in target) {
return target[key2];
} else if (key2 in publicPropertiesMap) {
return publicPropertiesMap[key2](instance);
}
},
has(target, key2) {
return key2 in target || key2 in publicPropertiesMap;
}
}));
} else {
return instance.proxy;
}
}
const classifyRE = /(?:^|[-_])(\w)/g;
const classify = (str) => str.replace(classifyRE, (c2) => c2.toUpperCase()).replace(/[-_]/g, "");
function getComponentName(Component, includeInferred = true) {
return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
}
function formatComponentName(instance, Component, isRoot = false) {
let name2 = getComponentName(Component);
if (!name2 && Component.__file) {
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
if (match) {
name2 = match[1];
}
}
if (!name2 && instance && instance.parent) {
const inferFromRegistry = (registry) => {
for (const key2 in registry) {
if (registry[key2] === Component) {
return key2;
}
}
};
name2 = inferFromRegistry(
instance.components || instance.parent.type.components
) || inferFromRegistry(instance.appContext.components);
}
return name2 ? classify(name2) : isRoot ? `App` : `Anonymous`;
}
function isClassComponent(value) {
return isFunction(value) && "__vccOpts" in value;
}
const computed = (getterOrOptions, debugOptions) => {
const c2 = computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
return c2;
};
function h$9(type2, propsOrChildren, children) {
const l2 = arguments.length;
if (l2 === 2) {
if (isObject$2(propsOrChildren) && !isArray$3(propsOrChildren)) {
if (isVNode(propsOrChildren)) {
return createVNode(type2, null, [propsOrChildren]);
}
return createVNode(type2, propsOrChildren);
} else {
return createVNode(type2, null, propsOrChildren);
}
} else {
if (l2 > 3) {
children = Array.prototype.slice.call(arguments, 2);
} else if (l2 === 3 && isVNode(children)) {
children = [children];
}
return createVNode(type2, propsOrChildren, children);
}
}
const version$1 = "3.5.12";
/**
* @vue/runtime-dom v3.5.12
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
let policy = void 0;
const tt = typeof window !== "undefined" && window.trustedTypes;
if (tt) {
try {
policy = /* @__PURE__ */ tt.createPolicy("vue", {
createHTML: (val) => val
});
} catch (e2) {
}
}
const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
const svgNS = "http://www.w3.org/2000/svg";
const mathmlNS = "http://www.w3.org/1998/Math/MathML";
const doc$1 = typeof document !== "undefined" ? document : null;
const templateContainer = doc$1 && /* @__PURE__ */ doc$1.createElement("template");
const nodeOps = {
insert: (child, parent, anchor) => {
parent.insertBefore(child, anchor || null);
},
remove: (child) => {
const parent = child.parentNode;
if (parent) {
parent.removeChild(child);
}
},
createElement: (tag, namespace, is, props) => {
const el = namespace === "svg" ? doc$1.createElementNS(svgNS, tag) : namespace === "mathml" ? doc$1.createElementNS(mathmlNS, tag) : is ? doc$1.createElement(tag, { is }) : doc$1.createElement(tag);
if (tag === "select" && props && props.multiple != null) {
el.setAttribute("multiple", props.multiple);
}
return el;
},
createText: (text2) => doc$1.createTextNode(text2),
createComment: (text2) => doc$1.createComment(text2),
setText: (node, text2) => {
node.nodeValue = text2;
},
setElementText: (el, text2) => {
el.textContent = text2;
},
parentNode: (node) => node.parentNode,
nextSibling: (node) => node.nextSibling,
querySelector: (selector) => doc$1.querySelector(selector),
setScopeId(el, id2) {
el.setAttribute(id2, "");
},
// __UNSAFE__
// Reason: innerHTML.
// Static content here can only come from compiled templates.
// As long as the user only uses trusted templates, this is safe.
insertStaticContent(content2, parent, anchor, namespace, start, end) {
const before = anchor ? anchor.previousSibling : parent.lastChild;
if (start && (start === end || start.nextSibling)) {
while (true) {
parent.insertBefore(start.cloneNode(true), anchor);
if (start === end || !(start = start.nextSibling)) break;
}
} else {
templateContainer.innerHTML = unsafeToTrustedHTML(
namespace === "svg" ? `<svg>${content2}</svg>` : namespace === "mathml" ? `<math>${content2}</math>` : content2
);
const template = templateContainer.content;
if (namespace === "svg" || namespace === "mathml") {
const wrapper = template.firstChild;
while (wrapper.firstChild) {
template.appendChild(wrapper.firstChild);
}
template.removeChild(wrapper);
}
parent.insertBefore(template, anchor);
}
return [
// first
before ? before.nextSibling : parent.firstChild,
// last
anchor ? anchor.previousSibling : parent.lastChild
];
}
};
const TRANSITION = "transition";
const ANIMATION = "animation";
const vtcKey = Symbol("_vtc");
const DOMTransitionPropsValidators = {
name: String,
type: String,
css: {
type: Boolean,
default: true
},
duration: [String, Number, Object],
enterFromClass: String,
enterActiveClass: String,
enterToClass: String,
appearFromClass: String,
appearActiveClass: String,
appearToClass: String,
leaveFromClass: String,
leaveActiveClass: String,
leaveToClass: String
};
const TransitionPropsValidators = /* @__PURE__ */ extend$3(
{},
BaseTransitionPropsValidators,
DOMTransitionPropsValidators
);
const decorate$1 = (t2) => {
t2.displayName = "Transition";
t2.props = TransitionPropsValidators;
return t2;
};
const Transition = /* @__PURE__ */ decorate$1(
(props, { slots }) => h$9(BaseTransition, resolveTransitionProps(props), slots)
);
const callHook = (hook, args = []) => {
if (isArray$3(hook)) {
hook.forEach((h2) => h2(...args));
} else if (hook) {
hook(...args);
}
};
const hasExplicitCallback = (hook) => {
return hook ? isArray$3(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
};
function resolveTransitionProps(rawProps) {
const baseProps = {};
for (const key2 in rawProps) {
if (!(key2 in DOMTransitionPropsValidators)) {
baseProps[key2] = rawProps[key2];
}
}
if (rawProps.css === false) {
return baseProps;
}
const {
name: name2 = "v",
type: type2,
duration,
enterFromClass = `${name2}-enter-from`,
enterActiveClass = `${name2}-enter-active`,
enterToClass = `${name2}-enter-to`,
appearFromClass = enterFromClass,
appearActiveClass = enterActiveClass,
appearToClass = enterToClass,
leaveFromClass = `${name2}-leave-from`,
leaveActiveClass = `${name2}-leave-active`,
leaveToClass = `${name2}-leave-to`
} = rawProps;
const durations = normalizeDuration(duration);
const enterDuration = durations && durations[0];
const leaveDuration = durations && durations[1];
const {
onBeforeEnter,
onEnter,
onEnterCancelled,
onLeave,
onLeaveCancelled,
onBeforeAppear = onBeforeEnter,
onAppear = onEnter,
onAppearCancelled = onEnterCancelled
} = baseProps;
const finishEnter = (el, isAppear, done) => {
removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
done && done();
};
const finishLeave = (el, done) => {
el._isLeaving = false;
removeTransitionClass(el, leaveFromClass);
removeTransitionClass(el, leaveToClass);
removeTransitionClass(el, leaveActiveClass);
done && done();
};
const makeEnterHook = (isAppear) => {
return (el, done) => {
const hook = isAppear ? onAppear : onEnter;
const resolve2 = () => finishEnter(el, isAppear, done);
callHook(hook, [el, resolve2]);
nextFrame(() => {
removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
addTransitionClass(el, isAppear ? appearToClass : enterToClass);
if (!hasExplicitCallback(hook)) {
whenTransitionEnds(el, type2, enterDuration, resolve2);
}
});
};
};
return extend$3(baseProps, {
onBeforeEnter(el) {
callHook(onBeforeEnter, [el]);
addTransitionClass(el, enterFromClass);
addTransitionClass(el, enterActiveClass);
},
onBeforeAppear(el) {
callHook(onBeforeAppear, [el]);
addTransitionClass(el, appearFromClass);
addTransitionClass(el, appearActiveClass);
},
onEnter: makeEnterHook(false),
onAppear: makeEnterHook(true),
onLeave(el, done) {
el._isLeaving = true;
const resolve2 = () => finishLeave(el, done);
addTransitionClass(el, leaveFromClass);
addTransitionClass(el, leaveActiveClass);
forceReflow();
nextFrame(() => {
if (!el._isLeaving) {
return;
}
removeTransitionClass(el, leaveFromClass);
addTransitionClass(el, leaveToClass);
if (!hasExplicitCallback(onLeave)) {
whenTransitionEnds(el, type2, leaveDuration, resolve2);
}
});
callHook(onLeave, [el, resolve2]);
},
onEnterCancelled(el) {
finishEnter(el, false);
callHook(onEnterCancelled, [el]);
},
onAppearCancelled(el) {
finishEnter(el, true);
callHook(onAppearCancelled, [el]);
},
onLeaveCancelled(el) {
finishLeave(el);
callHook(onLeaveCancelled, [el]);
}
});
}
function normalizeDuration(duration) {
if (duration == null) {
return null;
} else if (isObject$2(duration)) {
return [NumberOf(duration.enter), NumberOf(duration.leave)];
} else {
const n2 = NumberOf(duration);
return [n2, n2];
}
}
function NumberOf(val) {
const res = toNumber(val);
return res;
}
function addTransitionClass(el, cls) {
cls.split(/\s+/).forEach((c2) => c2 && el.classList.add(c2));
(el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
}
function removeTransitionClass(el, cls) {
cls.split(/\s+/).forEach((c2) => c2 && el.classList.remove(c2));
const _vtc = el[vtcKey];
if (_vtc) {
_vtc.delete(cls);
if (!_vtc.size) {
el[vtcKey] = void 0;
}
}
}
function nextFrame(cb) {
requestAnimationFrame(() => {
requestAnimationFrame(cb);
});
}
let endId = 0;
function whenTransitionEnds(el, expectedType, explicitTimeout, resolve2) {
const id2 = el._endId = ++endId;
const resolveIfNotStale = () => {
if (id2 === el._endId) {
resolve2();
}
};
if (explicitTimeout != null) {
return setTimeout(resolveIfNotStale, explicitTimeout);
}
const { type: type2, timeout, propCount } = getTransitionInfo(el, expectedType);
if (!type2) {
return resolve2();
}
const endEvent = type2 + "end";
let ended = 0;
const end = () => {
el.removeEventListener(endEvent, onEnd);
resolveIfNotStale();
};
const onEnd = (e2) => {
if (e2.target === el && ++ended >= propCount) {
end();
}
};
setTimeout(() => {
if (ended < propCount) {
end();
}
}, timeout + 1);
el.addEventListener(endEvent, onEnd);
}
function getTransitionInfo(el, expectedType) {
const styles = window.getComputedStyle(el);
const getStyleProperties = (key2) => (styles[key2] || "").split(", ");
const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
const animationTimeout = getTimeout(animationDelays, animationDurations);
let type2 = null;
let timeout = 0;
let propCount = 0;
if (expectedType === TRANSITION) {
if (transitionTimeout > 0) {
type2 = TRANSITION;
timeout = transitionTimeout;
propCount = transitionDurations.length;
}
} else if (expectedType === ANIMATION) {
if (animationTimeout > 0) {
type2 = ANIMATION;
timeout = animationTimeout;
propCount = animationDurations.length;
}
} else {
timeout = Math.max(transitionTimeout, animationTimeout);
type2 = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
propCount = type2 ? type2 === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
}
const hasTransform = type2 === TRANSITION && /\b(transform|all)(,|$)/.test(
getStyleProperties(`${TRANSITION}Property`).toString()
);
return {
type: type2,
timeout,
propCount,
hasTransform
};
}
function getTimeout(delays, durations) {
while (delays.length < durations.length) {
delays = delays.concat(delays);
}
return Math.max(...durations.map((d2, i2) => toMs(d2) + toMs(delays[i2])));
}
function toMs(s3) {
if (s3 === "auto") return 0;
return Number(s3.slice(0, -1).replace(",", ".")) * 1e3;
}
function forceReflow() {
return document.body.offsetHeight;
}
function patchClass(el, value, isSVG) {
const transitionClasses = el[vtcKey];
if (transitionClasses) {
value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
}
if (value == null) {
el.removeAttribute("class");
} else if (isSVG) {
el.setAttribute("class", value);
} else {
el.className = value;
}
}
const vShowOriginalDisplay = Symbol("_vod");
const vShowHidden = Symbol("_vsh");
const vShow = {
beforeMount(el, { value }, { transition }) {
el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
if (transition && value) {
transition.beforeEnter(el);
} else {
setDisplay(el, value);
}
},
mounted(el, { value }, { transition }) {
if (transition && value) {
transition.enter(el);
}
},
updated(el, { value, oldValue }, { transition }) {
if (!value === !oldValue) return;
if (transition) {
if (value) {
transition.beforeEnter(el);
setDisplay(el, true);
transition.enter(el);
} else {
transition.leave(el, () => {
setDisplay(el, false);
});
}
} else {
setDisplay(el, value);
}
},
beforeUnmount(el, { value }) {
setDisplay(el, value);
}
};
function setDisplay(el, value) {
el.style.display = value ? el[vShowOriginalDisplay] : "none";
el[vShowHidden] = !value;
}
const CSS_VAR_TEXT = Symbol("");
function useCssVars(getter) {
const instance = getCurrentInstance();
if (!instance) {
return;
}
const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
Array.from(
document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
).forEach((node) => setVarsOnNode(node, vars));
};
const setVars = () => {
const vars = getter(instance.proxy);
if (instance.ce) {
setVarsOnNode(instance.ce, vars);
} else {
setVarsOnVNode(instance.subTree, vars);
}
updateTeleports(vars);
};
onBeforeMount(() => {
watchPostEffect(setVars);
});
onMounted(() => {
const ob = new MutationObserver(setVars);
ob.observe(instance.subTree.el.parentNode, { childList: true });
onUnmounted(() => ob.disconnect());
});
}
function setVarsOnVNode(vnode, vars) {
if (vnode.shapeFlag & 128) {
const suspense = vnode.suspense;
vnode = suspense.activeBranch;
if (suspense.pendingBranch && !suspense.isHydrating) {
suspense.effects.push(() => {
setVarsOnVNode(suspense.activeBranch, vars);
});
}
}
while (vnode.component) {
vnode = vnode.component.subTree;
}
if (vnode.shapeFlag & 1 && vnode.el) {
setVarsOnNode(vnode.el, vars);
} else if (vnode.type === Fragment) {
vnode.children.forEach((c2) => setVarsOnVNode(c2, vars));
} else if (vnode.type === Static) {
let { el, anchor } = vnode;
while (el) {
setVarsOnNode(el, vars);
if (el === anchor) break;
el = el.nextSibling;
}
}
}
function setVarsOnNode(el, vars) {
if (el.nodeType === 1) {
const style2 = el.style;
let cssText = "";
for (const key2 in vars) {
style2.setProperty(`--${key2}`, vars[key2]);
cssText += `--${key2}: ${vars[key2]};`;
}
style2[CSS_VAR_TEXT] = cssText;
}
}
const displayRE = /(^|;)\s*display\s*:/;
function patchStyle(el, prev, next) {
const style2 = el.style;
const isCssString = isString$1(next);
let hasControlledDisplay = false;
if (next && !isCssString) {
if (prev) {
if (!isString$1(prev)) {
for (const key2 in prev) {
if (next[key2] == null) {
setStyle(style2, key2, "");
}
}
} else {
for (const prevStyle of prev.split(";")) {
const key2 = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
if (next[key2] == null) {
setStyle(style2, key2, "");
}
}
}
}
for (const key2 in next) {
if (key2 === "display") {
hasControlledDisplay = true;
}
setStyle(style2, key2, next[key2]);
}
} else {
if (isCssString) {
if (prev !== next) {
const cssVarText = style2[CSS_VAR_TEXT];
if (cssVarText) {
next += ";" + cssVarText;
}
style2.cssText = next;
hasControlledDisplay = displayRE.test(next);
}
} else if (prev) {
el.removeAttribute("style");
}
}
if (vShowOriginalDisplay in el) {
el[vShowOriginalDisplay] = hasControlledDisplay ? style2.display : "";
if (el[vShowHidden]) {
style2.display = "none";
}
}
}
const importantRE = /\s*!important$/;
function setStyle(style2, name2, val) {
if (isArray$3(val)) {
val.forEach((v2) => setStyle(style2, name2, v2));
} else {
if (val == null) val = "";
if (name2.startsWith("--")) {
style2.setProperty(name2, val);
} else {
const prefixed = autoPrefix(style2, name2);
if (importantRE.test(val)) {
style2.setProperty(
hyphenate(prefixed),
val.replace(importantRE, ""),
"important"
);
} else {
style2[prefixed] = val;
}
}
}
}
const prefixes = ["Webkit", "Moz", "ms"];
const prefixCache = {};
function autoPrefix(style2, rawName) {
const cached = prefixCache[rawName];
if (cached) {
return cached;
}
let name2 = camelize(rawName);
if (name2 !== "filter" && name2 in style2) {
return prefixCache[rawName] = name2;
}
name2 = capitalize$1(name2);
for (let i2 = 0; i2 < prefixes.length; i2++) {
const prefixed = prefixes[i2] + name2;
if (prefixed in style2) {
return prefixCache[rawName] = prefixed;
}
}
return rawName;
}
const xlinkNS = "http://www.w3.org/1999/xlink";
function patchAttr(el, key2, value, isSVG, instance, isBoolean2 = isSpecialBooleanAttr(key2)) {
if (isSVG && key2.startsWith("xlink:")) {
if (value == null) {
el.removeAttributeNS(xlinkNS, key2.slice(6, key2.length));
} else {
el.setAttributeNS(xlinkNS, key2, value);
}
} else {
if (value == null || isBoolean2 && !includeBooleanAttr(value)) {
el.removeAttribute(key2);
} else {
el.setAttribute(
key2,
isBoolean2 ? "" : isSymbol(value) ? String(value) : value
);
}
}
}
function patchDOMProp(el, key2, value, parentComponent, attrName2) {
if (key2 === "innerHTML" || key2 === "textContent") {
if (value != null) {
el[key2] = key2 === "innerHTML" ? unsafeToTrustedHTML(value) : value;
}
return;
}
const tag = el.tagName;
if (key2 === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
!tag.includes("-")) {
const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
const newValue = value == null ? (
// #11647: value should be set as empty string for null and undefined,
// but <input type="checkbox"> should be set as 'on'.
el.type === "checkbox" ? "on" : ""
) : String(value);
if (oldValue !== newValue || !("_value" in el)) {
el.value = newValue;
}
if (value == null) {
el.removeAttribute(key2);
}
el._value = value;
return;
}
let needRemove = false;
if (value === "" || value == null) {
const type2 = typeof el[key2];
if (type2 === "boolean") {
value = includeBooleanAttr(value);
} else if (value == null && type2 === "string") {
value = "";
needRemove = true;
} else if (type2 === "number") {
value = 0;
needRemove = true;
}
}
try {
el[key2] = value;
} catch (e2) {
}
needRemove && el.removeAttribute(attrName2 || key2);
}
function addEventListener(el, event, handler, options) {
el.addEventListener(event, handler, options);
}
function removeEventListener(el, event, handler, options) {
el.removeEventListener(event, handler, options);
}
const veiKey = Symbol("_vei");
function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
const invokers = el[veiKey] || (el[veiKey] = {});
const existingInvoker = invokers[rawName];
if (nextValue && existingInvoker) {
existingInvoker.value = nextValue;
} else {
const [name2, options] = parseName(rawName);
if (nextValue) {
const invoker = invokers[rawName] = createInvoker(
nextValue,
instance
);
addEventListener(el, name2, invoker, options);
} else if (existingInvoker) {
removeEventListener(el, name2, existingInvoker, options);
invokers[rawName] = void 0;
}
}
}
const optionsModifierRE = /(?:Once|Passive|Capture)$/;
function parseName(name2) {
let options;
if (optionsModifierRE.test(name2)) {
options = {};
let m2;
while (m2 = name2.match(optionsModifierRE)) {
name2 = name2.slice(0, name2.length - m2[0].length);
options[m2[0].toLowerCase()] = true;
}
}
const event = name2[2] === ":" ? name2.slice(3) : hyphenate(name2.slice(2));
return [event, options];
}
let cachedNow = 0;
const p$7 = /* @__PURE__ */ Promise.resolve();
const getNow = () => cachedNow || (p$7.then(() => cachedNow = 0), cachedNow = Date.now());
function createInvoker(initialValue, instance) {
const invoker = (e2) => {
if (!e2._vts) {
e2._vts = Date.now();
} else if (e2._vts <= invoker.attached) {
return;
}
callWithAsyncErrorHandling(
patchStopImmediatePropagation(e2, invoker.value),
instance,
5,
[e2]
);
};
invoker.value = initialValue;
invoker.attached = getNow();
return invoker;
}
function patchStopImmediatePropagation(e2, value) {
if (isArray$3(value)) {
const originalStop = e2.stopImmediatePropagation;
e2.stopImmediatePropagation = () => {
originalStop.call(e2);
e2._stopped = true;
};
return value.map(
(fn) => (e22) => !e22._stopped && fn && fn(e22)
);
} else {
return value;
}
}
const isNativeOn = (key2) => key2.charCodeAt(0) === 111 && key2.charCodeAt(1) === 110 && // lowercase letter
key2.charCodeAt(2) > 96 && key2.charCodeAt(2) < 123;
const patchProp = (el, key2, prevValue, nextValue, namespace, parentComponent) => {
const isSVG = namespace === "svg";
if (key2 === "class") {
patchClass(el, nextValue, isSVG);
} else if (key2 === "style") {
patchStyle(el, prevValue, nextValue);
} else if (isOn(key2)) {
if (!isModelListener(key2)) {
patchEvent(el, key2, prevValue, nextValue, parentComponent);
}
} else if (key2[0] === "." ? (key2 = key2.slice(1), true) : key2[0] === "^" ? (key2 = key2.slice(1), false) : shouldSetAsProp(el, key2, nextValue, isSVG)) {
patchDOMProp(el, key2, nextValue);
if (!el.tagName.includes("-") && (key2 === "value" || key2 === "checked" || key2 === "selected")) {
patchAttr(el, key2, nextValue, isSVG, parentComponent, key2 !== "value");
}
} else if (
// #11081 force set props for possible async custom element
el._isVueCE && (/[A-Z]/.test(key2) || !isString$1(nextValue))
) {
patchDOMProp(el, camelize(key2), nextValue, parentComponent, key2);
} else {
if (key2 === "true-value") {
el._trueValue = nextValue;
} else if (key2 === "false-value") {
el._falseValue = nextValue;
}
patchAttr(el, key2, nextValue, isSVG);
}
};
function shouldSetAsProp(el, key2, value, isSVG) {
if (isSVG) {
if (key2 === "innerHTML" || key2 === "textContent") {
return true;
}
if (key2 in el && isNativeOn(key2) && isFunction(value)) {
return true;
}
return false;
}
if (key2 === "spellcheck" || key2 === "draggable" || key2 === "translate") {
return false;
}
if (key2 === "form") {
return false;
}
if (key2 === "list" && el.tagName === "INPUT") {
return false;
}
if (key2 === "type" && el.tagName === "TEXTAREA") {
return false;
}
if (key2 === "width" || key2 === "height") {
const tag = el.tagName;
if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
return false;
}
}
if (isNativeOn(key2) && isString$1(value)) {
return false;
}
return key2 in el;
}
const getModelAssigner = (vnode) => {
const fn = vnode.props["onUpdate:modelValue"] || false;
return isArray$3(fn) ? (value) => invokeArrayFns(fn, value) : fn;
};
function onCompositionStart(e2) {
e2.target.composing = true;
}
function onCompositionEnd(e2) {
const target = e2.target;
if (target.composing) {
target.composing = false;
target.dispatchEvent(new Event("input"));
}
}
const assignKey = Symbol("_assign");
const vModelText = {
created(el, { modifiers: { lazy, trim, number: number2 } }, vnode) {
el[assignKey] = getModelAssigner(vnode);
const castToNumber = number2 || vnode.props && vnode.props.type === "number";
addEventListener(el, lazy ? "change" : "input", (e2) => {
if (e2.target.composing) return;
let domValue = el.value;
if (trim) {
domValue = domValue.trim();
}
if (castToNumber) {
domValue = looseToNumber(domValue);
}
el[assignKey](domValue);
});
if (trim) {
addEventListener(el, "change", () => {
el.value = el.value.trim();
});
}
if (!lazy) {
addEventListener(el, "compositionstart", onCompositionStart);
addEventListener(el, "compositionend", onCompositionEnd);
addEventListener(el, "change", onCompositionEnd);
}
},
// set value on mounted so it's after min/max for type="range"
mounted(el, { value }) {
el.value = value == null ? "" : value;
},
beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number: number2 } }, vnode) {
el[assignKey] = getModelAssigner(vnode);
if (el.composing) return;
const elValue = (number2 || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
const newValue = value == null ? "" : value;
if (elValue === newValue) {
return;
}
if (document.activeElement === el && el.type !== "range") {
if (lazy && value === oldValue) {
return;
}
if (trim && el.value.trim() === newValue) {
return;
}
}
el.value = newValue;
}
};
const systemModifiers = ["ctrl", "shift", "alt", "meta"];
const modifierGuards = {
stop: (e2) => e2.stopPropagation(),
prevent: (e2) => e2.preventDefault(),
self: (e2) => e2.target !== e2.currentTarget,
ctrl: (e2) => !e2.ctrlKey,
shift: (e2) => !e2.shiftKey,
alt: (e2) => !e2.altKey,
meta: (e2) => !e2.metaKey,
left: (e2) => "button" in e2 && e2.button !== 0,
middle: (e2) => "button" in e2 && e2.button !== 1,
right: (e2) => "button" in e2 && e2.button !== 2,
exact: (e2, modifiers2) => systemModifiers.some((m2) => e2[`${m2}Key`] && !modifiers2.includes(m2))
};
const withModifiers = (fn, modifiers2) => {
const cache2 = fn._withMods || (fn._withMods = {});
const cacheKey = modifiers2.join(".");
return cache2[cacheKey] || (cache2[cacheKey] = (event, ...args) => {
for (let i2 = 0; i2 < modifiers2.length; i2++) {
const guard = modifierGuards[modifiers2[i2]];
if (guard && guard(event, modifiers2)) return;
}
return fn(event, ...args);
});
};
const keyNames = {
esc: "escape",
space: " ",
up: "arrow-up",
left: "arrow-left",
right: "arrow-right",
down: "arrow-down",
delete: "backspace"
};
const withKeys = (fn, modifiers2) => {
const cache2 = fn._withKeys || (fn._withKeys = {});
const cacheKey = modifiers2.join(".");
return cache2[cacheKey] || (cache2[cacheKey] = (event) => {
if (!("key" in event)) {
return;
}
const eventKey = hyphenate(event.key);
if (modifiers2.some(
(k2) => k2 === eventKey || keyNames[k2] === eventKey
)) {
return fn(event);
}
});
};
const rendererOptions = /* @__PURE__ */ extend$3({ patchProp }, nodeOps);
let renderer;
function ensureRenderer() {
return renderer || (renderer = createRenderer(rendererOptions));
}
const render = (...args) => {
ensureRenderer().render(...args);
};
const createApp = (...args) => {
const app = ensureRenderer().createApp(...args);
const { mount } = app;
app.mount = (containerOrSelector) => {
const container = normalizeContainer(containerOrSelector);
if (!container) return;
const component = app._component;
if (!isFunction(component) && !component.render && !component.template) {
component.template = container.innerHTML;
}
if (container.nodeType === 1) {
container.textContent = "";
}
const proxy = mount(container, false, resolveRootNamespace(container));
if (container instanceof Element) {
container.removeAttribute("v-cloak");
container.setAttribute("data-v-app", "");
}
return proxy;
};
return app;
};
function resolveRootNamespace(container) {
if (container instanceof SVGElement) {
return "svg";
}
if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
return "mathml";
}
}
function normalizeContainer(container) {
if (isString$1(container)) {
const res = document.querySelector(container);
return res;
}
return container;
}
var util;
(function(util2) {
util2.assertEqual = (val) => val;
function assertIs(_arg) {
}
util2.assertIs = assertIs;
function assertNever(_x) {
throw new Error();
}
util2.assertNever = assertNever;
util2.arrayToEnum = (items) => {
const obj = {};
for (const item of items) {
obj[item] = item;
}
return obj;
};
util2.getValidEnumValues = (obj) => {
const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number");
const filtered = {};
for (const k2 of validKeys) {
filtered[k2] = obj[k2];
}
return util2.objectValues(filtered);
};
util2.objectValues = (obj) => {
return util2.objectKeys(obj).map(function(e2) {
return obj[e2];
});
};
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object2) => {
const keys2 = [];
for (const key2 in object2) {
if (Object.prototype.hasOwnProperty.call(object2, key2)) {
keys2.push(key2);
}
}
return keys2;
};
util2.find = (arr, checker) => {
for (const item of arr) {
if (checker(item))
return item;
}
return void 0;
};
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
function joinValues(array, separator = " | ") {
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
}
util2.joinValues = joinValues;
util2.jsonStringifyReplacer = (_2, value) => {
if (typeof value === "bigint") {
return value.toString();
}
return value;
};
})(util || (util = {}));
var objectUtil;
(function(objectUtil2) {
objectUtil2.mergeShapes = (first, second) => {
return {
...first,
...second
// second overwrites first
};
};
})(objectUtil || (objectUtil = {}));
const ZodParsedType = util.arrayToEnum([
"string",
"nan",
"number",
"integer",
"float",
"boolean",
"date",
"bigint",
"symbol",
"function",
"undefined",
"null",
"array",
"object",
"unknown",
"promise",
"void",
"never",
"map",
"set"
]);
const getParsedType = (data) => {
const t2 = typeof data;
switch (t2) {
case "undefined":
return ZodParsedType.undefined;
case "string":
return ZodParsedType.string;
case "number":
return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
case "boolean":
return ZodParsedType.boolean;
case "function":
return ZodParsedType.function;
case "bigint":
return ZodParsedType.bigint;
case "symbol":
return ZodParsedType.symbol;
case "object":
if (Array.isArray(data)) {
return ZodParsedType.array;
}
if (data === null) {
return ZodParsedType.null;
}
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
return ZodParsedType.promise;
}
if (typeof Map !== "undefined" && data instanceof Map) {
return ZodParsedType.map;
}
if (typeof Set !== "undefined" && data instanceof Set) {
return ZodParsedType.set;
}
if (typeof Date !== "undefined" && data instanceof Date) {
return ZodParsedType.date;
}
return ZodParsedType.object;
default:
return ZodParsedType.unknown;
}
};
const ZodIssueCode = util.arrayToEnum([
"invalid_type",
"invalid_literal",
"custom",
"invalid_union",
"invalid_union_discriminator",
"invalid_enum_value",
"unrecognized_keys",
"invalid_arguments",
"invalid_return_type",
"invalid_date",
"invalid_string",
"too_small",
"too_big",
"invalid_intersection_types",
"not_multiple_of",
"not_finite"
]);
const quotelessJson = (obj) => {
const json2 = JSON.stringify(obj, null, 2);
return json2.replace(/"([^"]+)":/g, "$1:");
};
class ZodError extends Error {
constructor(issues) {
super();
this.issues = [];
this.addIssue = (sub) => {
this.issues = [...this.issues, sub];
};
this.addIssues = (subs = []) => {
this.issues = [...this.issues, ...subs];
};
const actualProto = new.target.prototype;
if (Object.setPrototypeOf) {
Object.setPrototypeOf(this, actualProto);
} else {
this.__proto__ = actualProto;
}
this.name = "ZodError";
this.issues = issues;
}
get errors() {
return this.issues;
}
format(_mapper) {
const mapper = _mapper || function(issue) {
return issue.message;
};
const fieldErrors = { _errors: [] };
const processError = (error2) => {
for (const issue of error2.issues) {
if (issue.code === "invalid_union") {
issue.unionErrors.map(processError);
} else if (issue.code === "invalid_return_type") {
processError(issue.returnTypeError);
} else if (issue.code === "invalid_arguments") {
processError(issue.argumentsError);
} else if (issue.path.length === 0) {
fieldErrors._errors.push(mapper(issue));
} else {
let curr = fieldErrors;
let i2 = 0;
while (i2 < issue.path.length) {
const el = issue.path[i2];
const terminal = i2 === issue.path.length - 1;
if (!terminal) {
curr[el] = curr[el] || { _errors: [] };
} else {
curr[el] = curr[el] || { _errors: [] };
curr[el]._errors.push(mapper(issue));
}
curr = curr[el];
i2++;
}
}
}
};
processError(this);
return fieldErrors;
}
static assert(value) {
if (!(value instanceof ZodError)) {
throw new Error(`Not a ZodError: ${value}`);
}
}
toString() {
return this.message;
}
get message() {
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
}
get isEmpty() {
return this.issues.length === 0;
}
flatten(mapper = (issue) => issue.message) {
const fieldErrors = {};
const formErrors = [];
for (const sub of this.issues) {
if (sub.path.length > 0) {
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
fieldErrors[sub.path[0]].push(mapper(sub));
} else {
formErrors.push(mapper(sub));
}
}
return { formErrors, fieldErrors };
}
get formErrors() {
return this.flatten();
}
}
ZodError.create = (issues) => {
const error2 = new ZodError(issues);
return error2;
};
const errorMap = (issue, _ctx) => {
let message;
switch (issue.code) {
case ZodIssueCode.invalid_type:
if (issue.received === ZodParsedType.undefined) {
message = "Required";
} else {
message = `Expected ${issue.expected}, received ${issue.received}`;
}
break;
case ZodIssueCode.invalid_literal:
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
break;
case ZodIssueCode.unrecognized_keys:
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
break;
case ZodIssueCode.invalid_union:
message = `Invalid input`;
break;
case ZodIssueCode.invalid_union_discriminator:
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
break;
case ZodIssueCode.invalid_enum_value:
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
break;
case ZodIssueCode.invalid_arguments:
message = `Invalid function arguments`;
break;
case ZodIssueCode.invalid_return_type:
message = `Invalid function return type`;
break;
case ZodIssueCode.invalid_date:
message = `Invalid date`;
break;
case ZodIssueCode.invalid_string:
if (typeof issue.validation === "object") {
if ("includes" in issue.validation) {
message = `Invalid input: must include "${issue.validation.includes}"`;
if (typeof issue.validation.position === "number") {
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
}
} else if ("startsWith" in issue.validation) {
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
} else if ("endsWith" in issue.validation) {
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
} else {
util.assertNever(issue.validation);
}
} else if (issue.validation !== "regex") {
message = `Invalid ${issue.validation}`;
} else {
message = "Invalid";
}
break;
case ZodIssueCode.too_small:
if (issue.type === "array")
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
else if (issue.type === "string")
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
else if (issue.type === "number")
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
else if (issue.type === "date")
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
else
message = "Invalid input";
break;
case ZodIssueCode.too_big:
if (issue.type === "array")
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
else if (issue.type === "string")
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
else if (issue.type === "number")
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
else if (issue.type === "bigint")
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
else if (issue.type === "date")
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
else
message = "Invalid input";
break;
case ZodIssueCode.custom:
message = `Invalid input`;
break;
case ZodIssueCode.invalid_intersection_types:
message = `Intersection results could not be merged`;
break;
case ZodIssueCode.not_multiple_of:
message = `Number must be a multiple of ${issue.multipleOf}`;
break;
case ZodIssueCode.not_finite:
message = "Number must be finite";
break;
default:
message = _ctx.defaultError;
util.assertNever(issue);
}
return { message };
};
let overrideErrorMap = errorMap;
function setErrorMap(map2) {
overrideErrorMap = map2;
}
function getErrorMap() {
return overrideErrorMap;
}
const makeIssue = (params) => {
const { data, path: path2, errorMaps, issueData } = params;
const fullPath = [...path2, ...issueData.path || []];
const fullIssue = {
...issueData,
path: fullPath
};
if (issueData.message !== void 0) {
return {
...issueData,
path: fullPath,
message: issueData.message
};
}
let errorMessage = "";
const maps = errorMaps.filter((m2) => !!m2).slice().reverse();
for (const map2 of maps) {
errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
}
return {
...issueData,
path: fullPath,
message: errorMessage
};
};
const EMPTY_PATH = [];
function addIssueToContext(ctx, issueData) {
const overrideMap = getErrorMap();
const issue = makeIssue({
issueData,
data: ctx.data,
path: ctx.path,
errorMaps: [
ctx.common.contextualErrorMap,
ctx.schemaErrorMap,
overrideMap,
overrideMap === errorMap ? void 0 : errorMap
// then global default map
].filter((x2) => !!x2)
});
ctx.common.issues.push(issue);
}
class ParseStatus {
constructor() {
this.value = "valid";
}
dirty() {
if (this.value === "valid")
this.value = "dirty";
}
abort() {
if (this.value !== "aborted")
this.value = "aborted";
}
static mergeArray(status, results) {
const arrayValue = [];
for (const s3 of results) {
if (s3.status === "aborted")
return INVALID;
if (s3.status === "dirty")
status.dirty();
arrayValue.push(s3.value);
}
return { status: status.value, value: arrayValue };
}
static async mergeObjectAsync(status, pairs2) {
const syncPairs = [];
for (const pair2 of pairs2) {
const key2 = await pair2.key;
const value = await pair2.value;
syncPairs.push({
key: key2,
value
});
}
return ParseStatus.mergeObjectSync(status, syncPairs);
}
static mergeObjectSync(status, pairs2) {
const finalObject = {};
for (const pair2 of pairs2) {
const { key: key2, value } = pair2;
if (key2.status === "aborted")
return INVALID;
if (value.status === "aborted")
return INVALID;
if (key2.status === "dirty")
status.dirty();
if (value.status === "dirty")
status.dirty();
if (key2.value !== "__proto__" && (typeof value.value !== "undefined" || pair2.alwaysSet)) {
finalObject[key2.value] = value.value;
}
}
return { status: status.value, value: finalObject };
}
}
const INVALID = Object.freeze({
status: "aborted"
});
const DIRTY = (value) => ({ status: "dirty", value });
const OK = (value) => ({ status: "valid", value });
const isAborted = (x2) => x2.status === "aborted";
const isDirty = (x2) => x2.status === "dirty";
const isValid = (x2) => x2.status === "valid";
const isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
function __classPrivateFieldGet(receiver, state, kind, f2) {
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return state.get(receiver);
}
function __classPrivateFieldSet(receiver, state, value, kind, f2) {
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return state.set(receiver, value), value;
}
typeof SuppressedError === "function" ? SuppressedError : function(error2, suppressed, message) {
var e2 = new Error(message);
return e2.name = "SuppressedError", e2.error = error2, e2.suppressed = suppressed, e2;
};
var errorUtil;
(function(errorUtil2) {
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
})(errorUtil || (errorUtil = {}));
var _ZodEnum_cache, _ZodNativeEnum_cache;
class ParseInputLazyPath {
constructor(parent, value, path2, key2) {
this._cachedPath = [];
this.parent = parent;
this.data = value;
this._path = path2;
this._key = key2;
}
get path() {
if (!this._cachedPath.length) {
if (this._key instanceof Array) {
this._cachedPath.push(...this._path, ...this._key);
} else {
this._cachedPath.push(...this._path, this._key);
}
}
return this._cachedPath;
}
}
const handleResult = (ctx, result) => {
if (isValid(result)) {
return { success: true, data: result.value };
} else {
if (!ctx.common.issues.length) {
throw new Error("Validation failed but no issues detected.");
}
return {
success: false,
get error() {
if (this._error)
return this._error;
const error2 = new ZodError(ctx.common.issues);
this._error = error2;
return this._error;
}
};
}
};
function processCreateParams(params) {
if (!params)
return {};
const { errorMap: errorMap2, invalid_type_error, required_error, description: description2 } = params;
if (errorMap2 && (invalid_type_error || required_error)) {
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
}
if (errorMap2)
return { errorMap: errorMap2, description: description2 };
const customMap = (iss, ctx) => {
var _a2, _b;
const { message } = params;
if (iss.code === "invalid_enum_value") {
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
}
if (typeof ctx.data === "undefined") {
return { message: (_a2 = message !== null && message !== void 0 ? message : required_error) !== null && _a2 !== void 0 ? _a2 : ctx.defaultError };
}
if (iss.code !== "invalid_type")
return { message: ctx.defaultError };
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
};
return { errorMap: customMap, description: description2 };
}
class ZodType {
constructor(def2) {
this.spa = this.safeParseAsync;
this._def = def2;
this.parse = this.parse.bind(this);
this.safeParse = this.safeParse.bind(this);
this.parseAsync = this.parseAsync.bind(this);
this.safeParseAsync = this.safeParseAsync.bind(this);
this.spa = this.spa.bind(this);
this.refine = this.refine.bind(this);
this.refinement = this.refinement.bind(this);
this.superRefine = this.superRefine.bind(this);
this.optional = this.optional.bind(this);
this.nullable = this.nullable.bind(this);
this.nullish = this.nullish.bind(this);
this.array = this.array.bind(this);
this.promise = this.promise.bind(this);
this.or = this.or.bind(this);
this.and = this.and.bind(this);
this.transform = this.transform.bind(this);
this.brand = this.brand.bind(this);
this.default = this.default.bind(this);
this.catch = this.catch.bind(this);
this.describe = this.describe.bind(this);
this.pipe = this.pipe.bind(this);
this.readonly = this.readonly.bind(this);
this.isNullable = this.isNullable.bind(this);
this.isOptional = this.isOptional.bind(this);
}
get description() {
return this._def.description;
}
_getType(input) {
return getParsedType(input.data);
}
_getOrReturnCtx(input, ctx) {
return ctx || {
common: input.parent.common,
data: input.data,
parsedType: getParsedType(input.data),
schemaErrorMap: this._def.errorMap,
path: input.path,
parent: input.parent
};
}
_processInputParams(input) {
return {
status: new ParseStatus(),
ctx: {
common: input.parent.common,
data: input.data,
parsedType: getParsedType(input.data),
schemaErrorMap: this._def.errorMap,
path: input.path,
parent: input.parent
}
};
}
_parseSync(input) {
const result = this._parse(input);
if (isAsync(result)) {
throw new Error("Synchronous parse encountered promise.");
}
return result;
}
_parseAsync(input) {
const result = this._parse(input);
return Promise.resolve(result);
}
parse(data, params) {
const result = this.safeParse(data, params);
if (result.success)
return result.data;
throw result.error;
}
safeParse(data, params) {
var _a2;
const ctx = {
common: {
issues: [],
async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false,
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
},
path: (params === null || params === void 0 ? void 0 : params.path) || [],
schemaErrorMap: this._def.errorMap,
parent: null,
data,
parsedType: getParsedType(data)
};
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
return handleResult(ctx, result);
}
async parseAsync(data, params) {
const result = await this.safeParseAsync(data, params);
if (result.success)
return result.data;
throw result.error;
}
async safeParseAsync(data, params) {
const ctx = {
common: {
issues: [],
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
async: true
},
path: (params === null || params === void 0 ? void 0 : params.path) || [],
schemaErrorMap: this._def.errorMap,
parent: null,
data,
parsedType: getParsedType(data)
};
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
return handleResult(ctx, result);
}
refine(check, message) {
const getIssueProperties = (val) => {
if (typeof message === "string" || typeof message === "undefined") {
return { message };
} else if (typeof message === "function") {
return message(val);
} else {
return message;
}
};
return this._refinement((val, ctx) => {
const result = check(val);
const setError = () => ctx.addIssue({
code: ZodIssueCode.custom,
...getIssueProperties(val)
});
if (typeof Promise !== "undefined" && result instanceof Promise) {
return result.then((data) => {
if (!data) {
setError();
return false;
} else {
return true;
}
});
}
if (!result) {
setError();
return false;
} else {
return true;
}
});
}
refinement(check, refinementData) {
return this._refinement((val, ctx) => {
if (!check(val)) {
ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
return false;
} else {
return true;
}
});
}
_refinement(refinement) {
return new ZodEffects({
schema: this,
typeName: ZodFirstPartyTypeKind.ZodEffects,
effect: { type: "refinement", refinement }
});
}
superRefine(refinement) {
return this._refinement(refinement);
}
optional() {
return ZodOptional.create(this, this._def);
}
nullable() {
return ZodNullable.create(this, this._def);
}
nullish() {
return this.nullable().optional();
}
array() {
return ZodArray.create(this, this._def);
}
promise() {
return ZodPromise.create(this, this._def);
}
or(option2) {
return ZodUnion.create([this, option2], this._def);
}
and(incoming) {
return ZodIntersection.create(this, incoming, this._def);
}
transform(transform) {
return new ZodEffects({
...processCreateParams(this._def),
schema: this,
typeName: ZodFirstPartyTypeKind.ZodEffects,
effect: { type: "transform", transform }
});
}
default(def2) {
const defaultValueFunc = typeof def2 === "function" ? def2 : () => def2;
return new ZodDefault({
...processCreateParams(this._def),
innerType: this,
defaultValue: defaultValueFunc,
typeName: ZodFirstPartyTypeKind.ZodDefault
});
}
brand() {
return new ZodBranded({
typeName: ZodFirstPartyTypeKind.ZodBranded,
type: this,
...processCreateParams(this._def)
});
}
catch(def2) {
const catchValueFunc = typeof def2 === "function" ? def2 : () => def2;
return new ZodCatch({
...processCreateParams(this._def),
innerType: this,
catchValue: catchValueFunc,
typeName: ZodFirstPartyTypeKind.ZodCatch
});
}
describe(description2) {
const This = this.constructor;
return new This({
...this._def,
description: description2
});
}
pipe(target) {
return ZodPipeline.create(this, target);
}
readonly() {
return ZodReadonly.create(this);
}
isOptional() {
return this.safeParse(void 0).success;
}
isNullable() {
return this.safeParse(null).success;
}
}
const cuidRegex = /^c[^\s-]{8,}$/i;
const cuid2Regex = /^[0-9a-z]+$/;
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
const nanoidRegex = /^[a-z0-9_-]{21}$/i;
const durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
let emojiRegex;
const ipv4Regex = /^(?:(?: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])$/;
const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
const dateRegexSource = `((\\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])))`;
const dateRegex = new RegExp(`^${dateRegexSource}$`);
function timeRegexSource(args) {
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
if (args.precision) {
regex = `${regex}\\.\\d{${args.precision}}`;
} else if (args.precision == null) {
regex = `${regex}(\\.\\d+)?`;
}
return regex;
}
function timeRegex(args) {
return new RegExp(`^${timeRegexSource(args)}$`);
}
function datetimeRegex(args) {
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
const opts = [];
opts.push(args.local ? `Z?` : `Z`);
if (args.offset)
opts.push(`([+-]\\d{2}:?\\d{2})`);
regex = `${regex}(${opts.join("|")})`;
return new RegExp(`^${regex}$`);
}
function isValidIP(ip, version2) {
if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
return true;
}
if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) {
return true;
}
return false;
}
class ZodString extends ZodType {
_parse(input) {
if (this._def.coerce) {
input.data = String(input.data);
}
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.string) {
const ctx2 = this._getOrReturnCtx(input);
addIssueToContext(ctx2, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.string,
received: ctx2.parsedType
});
return INVALID;
}
const status = new ParseStatus();
let ctx = void 0;
for (const check of this._def.checks) {
if (check.kind === "min") {
if (input.data.length < check.value) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.too_small,
minimum: check.value,
type: "string",
inclusive: true,
exact: false,
message: check.message
});
status.dirty();
}
} else if (check.kind === "max") {
if (input.data.length > check.value) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.too_big,
maximum: check.value,
type: "string",
inclusive: true,
exact: false,
message: check.message
});
status.dirty();
}
} else if (check.kind === "length") {
const tooBig = input.data.length > check.value;
const tooSmall = input.data.length < check.value;
if (tooBig || tooSmall) {
ctx = this._getOrReturnCtx(input, ctx);
if (tooBig) {
addIssueToContext(ctx, {
code: ZodIssueCode.too_big,
maximum: check.value,
type: "string",
inclusive: true,
exact: true,
message: check.message
});
} else if (tooSmall) {
addIssueToContext(ctx, {
code: ZodIssueCode.too_small,
minimum: check.value,
type: "string",
inclusive: true,
exact: true,
message: check.message
});
}
status.dirty();
}
} else if (check.kind === "email") {
if (!emailRegex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "email",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "emoji") {
if (!emojiRegex) {
emojiRegex = new RegExp(_emojiRegex, "u");
}
if (!emojiRegex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "emoji",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "uuid") {
if (!uuidRegex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "uuid",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "nanoid") {
if (!nanoidRegex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "nanoid",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "cuid") {
if (!cuidRegex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "cuid",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "cuid2") {
if (!cuid2Regex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "cuid2",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "ulid") {
if (!ulidRegex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "ulid",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "url") {
try {
new URL(input.data);
} catch (_a2) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "url",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "regex") {
check.regex.lastIndex = 0;
const testResult = check.regex.test(input.data);
if (!testResult) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "regex",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "trim") {
input.data = input.data.trim();
} else if (check.kind === "includes") {
if (!input.data.includes(check.value, check.position)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_string,
validation: { includes: check.value, position: check.position },
message: check.message
});
status.dirty();
}
} else if (check.kind === "toLowerCase") {
input.data = input.data.toLowerCase();
} else if (check.kind === "toUpperCase") {
input.data = input.data.toUpperCase();
} else if (check.kind === "startsWith") {
if (!input.data.startsWith(check.value)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_string,
validation: { startsWith: check.value },
message: check.message
});
status.dirty();
}
} else if (check.kind === "endsWith") {
if (!input.data.endsWith(check.value)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_string,
validation: { endsWith: check.value },
message: check.message
});
status.dirty();
}
} else if (check.kind === "datetime") {
const regex = datetimeRegex(check);
if (!regex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_string,
validation: "datetime",
message: check.message
});
status.dirty();
}
} else if (check.kind === "date") {
const regex = dateRegex;
if (!regex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_string,
validation: "date",
message: check.message
});
status.dirty();
}
} else if (check.kind === "time") {
const regex = timeRegex(check);
if (!regex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_string,
validation: "time",
message: check.message
});
status.dirty();
}
} else if (check.kind === "duration") {
if (!durationRegex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "duration",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "ip") {
if (!isValidIP(input.data, check.version)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "ip",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else if (check.kind === "base64") {
if (!base64Regex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
validation: "base64",
code: ZodIssueCode.invalid_string,
message: check.message
});
status.dirty();
}
} else {
util.assertNever(check);
}
}
return { status: status.value, value: input.data };
}
_regex(regex, validation, message) {
return this.refinement((data) => regex.test(data), {
validation,
code: ZodIssueCode.invalid_string,
...errorUtil.errToObj(message)
});
}
_addCheck(check) {
return new ZodString({
...this._def,
checks: [...this._def.checks, check]
});
}
email(message) {
return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
}
url(message) {
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
}
emoji(message) {
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
}
uuid(message) {
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
}
nanoid(message) {
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
}
cuid(message) {
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
}
cuid2(message) {
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
}
ulid(message) {
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
}
base64(message) {
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
}
ip(options) {
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
}
datetime(options) {
var _a2, _b;
if (typeof options === "string") {
return this._addCheck({
kind: "datetime",
precision: null,
offset: false,
local: false,
message: options
});
}
return this._addCheck({
kind: "datetime",
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false,
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
});
}
date(message) {
return this._addCheck({ kind: "date", message });
}
time(options) {
if (typeof options === "string") {
return this._addCheck({
kind: "time",
precision: null,
message: options
});
}
return this._addCheck({
kind: "time",
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
});
}
duration(message) {
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
}
regex(regex, message) {
return this._addCheck({
kind: "regex",
regex,
...errorUtil.errToObj(message)
});
}
includes(value, options) {
return this._addCheck({
kind: "includes",
value,
position: options === null || options === void 0 ? void 0 : options.position,
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
});
}
startsWith(value, message) {
return this._addCheck({
kind: "startsWith",
value,
...errorUtil.errToObj(message)
});
}
endsWith(value, message) {
return this._addCheck({
kind: "endsWith",
value,
...errorUtil.errToObj(message)
});
}
min(minLength, message) {
return this._addCheck({
kind: "min",
value: minLength,
...errorUtil.errToObj(message)
});
}
max(maxLength, message) {
return this._addCheck({
kind: "max",
value: maxLength,
...errorUtil.errToObj(message)
});
}
length(len, message) {
return this._addCheck({
kind: "length",
value: len,
...errorUtil.errToObj(message)
});
}
/**
* @deprecated Use z.string().min(1) instead.
* @see {@link ZodString.min}
*/
nonempty(message) {
return this.min(1, errorUtil.errToObj(message));
}
trim() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "trim" }]
});
}
toLowerCase() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toLowerCase" }]
});
}
toUpperCase() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toUpperCase" }]
});
}
get isDatetime() {
return !!this._def.checks.find((ch) => ch.kind === "datetime");
}
get isDate() {
return !!this._def.checks.find((ch) => ch.kind === "date");
}
get isTime() {
return !!this._def.checks.find((ch) => ch.kind === "time");
}
get isDuration() {
return !!this._def.checks.find((ch) => ch.kind === "duration");
}
get isEmail() {
return !!this._def.checks.find((ch) => ch.kind === "email");
}
get isURL() {
return !!this._def.checks.find((ch) => ch.kind === "url");
}
get isEmoji() {
return !!this._def.checks.find((ch) => ch.kind === "emoji");
}
get isUUID() {
return !!this._def.checks.find((ch) => ch.kind === "uuid");
}
get isNANOID() {
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
}
get isCUID() {
return !!this._def.checks.find((ch) => ch.kind === "cuid");
}
get isCUID2() {
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
}
get isULID() {
return !!this._def.checks.find((ch) => ch.kind === "ulid");
}
get isIP() {
return !!this._def.checks.find((ch) => ch.kind === "ip");
}
get isBase64() {
return !!this._def.checks.find((ch) => ch.kind === "base64");
}
get minLength() {
let min2 = null;
for (const ch of this._def.checks) {
if (ch.kind === "min") {
if (min2 === null || ch.value > min2)
min2 = ch.value;
}
}
return min2;
}
get maxLength() {
let max2 = null;
for (const ch of this._def.checks) {
if (ch.kind === "max") {
if (max2 === null || ch.value < max2)
max2 = ch.value;
}
}
return max2;
}
}
ZodString.create = (params) => {
var _a2;
return new ZodString({
checks: [],
typeName: ZodFirstPartyTypeKind.ZodString,
coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false,
...processCreateParams(params)
});
};
function floatSafeRemainder(val, step) {
const valDecCount = (val.toString().split(".")[1] || "").length;
const stepDecCount = (step.toString().split(".")[1] || "").length;
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
return valInt % stepInt / Math.pow(10, decCount);
}
class ZodNumber extends ZodType {
constructor() {
super(...arguments);
this.min = this.gte;
this.max = this.lte;
this.step = this.multipleOf;
}
_parse(input) {
if (this._def.coerce) {
input.data = Number(input.data);
}
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.number) {
const ctx2 = this._getOrReturnCtx(input);
addIssueToContext(ctx2, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.number,
received: ctx2.parsedType
});
return INVALID;
}
let ctx = void 0;
const status = new ParseStatus();
for (const check of this._def.checks) {
if (check.kind === "int") {
if (!util.isInteger(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: "integer",
received: "float",
message: check.message
});
status.dirty();
}
} else if (check.kind === "min") {
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
if (tooSmall) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.too_small,
minimum: check.value,
type: "number",
inclusive: check.inclusive,
exact: false,
message: check.message
});
status.dirty();
}
} else if (check.kind === "max") {
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
if (tooBig) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.too_big,
maximum: check.value,
type: "number",
inclusive: check.inclusive,
exact: false,
message: check.message
});
status.dirty();
}
} else if (check.kind === "multipleOf") {
if (floatSafeRemainder(input.data, check.value) !== 0) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.not_multiple_of,
multipleOf: check.value,
message: check.message
});
status.dirty();
}
} else if (check.kind === "finite") {
if (!Number.isFinite(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.not_finite,
message: check.message
});
status.dirty();
}
} else {
util.assertNever(check);
}
}
return { status: status.value, value: input.data };
}
gte(value, message) {
return this.setLimit("min", value, true, errorUtil.toString(message));
}
gt(value, message) {
return this.setLimit("min", value, false, errorUtil.toString(message));
}
lte(value, message) {
return this.setLimit("max", value, true, errorUtil.toString(message));
}
lt(value, message) {
return this.setLimit("max", value, false, errorUtil.toString(message));
}
setLimit(kind, value, inclusive, message) {
return new ZodNumber({
...this._def,
checks: [
...this._def.checks,
{
kind,
value,
inclusive,
message: errorUtil.toString(message)
}
]
});
}
_addCheck(check) {
return new ZodNumber({
...this._def,
checks: [...this._def.checks, check]
});
}
int(message) {
return this._addCheck({
kind: "int",
message: errorUtil.toString(message)
});
}
positive(message) {
return this._addCheck({
kind: "min",
value: 0,
inclusive: false,
message: errorUtil.toString(message)
});
}
negative(message) {
return this._addCheck({
kind: "max",
value: 0,
inclusive: false,
message: errorUtil.toString(message)
});
}
nonpositive(message) {
return this._addCheck({
kind: "max",
value: 0,
inclusive: true,
message: errorUtil.toString(message)
});
}
nonnegative(message) {
return this._addCheck({
kind: "min",
value: 0,
inclusive: true,
message: errorUtil.toString(message)
});
}
multipleOf(value, message) {
return this._addCheck({
kind: "multipleOf",
value,
message: errorUtil.toString(message)
});
}
finite(message) {
return this._addCheck({
kind: "finite",
message: errorUtil.toString(message)
});
}
safe(message) {
return this._addCheck({
kind: "min",
inclusive: true,
value: Number.MIN_SAFE_INTEGER,
message: errorUtil.toString(message)
})._addCheck({
kind: "max",
inclusive: true,
value: Number.MAX_SAFE_INTEGER,
message: errorUtil.toString(message)
});
}
get minValue() {
let min2 = null;
for (const ch of this._def.checks) {
if (ch.kind === "min") {
if (min2 === null || ch.value > min2)
min2 = ch.value;
}
}
return min2;
}
get maxValue() {
let max2 = null;
for (const ch of this._def.checks) {
if (ch.kind === "max") {
if (max2 === null || ch.value < max2)
max2 = ch.value;
}
}
return max2;
}
get isInt() {
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
}
get isFinite() {
let max2 = null, min2 = null;
for (const ch of this._def.checks) {
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
return true;
} else if (ch.kind === "min") {
if (min2 === null || ch.value > min2)
min2 = ch.value;
} else if (ch.kind === "max") {
if (max2 === null || ch.value < max2)
max2 = ch.value;
}
}
return Number.isFinite(min2) && Number.isFinite(max2);
}
}
ZodNumber.create = (params) => {
return new ZodNumber({
checks: [],
typeName: ZodFirstPartyTypeKind.ZodNumber,
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
...processCreateParams(params)
});
};
class ZodBigInt extends ZodType {
constructor() {
super(...arguments);
this.min = this.gte;
this.max = this.lte;
}
_parse(input) {
if (this._def.coerce) {
input.data = BigInt(input.data);
}
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.bigint) {
const ctx2 = this._getOrReturnCtx(input);
addIssueToContext(ctx2, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.bigint,
received: ctx2.parsedType
});
return INVALID;
}
let ctx = void 0;
const status = new ParseStatus();
for (const check of this._def.checks) {
if (check.kind === "min") {
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
if (tooSmall) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.too_small,
type: "bigint",
minimum: check.value,
inclusive: check.inclusive,
message: check.message
});
status.dirty();
}
} else if (check.kind === "max") {
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
if (tooBig) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.too_big,
type: "bigint",
maximum: check.value,
inclusive: check.inclusive,
message: check.message
});
status.dirty();
}
} else if (check.kind === "multipleOf") {
if (input.data % check.value !== BigInt(0)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.not_multiple_of,
multipleOf: check.value,
message: check.message
});
status.dirty();
}
} else {
util.assertNever(check);
}
}
return { status: status.value, value: input.data };
}
gte(value, message) {
return this.setLimit("min", value, true, errorUtil.toString(message));
}
gt(value, message) {
return this.setLimit("min", value, false, errorUtil.toString(message));
}
lte(value, message) {
return this.setLimit("max", value, true, errorUtil.toString(message));
}
lt(value, message) {
return this.setLimit("max", value, false, errorUtil.toString(message));
}
setLimit(kind, value, inclusive, message) {
return new ZodBigInt({
...this._def,
checks: [
...this._def.checks,
{
kind,
value,
inclusive,
message: errorUtil.toString(message)
}
]
});
}
_addCheck(check) {
return new ZodBigInt({
...this._def,
checks: [...this._def.checks, check]
});
}
positive(message) {
return this._addCheck({
kind: "min",
value: BigInt(0),
inclusive: false,
message: errorUtil.toString(message)
});
}
negative(message) {
return this._addCheck({
kind: "max",
value: BigInt(0),
inclusive: false,
message: errorUtil.toString(message)
});
}
nonpositive(message) {
return this._addCheck({
kind: "max",
value: BigInt(0),
inclusive: true,
message: errorUtil.toString(message)
});
}
nonnegative(message) {
return this._addCheck({
kind: "min",
value: BigInt(0),
inclusive: true,
message: errorUtil.toString(message)
});
}
multipleOf(value, message) {
return this._addCheck({
kind: "multipleOf",
value,
message: errorUtil.toString(message)
});
}
get minValue() {
let min2 = null;
for (const ch of this._def.checks) {
if (ch.kind === "min") {
if (min2 === null || ch.value > min2)
min2 = ch.value;
}
}
return min2;
}
get maxValue() {
let max2 = null;
for (const ch of this._def.checks) {
if (ch.kind === "max") {
if (max2 === null || ch.value < max2)
max2 = ch.value;
}
}
return max2;
}
}
ZodBigInt.create = (params) => {
var _a2;
return new ZodBigInt({
checks: [],
typeName: ZodFirstPartyTypeKind.ZodBigInt,
coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false,
...processCreateParams(params)
});
};
class ZodBoolean extends ZodType {
_parse(input) {
if (this._def.coerce) {
input.data = Boolean(input.data);
}
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.boolean) {
const ctx = this._getOrReturnCtx(input);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.boolean,
received: ctx.parsedType
});
return INVALID;
}
return OK(input.data);
}
}
ZodBoolean.create = (params) => {
return new ZodBoolean({
typeName: ZodFirstPartyTypeKind.ZodBoolean,
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
...processCreateParams(params)
});
};
class ZodDate extends ZodType {
_parse(input) {
if (this._def.coerce) {
input.data = new Date(input.data);
}
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.date) {
const ctx2 = this._getOrReturnCtx(input);
addIssueToContext(ctx2, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.date,
received: ctx2.parsedType
});
return INVALID;
}
if (isNaN(input.data.getTime())) {
const ctx2 = this._getOrReturnCtx(input);
addIssueToContext(ctx2, {
code: ZodIssueCode.invalid_date
});
return INVALID;
}
const status = new ParseStatus();
let ctx = void 0;
for (const check of this._def.checks) {
if (check.kind === "min") {
if (input.data.getTime() < check.value) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.too_small,
message: check.message,
inclusive: true,
exact: false,
minimum: check.value,
type: "date"
});
status.dirty();
}
} else if (check.kind === "max") {
if (input.data.getTime() > check.value) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
code: ZodIssueCode.too_big,
message: check.message,
inclusive: true,
exact: false,
maximum: check.value,
type: "date"
});
status.dirty();
}
} else {
util.assertNever(check);
}
}
return {
status: status.value,
value: new Date(input.data.getTime())
};
}
_addCheck(check) {
return new ZodDate({
...this._def,
checks: [...this._def.checks, check]
});
}
min(minDate, message) {
return this._addCheck({
kind: "min",
value: minDate.getTime(),
message: errorUtil.toString(message)
});
}
max(maxDate, message) {
return this._addCheck({
kind: "max",
value: maxDate.getTime(),
message: errorUtil.toString(message)
});
}
get minDate() {
let min2 = null;
for (const ch of this._def.checks) {
if (ch.kind === "min") {
if (min2 === null || ch.value > min2)
min2 = ch.value;
}
}
return min2 != null ? new Date(min2) : null;
}
get maxDate() {
let max2 = null;
for (const ch of this._def.checks) {
if (ch.kind === "max") {
if (max2 === null || ch.value < max2)
max2 = ch.value;
}
}
return max2 != null ? new Date(max2) : null;
}
}
ZodDate.create = (params) => {
return new ZodDate({
checks: [],
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
typeName: ZodFirstPartyTypeKind.ZodDate,
...processCreateParams(params)
});
};
class ZodSymbol extends ZodType {
_parse(input) {
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.symbol) {
const ctx = this._getOrReturnCtx(input);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.symbol,
received: ctx.parsedType
});
return INVALID;
}
return OK(input.data);
}
}
ZodSymbol.create = (params) => {
return new ZodSymbol({
typeName: ZodFirstPartyTypeKind.ZodSymbol,
...processCreateParams(params)
});
};
class ZodUndefined extends ZodType {
_parse(input) {
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.undefined) {
const ctx = this._getOrReturnCtx(input);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.undefined,
received: ctx.parsedType
});
return INVALID;
}
return OK(input.data);
}
}
ZodUndefined.create = (params) => {
return new ZodUndefined({
typeName: ZodFirstPartyTypeKind.ZodUndefined,
...processCreateParams(params)
});
};
class ZodNull extends ZodType {
_parse(input) {
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.null) {
const ctx = this._getOrReturnCtx(input);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.null,
received: ctx.parsedType
});
return INVALID;
}
return OK(input.data);
}
}
ZodNull.create = (params) => {
return new ZodNull({
typeName: ZodFirstPartyTypeKind.ZodNull,
...processCreateParams(params)
});
};
class ZodAny extends ZodType {
constructor() {
super(...arguments);
this._any = true;
}
_parse(input) {
return OK(input.data);
}
}
ZodAny.create = (params) => {
return new ZodAny({
typeName: ZodFirstPartyTypeKind.ZodAny,
...processCreateParams(params)
});
};
class ZodUnknown extends ZodType {
constructor() {
super(...arguments);
this._unknown = true;
}
_parse(input) {
return OK(input.data);
}
}
ZodUnknown.create = (params) => {
return new ZodUnknown({
typeName: ZodFirstPartyTypeKind.ZodUnknown,
...processCreateParams(params)
});
};
class ZodNever extends ZodType {
_parse(input) {
const ctx = this._getOrReturnCtx(input);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.never,
received: ctx.parsedType
});
return INVALID;
}
}
ZodNever.create = (params) => {
return new ZodNever({
typeName: ZodFirstPartyTypeKind.ZodNever,
...processCreateParams(params)
});
};
class ZodVoid extends ZodType {
_parse(input) {
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.undefined) {
const ctx = this._getOrReturnCtx(input);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.void,
received: ctx.parsedType
});
return INVALID;
}
return OK(input.data);
}
}
ZodVoid.create = (params) => {
return new ZodVoid({
typeName: ZodFirstPartyTypeKind.ZodVoid,
...processCreateParams(params)
});
};
class ZodArray extends ZodType {
_parse(input) {
const { ctx, status } = this._processInputParams(input);
const def2 = this._def;
if (ctx.parsedType !== ZodParsedType.array) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.array,
received: ctx.parsedType
});
return INVALID;
}
if (def2.exactLength !== null) {
const tooBig = ctx.data.length > def2.exactLength.value;
const tooSmall = ctx.data.length < def2.exactLength.value;
if (tooBig || tooSmall) {
addIssueToContext(ctx, {
code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
minimum: tooSmall ? def2.exactLength.value : void 0,
maximum: tooBig ? def2.exactLength.value : void 0,
type: "array",
inclusive: true,
exact: true,
message: def2.exactLength.message
});
status.dirty();
}
}
if (def2.minLength !== null) {
if (ctx.data.length < def2.minLength.value) {
addIssueToContext(ctx, {
code: ZodIssueCode.too_small,
minimum: def2.minLength.value,
type: "array",
inclusive: true,
exact: false,
message: def2.minLength.message
});
status.dirty();
}
}
if (def2.maxLength !== null) {
if (ctx.data.length > def2.maxLength.value) {
addIssueToContext(ctx, {
code: ZodIssueCode.too_big,
maximum: def2.maxLength.value,
type: "array",
inclusive: true,
exact: false,
message: def2.maxLength.message
});
status.dirty();
}
}
if (ctx.common.async) {
return Promise.all([...ctx.data].map((item, i2) => {
return def2.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2));
})).then((result2) => {
return ParseStatus.mergeArray(status, result2);
});
}
const result = [...ctx.data].map((item, i2) => {
return def2.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2));
});
return ParseStatus.mergeArray(status, result);
}
get element() {
return this._def.type;
}
min(minLength, message) {
return new ZodArray({
...this._def,
minLength: { value: minLength, message: errorUtil.toString(message) }
});
}
max(maxLength, message) {
return new ZodArray({
...this._def,
maxLength: { value: maxLength, message: errorUtil.toString(message) }
});
}
length(len, message) {
return new ZodArray({
...this._def,
exactLength: { value: len, message: errorUtil.toString(message) }
});
}
nonempty(message) {
return this.min(1, message);
}
}
ZodArray.create = (schema2, params) => {
return new ZodArray({
type: schema2,
minLength: null,
maxLength: null,
exactLength: null,
typeName: ZodFirstPartyTypeKind.ZodArray,
...processCreateParams(params)
});
};
function deepPartialify(schema2) {
if (schema2 instanceof ZodObject) {
const newShape = {};
for (const key2 in schema2.shape) {
const fieldSchema = schema2.shape[key2];
newShape[key2] = ZodOptional.create(deepPartialify(fieldSchema));
}
return new ZodObject({
...schema2._def,
shape: () => newShape
});
} else if (schema2 instanceof ZodArray) {
return new ZodArray({
...schema2._def,
type: deepPartialify(schema2.element)
});
} else if (schema2 instanceof ZodOptional) {
return ZodOptional.create(deepPartialify(schema2.unwrap()));
} else if (schema2 instanceof ZodNullable) {
return ZodNullable.create(deepPartialify(schema2.unwrap()));
} else if (schema2 instanceof ZodTuple) {
return ZodTuple.create(schema2.items.map((item) => deepPartialify(item)));
} else {
return schema2;
}
}
class ZodObject extends ZodType {
constructor() {
super(...arguments);
this._cached = null;
this.nonstrict = this.passthrough;
this.augment = this.extend;
}
_getCached() {
if (this._cached !== null)
return this._cached;
const shape = this._def.shape();
const keys2 = util.objectKeys(shape);
return this._cached = { shape, keys: keys2 };
}
_parse(input) {
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.object) {
const ctx2 = this._getOrReturnCtx(input);
addIssueToContext(ctx2, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.object,
received: ctx2.parsedType
});
return INVALID;
}
const { status, ctx } = this._processInputParams(input);
const { shape, keys: shapeKeys } = this._getCached();
const extraKeys = [];
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
for (const key2 in ctx.data) {
if (!shapeKeys.includes(key2)) {
extraKeys.push(key2);
}
}
}
const pairs2 = [];
for (const key2 of shapeKeys) {
const keyValidator = shape[key2];
const value = ctx.data[key2];
pairs2.push({
key: { status: "valid", value: key2 },
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key2)),
alwaysSet: key2 in ctx.data
});
}
if (this._def.catchall instanceof ZodNever) {
const unknownKeys = this._def.unknownKeys;
if (unknownKeys === "passthrough") {
for (const key2 of extraKeys) {
pairs2.push({
key: { status: "valid", value: key2 },
value: { status: "valid", value: ctx.data[key2] }
});
}
} else if (unknownKeys === "strict") {
if (extraKeys.length > 0) {
addIssueToContext(ctx, {
code: ZodIssueCode.unrecognized_keys,
keys: extraKeys
});
status.dirty();
}
} else if (unknownKeys === "strip") ;
else {
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
}
} else {
const catchall = this._def.catchall;
for (const key2 of extraKeys) {
const value = ctx.data[key2];
pairs2.push({
key: { status: "valid", value: key2 },
value: catchall._parse(
new ParseInputLazyPath(ctx, value, ctx.path, key2)
//, ctx.child(key), value, getParsedType(value)
),
alwaysSet: key2 in ctx.data
});
}
}
if (ctx.common.async) {
return Promise.resolve().then(async () => {
const syncPairs = [];
for (const pair2 of pairs2) {
const key2 = await pair2.key;
const value = await pair2.value;
syncPairs.push({
key: key2,
value,
alwaysSet: pair2.alwaysSet
});
}
return syncPairs;
}).then((syncPairs) => {
return ParseStatus.mergeObjectSync(status, syncPairs);
});
} else {
return ParseStatus.mergeObjectSync(status, pairs2);
}
}
get shape() {
return this._def.shape();
}
strict(message) {
errorUtil.errToObj;
return new ZodObject({
...this._def,
unknownKeys: "strict",
...message !== void 0 ? {
errorMap: (issue, ctx) => {
var _a2, _b, _c, _d;
const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
if (issue.code === "unrecognized_keys")
return {
message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
};
return {
message: defaultError
};
}
} : {}
});
}
strip() {
return new ZodObject({
...this._def,
unknownKeys: "strip"
});
}
passthrough() {
return new ZodObject({
...this._def,
unknownKeys: "passthrough"
});
}
// const AugmentFactory =
// <Def extends ZodObjectDef>(def: Def) =>
// <Augmentation extends ZodRawShape>(
// augmentation: Augmentation
// ): ZodObject<
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
// Def["unknownKeys"],
// Def["catchall"]
// > => {
// return new ZodObject({
// ...def,
// shape: () => ({
// ...def.shape(),
// ...augmentation,
// }),
// }) as any;
// };
extend(augmentation) {
return new ZodObject({
...this._def,
shape: () => ({
...this._def.shape(),
...augmentation
})
});
}
/**
* Prior to [email protected] there was a bug in the
* inferred type of merged objects. Please
* upgrade if you are experiencing issues.
*/
merge(merging) {
const merged = new ZodObject({
unknownKeys: merging._def.unknownKeys,
catchall: merging._def.catchall,
shape: () => ({
...this._def.shape(),
...merging._def.shape()
}),
typeName: ZodFirstPartyTypeKind.ZodObject
});
return merged;
}
// merge<
// Incoming extends AnyZodObject,
// Augmentation extends Incoming["shape"],
// NewOutput extends {
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
// ? Augmentation[k]["_output"]
// : k extends keyof Output
// ? Output[k]
// : never;
// },
// NewInput extends {
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
// ? Augmentation[k]["_input"]
// : k extends keyof Input
// ? Input[k]
// : never;
// }
// >(
// merging: Incoming
// ): ZodObject<
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
// Incoming["_def"]["unknownKeys"],
// Incoming["_def"]["catchall"],
// NewOutput,
// NewInput
// > {
// const merged: any = new ZodObject({
// unknownKeys: merging._def.unknownKeys,
// catchall: merging._def.catchall,
// shape: () =>
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
// typeName: ZodFirstPartyTypeKind.ZodObject,
// }) as any;
// return merged;
// }
setKey(key2, schema2) {
return this.augment({ [key2]: schema2 });
}
// merge<Incoming extends AnyZodObject>(
// merging: Incoming
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
// ZodObject<
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
// Incoming["_def"]["unknownKeys"],
// Incoming["_def"]["catchall"]
// > {
// // const mergedShape = objectUtil.mergeShapes(
// // this._def.shape(),
// // merging._def.shape()
// // );
// const merged: any = new ZodObject({
// unknownKeys: merging._def.unknownKeys,
// catchall: merging._def.catchall,
// shape: () =>
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
// typeName: ZodFirstPartyTypeKind.ZodObject,
// }) as any;
// return merged;
// }
catchall(index2) {
return new ZodObject({
...this._def,
catchall: index2
});
}
pick(mask) {
const shape = {};
util.objectKeys(mask).forEach((key2) => {
if (mask[key2] && this.shape[key2]) {
shape[key2] = this.shape[key2];
}
});
return new ZodObject({
...this._def,
shape: () => shape
});
}
omit(mask) {
const shape = {};
util.objectKeys(this.shape).forEach((key2) => {
if (!mask[key2]) {
shape[key2] = this.shape[key2];
}
});
return new ZodObject({
...this._def,
shape: () => shape
});
}
/**
* @deprecated
*/
deepPartial() {
return deepPartialify(this);
}
partial(mask) {
const newShape = {};
util.objectKeys(this.shape).forEach((key2) => {
const fieldSchema = this.shape[key2];
if (mask && !mask[key2]) {
newShape[key2] = fieldSchema;
} else {
newShape[key2] = fieldSchema.optional();
}
});
return new ZodObject({
...this._def,
shape: () => newShape
});
}
required(mask) {
const newShape = {};
util.objectKeys(this.shape).forEach((key2) => {
if (mask && !mask[key2]) {
newShape[key2] = this.shape[key2];
} else {
const fieldSchema = this.shape[key2];
let newField = fieldSchema;
while (newField instanceof ZodOptional) {
newField = newField._def.innerType;
}
newShape[key2] = newField;
}
});
return new ZodObject({
...this._def,
shape: () => newShape
});
}
keyof() {
return createZodEnum(util.objectKeys(this.shape));
}
}
ZodObject.create = (shape, params) => {
return new ZodObject({
shape: () => shape,
unknownKeys: "strip",
catchall: ZodNever.create(),
typeName: ZodFirstPartyTypeKind.ZodObject,
...processCreateParams(params)
});
};
ZodObject.strictCreate = (shape, params) => {
return new ZodObject({
shape: () => shape,
unknownKeys: "strict",
catchall: ZodNever.create(),
typeName: ZodFirstPartyTypeKind.ZodObject,
...processCreateParams(params)
});
};
ZodObject.lazycreate = (shape, params) => {
return new ZodObject({
shape,
unknownKeys: "strip",
catchall: ZodNever.create(),
typeName: ZodFirstPartyTypeKind.ZodObject,
...processCreateParams(params)
});
};
class ZodUnion extends ZodType {
_parse(input) {
const { ctx } = this._processInputParams(input);
const options = this._def.options;
function handleResults(results) {
for (const result of results) {
if (result.result.status === "valid") {
return result.result;
}
}
for (const result of results) {
if (result.result.status === "dirty") {
ctx.common.issues.push(...result.ctx.common.issues);
return result.result;
}
}
const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_union,
unionErrors
});
return INVALID;
}
if (ctx.common.async) {
return Promise.all(options.map(async (option2) => {
const childCtx = {
...ctx,
common: {
...ctx.common,
issues: []
},
parent: null
};
return {
result: await option2._parseAsync({
data: ctx.data,
path: ctx.path,
parent: childCtx
}),
ctx: childCtx
};
})).then(handleResults);
} else {
let dirty = void 0;
const issues = [];
for (const option2 of options) {
const childCtx = {
...ctx,
common: {
...ctx.common,
issues: []
},
parent: null
};
const result = option2._parseSync({
data: ctx.data,
path: ctx.path,
parent: childCtx
});
if (result.status === "valid") {
return result;
} else if (result.status === "dirty" && !dirty) {
dirty = { result, ctx: childCtx };
}
if (childCtx.common.issues.length) {
issues.push(childCtx.common.issues);
}
}
if (dirty) {
ctx.common.issues.push(...dirty.ctx.common.issues);
return dirty.result;
}
const unionErrors = issues.map((issues2) => new ZodError(issues2));
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_union,
unionErrors
});
return INVALID;
}
}
get options() {
return this._def.options;
}
}
ZodUnion.create = (types2, params) => {
return new ZodUnion({
options: types2,
typeName: ZodFirstPartyTypeKind.ZodUnion,
...processCreateParams(params)
});
};
const getDiscriminator = (type2) => {
if (type2 instanceof ZodLazy) {
return getDiscriminator(type2.schema);
} else if (type2 instanceof ZodEffects) {
return getDiscriminator(type2.innerType());
} else if (type2 instanceof ZodLiteral) {
return [type2.value];
} else if (type2 instanceof ZodEnum) {
return type2.options;
} else if (type2 instanceof ZodNativeEnum) {
return util.objectValues(type2.enum);
} else if (type2 instanceof ZodDefault) {
return getDiscriminator(type2._def.innerType);
} else if (type2 instanceof ZodUndefined) {
return [void 0];
} else if (type2 instanceof ZodNull) {
return [null];
} else if (type2 instanceof ZodOptional) {
return [void 0, ...getDiscriminator(type2.unwrap())];
} else if (type2 instanceof ZodNullable) {
return [null, ...getDiscriminator(type2.unwrap())];
} else if (type2 instanceof ZodBranded) {
return getDiscriminator(type2.unwrap());
} else if (type2 instanceof ZodReadonly) {
return getDiscriminator(type2.unwrap());
} else if (type2 instanceof ZodCatch) {
return getDiscriminator(type2._def.innerType);
} else {
return [];
}
};
class ZodDiscriminatedUnion extends ZodType {
_parse(input) {
const { ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.object) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.object,
received: ctx.parsedType
});
return INVALID;
}
const discriminator = this.discriminator;
const discriminatorValue = ctx.data[discriminator];
const option2 = this.optionsMap.get(discriminatorValue);
if (!option2) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_union_discriminator,
options: Array.from(this.optionsMap.keys()),
path: [discriminator]
});
return INVALID;
}
if (ctx.common.async) {
return option2._parseAsync({
data: ctx.data,
path: ctx.path,
parent: ctx
});
} else {
return option2._parseSync({
data: ctx.data,
path: ctx.path,
parent: ctx
});
}
}
get discriminator() {
return this._def.discriminator;
}
get options() {
return this._def.options;
}
get optionsMap() {
return this._def.optionsMap;
}
/**
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
* have a different value for each object in the union.
* @param discriminator the name of the discriminator property
* @param types an array of object schemas
* @param params
*/
static create(discriminator, options, params) {
const optionsMap = /* @__PURE__ */ new Map();
for (const type2 of options) {
const discriminatorValues = getDiscriminator(type2.shape[discriminator]);
if (!discriminatorValues.length) {
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
}
for (const value of discriminatorValues) {
if (optionsMap.has(value)) {
throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
}
optionsMap.set(value, type2);
}
}
return new ZodDiscriminatedUnion({
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
discriminator,
options,
optionsMap,
...processCreateParams(params)
});
}
}
function mergeValues(a2, b2) {
const aType = getParsedType(a2);
const bType = getParsedType(b2);
if (a2 === b2) {
return { valid: true, data: a2 };
} else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
const bKeys = util.objectKeys(b2);
const sharedKeys = util.objectKeys(a2).filter((key2) => bKeys.indexOf(key2) !== -1);
const newObj = { ...a2, ...b2 };
for (const key2 of sharedKeys) {
const sharedValue = mergeValues(a2[key2], b2[key2]);
if (!sharedValue.valid) {
return { valid: false };
}
newObj[key2] = sharedValue.data;
}
return { valid: true, data: newObj };
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
if (a2.length !== b2.length) {
return { valid: false };
}
const newArray = [];
for (let index2 = 0; index2 < a2.length; index2++) {
const itemA = a2[index2];
const itemB = b2[index2];
const sharedValue = mergeValues(itemA, itemB);
if (!sharedValue.valid) {
return { valid: false };
}
newArray.push(sharedValue.data);
}
return { valid: true, data: newArray };
} else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a2 === +b2) {
return { valid: true, data: a2 };
} else {
return { valid: false };
}
}
class ZodIntersection extends ZodType {
_parse(input) {
const { status, ctx } = this._processInputParams(input);
const handleParsed = (parsedLeft, parsedRight) => {
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
return INVALID;
}
const merged = mergeValues(parsedLeft.value, parsedRight.value);
if (!merged.valid) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_intersection_types
});
return INVALID;
}
if (isDirty(parsedLeft) || isDirty(parsedRight)) {
status.dirty();
}
return { status: status.value, value: merged.data };
};
if (ctx.common.async) {
return Promise.all([
this._def.left._parseAsync({
data: ctx.data,
path: ctx.path,
parent: ctx
}),
this._def.right._parseAsync({
data: ctx.data,
path: ctx.path,
parent: ctx
})
]).then(([left, right]) => handleParsed(left, right));
} else {
return handleParsed(this._def.left._parseSync({
data: ctx.data,
path: ctx.path,
parent: ctx
}), this._def.right._parseSync({
data: ctx.data,
path: ctx.path,
parent: ctx
}));
}
}
}
ZodIntersection.create = (left, right, params) => {
return new ZodIntersection({
left,
right,
typeName: ZodFirstPartyTypeKind.ZodIntersection,
...processCreateParams(params)
});
};
class ZodTuple extends ZodType {
_parse(input) {
const { status, ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.array) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.array,
received: ctx.parsedType
});
return INVALID;
}
if (ctx.data.length < this._def.items.length) {
addIssueToContext(ctx, {
code: ZodIssueCode.too_small,
minimum: this._def.items.length,
inclusive: true,
exact: false,
type: "array"
});
return INVALID;
}
const rest = this._def.rest;
if (!rest && ctx.data.length > this._def.items.length) {
addIssueToContext(ctx, {
code: ZodIssueCode.too_big,
maximum: this._def.items.length,
inclusive: true,
exact: false,
type: "array"
});
status.dirty();
}
const items = [...ctx.data].map((item, itemIndex) => {
const schema2 = this._def.items[itemIndex] || this._def.rest;
if (!schema2)
return null;
return schema2._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
}).filter((x2) => !!x2);
if (ctx.common.async) {
return Promise.all(items).then((results) => {
return ParseStatus.mergeArray(status, results);
});
} else {
return ParseStatus.mergeArray(status, items);
}
}
get items() {
return this._def.items;
}
rest(rest) {
return new ZodTuple({
...this._def,
rest
});
}
}
ZodTuple.create = (schemas2, params) => {
if (!Array.isArray(schemas2)) {
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
}
return new ZodTuple({
items: schemas2,
typeName: ZodFirstPartyTypeKind.ZodTuple,
rest: null,
...processCreateParams(params)
});
};
class ZodRecord extends ZodType {
get keySchema() {
return this._def.keyType;
}
get valueSchema() {
return this._def.valueType;
}
_parse(input) {
const { status, ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.object) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.object,
received: ctx.parsedType
});
return INVALID;
}
const pairs2 = [];
const keyType = this._def.keyType;
const valueType = this._def.valueType;
for (const key2 in ctx.data) {
pairs2.push({
key: keyType._parse(new ParseInputLazyPath(ctx, key2, ctx.path, key2)),
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key2], ctx.path, key2)),
alwaysSet: key2 in ctx.data
});
}
if (ctx.common.async) {
return ParseStatus.mergeObjectAsync(status, pairs2);
} else {
return ParseStatus.mergeObjectSync(status, pairs2);
}
}
get element() {
return this._def.valueType;
}
static create(first, second, third) {
if (second instanceof ZodType) {
return new ZodRecord({
keyType: first,
valueType: second,
typeName: ZodFirstPartyTypeKind.ZodRecord,
...processCreateParams(third)
});
}
return new ZodRecord({
keyType: ZodString.create(),
valueType: first,
typeName: ZodFirstPartyTypeKind.ZodRecord,
...processCreateParams(second)
});
}
}
class ZodMap extends ZodType {
get keySchema() {
return this._def.keyType;
}
get valueSchema() {
return this._def.valueType;
}
_parse(input) {
const { status, ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.map) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.map,
received: ctx.parsedType
});
return INVALID;
}
const keyType = this._def.keyType;
const valueType = this._def.valueType;
const pairs2 = [...ctx.data.entries()].map(([key2, value], index2) => {
return {
key: keyType._parse(new ParseInputLazyPath(ctx, key2, ctx.path, [index2, "key"])),
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index2, "value"]))
};
});
if (ctx.common.async) {
const finalMap = /* @__PURE__ */ new Map();
return Promise.resolve().then(async () => {
for (const pair2 of pairs2) {
const key2 = await pair2.key;
const value = await pair2.value;
if (key2.status === "aborted" || value.status === "aborted") {
return INVALID;
}
if (key2.status === "dirty" || value.status === "dirty") {
status.dirty();
}
finalMap.set(key2.value, value.value);
}
return { status: status.value, value: finalMap };
});
} else {
const finalMap = /* @__PURE__ */ new Map();
for (const pair2 of pairs2) {
const key2 = pair2.key;
const value = pair2.value;
if (key2.status === "aborted" || value.status === "aborted") {
return INVALID;
}
if (key2.status === "dirty" || value.status === "dirty") {
status.dirty();
}
finalMap.set(key2.value, value.value);
}
return { status: status.value, value: finalMap };
}
}
}
ZodMap.create = (keyType, valueType, params) => {
return new ZodMap({
valueType,
keyType,
typeName: ZodFirstPartyTypeKind.ZodMap,
...processCreateParams(params)
});
};
class ZodSet extends ZodType {
_parse(input) {
const { status, ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.set) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.set,
received: ctx.parsedType
});
return INVALID;
}
const def2 = this._def;
if (def2.minSize !== null) {
if (ctx.data.size < def2.minSize.value) {
addIssueToContext(ctx, {
code: ZodIssueCode.too_small,
minimum: def2.minSize.value,
type: "set",
inclusive: true,
exact: false,
message: def2.minSize.message
});
status.dirty();
}
}
if (def2.maxSize !== null) {
if (ctx.data.size > def2.maxSize.value) {
addIssueToContext(ctx, {
code: ZodIssueCode.too_big,
maximum: def2.maxSize.value,
type: "set",
inclusive: true,
exact: false,
message: def2.maxSize.message
});
status.dirty();
}
}
const valueType = this._def.valueType;
function finalizeSet(elements2) {
const parsedSet = /* @__PURE__ */ new Set();
for (const element2 of elements2) {
if (element2.status === "aborted")
return INVALID;
if (element2.status === "dirty")
status.dirty();
parsedSet.add(element2.value);
}
return { status: status.value, value: parsedSet };
}
const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2)));
if (ctx.common.async) {
return Promise.all(elements).then((elements2) => finalizeSet(elements2));
} else {
return finalizeSet(elements);
}
}
min(minSize, message) {
return new ZodSet({
...this._def,
minSize: { value: minSize, message: errorUtil.toString(message) }
});
}
max(maxSize, message) {
return new ZodSet({
...this._def,
maxSize: { value: maxSize, message: errorUtil.toString(message) }
});
}
size(size2, message) {
return this.min(size2, message).max(size2, message);
}
nonempty(message) {
return this.min(1, message);
}
}
ZodSet.create = (valueType, params) => {
return new ZodSet({
valueType,
minSize: null,
maxSize: null,
typeName: ZodFirstPartyTypeKind.ZodSet,
...processCreateParams(params)
});
};
class ZodFunction extends ZodType {
constructor() {
super(...arguments);
this.validate = this.implement;
}
_parse(input) {
const { ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.function) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.function,
received: ctx.parsedType
});
return INVALID;
}
function makeArgsIssue(args, error2) {
return makeIssue({
data: args,
path: ctx.path,
errorMaps: [
ctx.common.contextualErrorMap,
ctx.schemaErrorMap,
getErrorMap(),
errorMap
].filter((x2) => !!x2),
issueData: {
code: ZodIssueCode.invalid_arguments,
argumentsError: error2
}
});
}
function makeReturnsIssue(returns, error2) {
return makeIssue({
data: returns,
path: ctx.path,
errorMaps: [
ctx.common.contextualErrorMap,
ctx.schemaErrorMap,
getErrorMap(),
errorMap
].filter((x2) => !!x2),
issueData: {
code: ZodIssueCode.invalid_return_type,
returnTypeError: error2
}
});
}
const params = { errorMap: ctx.common.contextualErrorMap };
const fn = ctx.data;
if (this._def.returns instanceof ZodPromise) {
const me2 = this;
return OK(async function(...args) {
const error2 = new ZodError([]);
const parsedArgs = await me2._def.args.parseAsync(args, params).catch((e2) => {
error2.addIssue(makeArgsIssue(args, e2));
throw error2;
});
const result = await Reflect.apply(fn, this, parsedArgs);
const parsedReturns = await me2._def.returns._def.type.parseAsync(result, params).catch((e2) => {
error2.addIssue(makeReturnsIssue(result, e2));
throw error2;
});
return parsedReturns;
});
} else {
const me2 = this;
return OK(function(...args) {
const parsedArgs = me2._def.args.safeParse(args, params);
if (!parsedArgs.success) {
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
}
const result = Reflect.apply(fn, this, parsedArgs.data);
const parsedReturns = me2._def.returns.safeParse(result, params);
if (!parsedReturns.success) {
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
}
return parsedReturns.data;
});
}
}
parameters() {
return this._def.args;
}
returnType() {
return this._def.returns;
}
args(...items) {
return new ZodFunction({
...this._def,
args: ZodTuple.create(items).rest(ZodUnknown.create())
});
}
returns(returnType) {
return new ZodFunction({
...this._def,
returns: returnType
});
}
implement(func) {
const validatedFunc = this.parse(func);
return validatedFunc;
}
strictImplement(func) {
const validatedFunc = this.parse(func);
return validatedFunc;
}
static create(args, returns, params) {
return new ZodFunction({
args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
returns: returns || ZodUnknown.create(),
typeName: ZodFirstPartyTypeKind.ZodFunction,
...processCreateParams(params)
});
}
}
class ZodLazy extends ZodType {
get schema() {
return this._def.getter();
}
_parse(input) {
const { ctx } = this._processInputParams(input);
const lazySchema = this._def.getter();
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
}
}
ZodLazy.create = (getter, params) => {
return new ZodLazy({
getter,
typeName: ZodFirstPartyTypeKind.ZodLazy,
...processCreateParams(params)
});
};
class ZodLiteral extends ZodType {
_parse(input) {
if (input.data !== this._def.value) {
const ctx = this._getOrReturnCtx(input);
addIssueToContext(ctx, {
received: ctx.data,
code: ZodIssueCode.invalid_literal,
expected: this._def.value
});
return INVALID;
}
return { status: "valid", value: input.data };
}
get value() {
return this._def.value;
}
}
ZodLiteral.create = (value, params) => {
return new ZodLiteral({
value,
typeName: ZodFirstPartyTypeKind.ZodLiteral,
...processCreateParams(params)
});
};
function createZodEnum(values2, params) {
return new ZodEnum({
values: values2,
typeName: ZodFirstPartyTypeKind.ZodEnum,
...processCreateParams(params)
});
}
class ZodEnum extends ZodType {
constructor() {
super(...arguments);
_ZodEnum_cache.set(this, void 0);
}
_parse(input) {
if (typeof input.data !== "string") {
const ctx = this._getOrReturnCtx(input);
const expectedValues = this._def.values;
addIssueToContext(ctx, {
expected: util.joinValues(expectedValues),
received: ctx.parsedType,
code: ZodIssueCode.invalid_type
});
return INVALID;
}
if (!__classPrivateFieldGet(this, _ZodEnum_cache)) {
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values));
}
if (!__classPrivateFieldGet(this, _ZodEnum_cache).has(input.data)) {
const ctx = this._getOrReturnCtx(input);
const expectedValues = this._def.values;
addIssueToContext(ctx, {
received: ctx.data,
code: ZodIssueCode.invalid_enum_value,
options: expectedValues
});
return INVALID;
}
return OK(input.data);
}
get options() {
return this._def.values;
}
get enum() {
const enumValues = {};
for (const val of this._def.values) {
enumValues[val] = val;
}
return enumValues;
}
get Values() {
const enumValues = {};
for (const val of this._def.values) {
enumValues[val] = val;
}
return enumValues;
}
get Enum() {
const enumValues = {};
for (const val of this._def.values) {
enumValues[val] = val;
}
return enumValues;
}
extract(values2, newDef = this._def) {
return ZodEnum.create(values2, {
...this._def,
...newDef
});
}
exclude(values2, newDef = this._def) {
return ZodEnum.create(this.options.filter((opt) => !values2.includes(opt)), {
...this._def,
...newDef
});
}
}
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
ZodEnum.create = createZodEnum;
class ZodNativeEnum extends ZodType {
constructor() {
super(...arguments);
_ZodNativeEnum_cache.set(this, void 0);
}
_parse(input) {
const nativeEnumValues = util.getValidEnumValues(this._def.values);
const ctx = this._getOrReturnCtx(input);
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
const expectedValues = util.objectValues(nativeEnumValues);
addIssueToContext(ctx, {
expected: util.joinValues(expectedValues),
received: ctx.parsedType,
code: ZodIssueCode.invalid_type
});
return INVALID;
}
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache)) {
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)));
}
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache).has(input.data)) {
const expectedValues = util.objectValues(nativeEnumValues);
addIssueToContext(ctx, {
received: ctx.data,
code: ZodIssueCode.invalid_enum_value,
options: expectedValues
});
return INVALID;
}
return OK(input.data);
}
get enum() {
return this._def.values;
}
}
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
ZodNativeEnum.create = (values2, params) => {
return new ZodNativeEnum({
values: values2,
typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
...processCreateParams(params)
});
};
class ZodPromise extends ZodType {
unwrap() {
return this._def.type;
}
_parse(input) {
const { ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.promise,
received: ctx.parsedType
});
return INVALID;
}
const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
return OK(promisified.then((data) => {
return this._def.type.parseAsync(data, {
path: ctx.path,
errorMap: ctx.common.contextualErrorMap
});
}));
}
}
ZodPromise.create = (schema2, params) => {
return new ZodPromise({
type: schema2,
typeName: ZodFirstPartyTypeKind.ZodPromise,
...processCreateParams(params)
});
};
class ZodEffects extends ZodType {
innerType() {
return this._def.schema;
}
sourceType() {
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
}
_parse(input) {
const { status, ctx } = this._processInputParams(input);
const effect = this._def.effect || null;
const checkCtx = {
addIssue: (arg) => {
addIssueToContext(ctx, arg);
if (arg.fatal) {
status.abort();
} else {
status.dirty();
}
},
get path() {
return ctx.path;
}
};
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
if (effect.type === "preprocess") {
const processed = effect.transform(ctx.data, checkCtx);
if (ctx.common.async) {
return Promise.resolve(processed).then(async (processed2) => {
if (status.value === "aborted")
return INVALID;
const result = await this._def.schema._parseAsync({
data: processed2,
path: ctx.path,
parent: ctx
});
if (result.status === "aborted")
return INVALID;
if (result.status === "dirty")
return DIRTY(result.value);
if (status.value === "dirty")
return DIRTY(result.value);
return result;
});
} else {
if (status.value === "aborted")
return INVALID;
const result = this._def.schema._parseSync({
data: processed,
path: ctx.path,
parent: ctx
});
if (result.status === "aborted")
return INVALID;
if (result.status === "dirty")
return DIRTY(result.value);
if (status.value === "dirty")
return DIRTY(result.value);
return result;
}
}
if (effect.type === "refinement") {
const executeRefinement = (acc) => {
const result = effect.refinement(acc, checkCtx);
if (ctx.common.async) {
return Promise.resolve(result);
}
if (result instanceof Promise) {
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
}
return acc;
};
if (ctx.common.async === false) {
const inner = this._def.schema._parseSync({
data: ctx.data,
path: ctx.path,
parent: ctx
});
if (inner.status === "aborted")
return INVALID;
if (inner.status === "dirty")
status.dirty();
executeRefinement(inner.value);
return { status: status.value, value: inner.value };
} else {
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
if (inner.status === "aborted")
return INVALID;
if (inner.status === "dirty")
status.dirty();
return executeRefinement(inner.value).then(() => {
return { status: status.value, value: inner.value };
});
});
}
}
if (effect.type === "transform") {
if (ctx.common.async === false) {
const base2 = this._def.schema._parseSync({
data: ctx.data,
path: ctx.path,
parent: ctx
});
if (!isValid(base2))
return base2;
const result = effect.transform(base2.value, checkCtx);
if (result instanceof Promise) {
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
}
return { status: status.value, value: result };
} else {
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base2) => {
if (!isValid(base2))
return base2;
return Promise.resolve(effect.transform(base2.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
});
}
}
util.assertNever(effect);
}
}
ZodEffects.create = (schema2, effect, params) => {
return new ZodEffects({
schema: schema2,
typeName: ZodFirstPartyTypeKind.ZodEffects,
effect,
...processCreateParams(params)
});
};
ZodEffects.createWithPreprocess = (preprocess, schema2, params) => {
return new ZodEffects({
schema: schema2,
effect: { type: "preprocess", transform: preprocess },
typeName: ZodFirstPartyTypeKind.ZodEffects,
...processCreateParams(params)
});
};
class ZodOptional extends ZodType {
_parse(input) {
const parsedType = this._getType(input);
if (parsedType === ZodParsedType.undefined) {
return OK(void 0);
}
return this._def.innerType._parse(input);
}
unwrap() {
return this._def.innerType;
}
}
ZodOptional.create = (type2, params) => {
return new ZodOptional({
innerType: type2,
typeName: ZodFirstPartyTypeKind.ZodOptional,
...processCreateParams(params)
});
};
class ZodNullable extends ZodType {
_parse(input) {
const parsedType = this._getType(input);
if (parsedType === ZodParsedType.null) {
return OK(null);
}
return this._def.innerType._parse(input);
}
unwrap() {
return this._def.innerType;
}
}
ZodNullable.create = (type2, params) => {
return new ZodNullable({
innerType: type2,
typeName: ZodFirstPartyTypeKind.ZodNullable,
...processCreateParams(params)
});
};
class ZodDefault extends ZodType {
_parse(input) {
const { ctx } = this._processInputParams(input);
let data = ctx.data;
if (ctx.parsedType === ZodParsedType.undefined) {
data = this._def.defaultValue();
}
return this._def.innerType._parse({
data,
path: ctx.path,
parent: ctx
});
}
removeDefault() {
return this._def.innerType;
}
}
ZodDefault.create = (type2, params) => {
return new ZodDefault({
innerType: type2,
typeName: ZodFirstPartyTypeKind.ZodDefault,
defaultValue: typeof params.default === "function" ? params.default : () => params.default,
...processCreateParams(params)
});
};
class ZodCatch extends ZodType {
_parse(input) {
const { ctx } = this._processInputParams(input);
const newCtx = {
...ctx,
common: {
...ctx.common,
issues: []
}
};
const result = this._def.innerType._parse({
data: newCtx.data,
path: newCtx.path,
parent: {
...newCtx
}
});
if (isAsync(result)) {
return result.then((result2) => {
return {
status: "valid",
value: result2.status === "valid" ? result2.value : this._def.catchValue({
get error() {
return new ZodError(newCtx.common.issues);
},
input: newCtx.data
})
};
});
} else {
return {
status: "valid",
value: result.status === "valid" ? result.value : this._def.catchValue({
get error() {
return new ZodError(newCtx.common.issues);
},
input: newCtx.data
})
};
}
}
removeCatch() {
return this._def.innerType;
}
}
ZodCatch.create = (type2, params) => {
return new ZodCatch({
innerType: type2,
typeName: ZodFirstPartyTypeKind.ZodCatch,
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
...processCreateParams(params)
});
};
class ZodNaN extends ZodType {
_parse(input) {
const parsedType = this._getType(input);
if (parsedType !== ZodParsedType.nan) {
const ctx = this._getOrReturnCtx(input);
addIssueToContext(ctx, {
code: ZodIssueCode.invalid_type,
expected: ZodParsedType.nan,
received: ctx.parsedType
});
return INVALID;
}
return { status: "valid", value: input.data };
}
}
ZodNaN.create = (params) => {
return new ZodNaN({
typeName: ZodFirstPartyTypeKind.ZodNaN,
...processCreateParams(params)
});
};
const BRAND = Symbol("zod_brand");
class ZodBranded extends ZodType {
_parse(input) {
const { ctx } = this._processInputParams(input);
const data = ctx.data;
return this._def.type._parse({
data,
path: ctx.path,
parent: ctx
});
}
unwrap() {
return this._def.type;
}
}
class ZodPipeline extends ZodType {
_parse(input) {
const { status, ctx } = this._processInputParams(input);
if (ctx.common.async) {
const handleAsync = async () => {
const inResult = await this._def.in._parseAsync({
data: ctx.data,
path: ctx.path,
parent: ctx
});
if (inResult.status === "aborted")
return INVALID;
if (inResult.status === "dirty") {
status.dirty();
return DIRTY(inResult.value);
} else {
return this._def.out._parseAsync({
data: inResult.value,
path: ctx.path,
parent: ctx
});
}
};
return handleAsync();
} else {
const inResult = this._def.in._parseSync({
data: ctx.data,
path: ctx.path,
parent: ctx
});
if (inResult.status === "aborted")
return INVALID;
if (inResult.status === "dirty") {
status.dirty();
return {
status: "dirty",
value: inResult.value
};
} else {
return this._def.out._parseSync({
data: inResult.value,
path: ctx.path,
parent: ctx
});
}
}
}
static create(a2, b2) {
return new ZodPipeline({
in: a2,
out: b2,
typeName: ZodFirstPartyTypeKind.ZodPipeline
});
}
}
class ZodReadonly extends ZodType {
_parse(input) {
const result = this._def.innerType._parse(input);
const freeze = (data) => {
if (isValid(data)) {
data.value = Object.freeze(data.value);
}
return data;
};
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
}
unwrap() {
return this._def.innerType;
}
}
ZodReadonly.create = (type2, params) => {
return new ZodReadonly({
innerType: type2,
typeName: ZodFirstPartyTypeKind.ZodReadonly,
...processCreateParams(params)
});
};
function custom(check, params = {}, fatal) {
if (check)
return ZodAny.create().superRefine((data, ctx) => {
var _a2, _b;
if (!check(data)) {
const p2 = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true;
const p22 = typeof p2 === "string" ? { message: p2 } : p2;
ctx.addIssue({ code: "custom", ...p22, fatal: _fatal });
}
});
return ZodAny.create();
}
const late = {
object: ZodObject.lazycreate
};
var ZodFirstPartyTypeKind;
(function(ZodFirstPartyTypeKind2) {
ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
const instanceOfType = (cls, params = {
message: `Input not instance of ${cls.name}`
}) => custom((data) => data instanceof cls, params);
const stringType = ZodString.create;
const numberType = ZodNumber.create;
const nanType = ZodNaN.create;
const bigIntType = ZodBigInt.create;
const booleanType = ZodBoolean.create;
const dateType = ZodDate.create;
const symbolType = ZodSymbol.create;
const undefinedType = ZodUndefined.create;
const nullType = ZodNull.create;
const anyType = ZodAny.create;
const unknownType = ZodUnknown.create;
const neverType = ZodNever.create;
const voidType = ZodVoid.create;
const arrayType = ZodArray.create;
const objectType = ZodObject.create;
const strictObjectType = ZodObject.strictCreate;
const unionType = ZodUnion.create;
const discriminatedUnionType = ZodDiscriminatedUnion.create;
const intersectionType = ZodIntersection.create;
const tupleType = ZodTuple.create;
const recordType = ZodRecord.create;
const mapType = ZodMap.create;
const setType = ZodSet.create;
const functionType = ZodFunction.create;
const lazyType = ZodLazy.create;
const literalType = ZodLiteral.create;
const enumType = ZodEnum.create;
const nativeEnumType = ZodNativeEnum.create;
const promiseType = ZodPromise.create;
const effectsType = ZodEffects.create;
const optionalType = ZodOptional.create;
const nullableType = ZodNullable.create;
const preprocessType = ZodEffects.createWithPreprocess;
const pipelineType = ZodPipeline.create;
const ostring = () => stringType().optional();
const onumber = () => numberType().optional();
const oboolean = () => booleanType().optional();
const coerce = {
string: (arg) => ZodString.create({ ...arg, coerce: true }),
number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
boolean: (arg) => ZodBoolean.create({
...arg,
coerce: true
}),
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
date: (arg) => ZodDate.create({ ...arg, coerce: true })
};
const NEVER = INVALID;
var z$8 = /* @__PURE__ */ Object.freeze({
__proto__: null,
defaultErrorMap: errorMap,
setErrorMap,
getErrorMap,
makeIssue,
EMPTY_PATH,
addIssueToContext,
ParseStatus,
INVALID,
DIRTY,
OK,
isAborted,
isDirty,
isValid,
isAsync,
get util() {
return util;
},
get objectUtil() {
return objectUtil;
},
ZodParsedType,
getParsedType,
ZodType,
datetimeRegex,
ZodString,
ZodNumber,
ZodBigInt,
ZodBoolean,
ZodDate,
ZodSymbol,
ZodUndefined,
ZodNull,
ZodAny,
ZodUnknown,
ZodNever,
ZodVoid,
ZodArray,
ZodObject,
ZodUnion,
ZodDiscriminatedUnion,
ZodIntersection,
ZodTuple,
ZodRecord,
ZodMap,
ZodSet,
ZodFunction,
ZodLazy,
ZodLiteral,
ZodEnum,
ZodNativeEnum,
ZodPromise,
ZodEffects,
ZodTransformer: ZodEffects,
ZodOptional,
ZodNullable,
ZodDefault,
ZodCatch,
ZodNaN,
BRAND,
ZodBranded,
ZodPipeline,
ZodReadonly,
custom,
Schema: ZodType,
ZodSchema: ZodType,
late,
get ZodFirstPartyTypeKind() {
return ZodFirstPartyTypeKind;
},
coerce,
any: anyType,
array: arrayType,
bigint: bigIntType,
boolean: booleanType,
date: dateType,
discriminatedUnion: discriminatedUnionType,
effect: effectsType,
"enum": enumType,
"function": functionType,
"instanceof": instanceOfType,
intersection: intersectionType,
lazy: lazyType,
literal: literalType,
map: mapType,
nan: nanType,
nativeEnum: nativeEnumType,
never: neverType,
"null": nullType,
nullable: nullableType,
number: numberType,
object: objectType,
oboolean,
onumber,
optional: optionalType,
ostring,
pipeline: pipelineType,
preprocess: preprocessType,
promise: promiseType,
record: recordType,
set: setType,
strictObject: strictObjectType,
string: stringType,
symbol: symbolType,
transformer: effectsType,
tuple: tupleType,
"undefined": undefinedType,
union: unionType,
unknown: unknownType,
"void": voidType,
NEVER,
ZodIssueCode,
quotelessJson,
ZodError
});
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
let nanoid = (size2 = 21) => {
let id2 = "";
let bytes = crypto.getRandomValues(new Uint8Array(size2));
while (size2--) {
id2 += urlAlphabet[bytes[size2] & 63];
}
return id2;
};
const nanoidSchema = z$8.string().min(7).optional().default(() => nanoid());
const cookieSchema = z$8.object({
uid: nanoidSchema,
/** Defines the cookie name and its value. A cookie definition begins with a name-value pair. */
name: z$8.string().default("Default Cookie"),
value: z$8.string().default("Default Value"),
/** Defines the host to which the cookie will be sent. */
domain: z$8.string().optional(),
/** Indicates the maximum lifetime of the cookie as an HTTP-date timestamp. See Date for the required formatting. */
expires: z$8.date().optional(),
/**
* Forbids JavaScript from accessing the cookie, for example, through the Document.cookie property. Note that a cookie
* that has been created with HttpOnly will still be sent with JavaScript-initiated requests, for example, when
* calling XMLHttpRequest.send() or fetch(). This mitigates attacks against cross-site scripting (XSS).
*/
httpOnly: z$8.boolean().optional(),
/**
* Indicates the number of seconds until the cookie expires. A zero or negative number will expire the cookie
* immediately. If both Expires and Max-Age are set, Max-Age has precedence.
*/
maxAge: z$8.number().optional(),
/**
* Indicates that the cookie should be stored using partitioned storage. See Cookies Having Independent Partitioned
* State (CHIPS) for more details.
*/
partitioned: z$8.boolean().optional(),
/** Indicates the path that must exist in the requested URL for the browser to send the Cookie header. */
path: z$8.string().optional(),
/**
* Controls whether or not a cookie is sent with cross-site requests, providing some protection against cross-site
* request forgery attacks (CSRF).
*/
sameSite: z$8.union([z$8.literal("Lax"), z$8.literal("Strict"), z$8.literal("None")]).default("None"),
/**
* Indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on
* localhost), and therefore, is more resistant to man-in-the-middle attacks.
*/
secure: z$8.boolean().optional()
});
const environmentSchema = z$8.object({
uid: nanoidSchema,
name: z$8.string().optional().default("Default Environment"),
color: z$8.string().optional().default("blue"),
value: z$8.string().default(""),
isDefault: z$8.boolean().optional()
});
const apiKeyExampleSchema = z$8.object({
type: z$8.literal("apiKey").default("apiKey"),
name: z$8.string().default(""),
value: z$8.string().default("")
});
const httpExampleSchema = z$8.object({
type: z$8.literal("http").default("http"),
username: z$8.string().default(""),
password: z$8.string().default(""),
token: z$8.string().default("")
});
const oauthImplicitExampleSchema = z$8.object({
type: z$8.literal("oauth-implicit").default("oauth-implicit"),
token: z$8.string().default("")
});
const oauthPasswordExampleSchema = z$8.object({
type: z$8.literal("oauth-password").default("oauth-password"),
token: z$8.string().default(""),
username: z$8.string().default(""),
password: z$8.string().default(""),
clientSecret: z$8.string().default("")
});
const oauthClientCredentialsExampleSchema = z$8.object({
type: z$8.literal("oauth-clientCredentials").default("oauth-clientCredentials"),
token: z$8.string().default(""),
clientSecret: z$8.string().default("")
});
const oauthAuthorizationCodeExampleSchema = z$8.object({
type: z$8.literal("oauth-authorizationCode").default("oauth-authorizationCode"),
token: z$8.string().default(""),
clientSecret: z$8.string().default("")
});
const securitySchemeExampleValueSchema = z$8.union([
apiKeyExampleSchema,
httpExampleSchema,
oauthImplicitExampleSchema,
oauthPasswordExampleSchema,
oauthClientCredentialsExampleSchema,
oauthAuthorizationCodeExampleSchema
]);
function authExampleFromSchema(scheme, baseValues = {}) {
if (scheme.type === "apiKey")
return apiKeyExampleSchema.parse({ name: scheme.name, ...baseValues });
if (scheme.type === "http")
return httpExampleSchema.parse(baseValues);
if (scheme.type === "oauth2") {
if (scheme.flow.type === "authorizationCode")
return oauthAuthorizationCodeExampleSchema.parse(baseValues);
if (scheme.flow.type === "clientCredentials")
return oauthClientCredentialsExampleSchema.parse(baseValues);
if (scheme.flow.type === "implicit")
return oauthImplicitExampleSchema.parse(baseValues);
if (scheme.flow.type === "password")
return oauthPasswordExampleSchema.parse(baseValues);
}
throw Error("INVALID SCHEMA FOR OAUTH EXAMPLE");
}
const commonProps = z$8.object({
/* A description for security scheme. CommonMark syntax MAY be used for rich text representation. */
description: z$8.string().optional()
});
const extendedSecuritySchema = z$8.object({
uid: nanoidSchema,
/** The name key that links a security requirement to a security object */
nameKey: z$8.string().optional().default("")
});
const securitySchemeApiKeyIn = ["query", "header", "cookie"];
const oasSecuritySchemeApiKey = commonProps.extend({
type: z$8.literal("apiKey"),
/** REQUIRED. The name of the header, query or cookie parameter to be used. */
name: z$8.string().optional().default(""),
/** REQUIRED. The location of the API key. Valid values are "query", "header" or "cookie". */
in: z$8.enum(securitySchemeApiKeyIn).optional().default("header")
});
const securityApiKeySchema = oasSecuritySchemeApiKey.merge(extendedSecuritySchema);
const oasSecuritySchemeHttp = commonProps.extend({
type: z$8.literal("http"),
/**
* REQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header as defined in
* [RFC7235]. The values used SHOULD be registered in the IANA Authentication Scheme registry.
*/
scheme: z$8.string().toLowerCase().pipe(z$8.enum(["basic", "bearer"])).optional().default("basic"),
/**
* A hint to the client to identify how the bearer token is formatted.
* Bearer tokens are usually generated by an authorization server, so
* this information is primarily for documentation purposes.
*/
bearerFormat: z$8.union([z$8.literal("JWT"), z$8.string()]).optional().default("JWT")
});
const securityHttpSchema = oasSecuritySchemeHttp.merge(extendedSecuritySchema);
const oasSecuritySchemeOpenId = commonProps.extend({
type: z$8.literal("openIdConnect"),
/**
* REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the
* form of a URL. The OpenID Connect standard requires the use of TLS.
*/
openIdConnectUrl: z$8.string().optional().default("")
});
const securityOpenIdSchema = oasSecuritySchemeOpenId.merge(extendedSecuritySchema);
const authorizationUrl = z$8.string().default("");
const tokenUrl = z$8.string().default("");
const oauthCommon = z$8.object({
/**
* The URL to be used for obtaining refresh tokens. This MUST be in the form of a
* URL. The OAuth2 standard requires the use of TLS.
*/
refreshUrl: z$8.string().optional().default(""),
/**
* REQUIRED. The available scopes for the OAuth2 security scheme. A map
* between the scope name and a short description for it. The map MAY be empty.
*/
scopes: z$8.union([
z$8.map(z$8.string(), z$8.string().optional()),
z$8.record(z$8.string(), z$8.string().optional()),
z$8.object({})
]).optional().default({}),
selectedScopes: z$8.array(z$8.string()).optional().default([])
});
const oasOauthFlowSchema = z$8.discriminatedUnion("type", [
/** Configuration for the OAuth Implicit flow */
oauthCommon.extend({
"type": z$8.literal("implicit"),
authorizationUrl,
"x-scalar-redirect-uri": z$8.string().optional().default("")
}),
/** Configuration for the OAuth Resource Owner Password flow */
oauthCommon.extend({
type: z$8.literal("password"),
tokenUrl
}),
/** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */
oauthCommon.extend({
type: z$8.literal("clientCredentials"),
tokenUrl
}),
/** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.*/
oauthCommon.extend({
"type": z$8.literal("authorizationCode"),
authorizationUrl,
"x-scalar-redirect-uri": z$8.string().optional().default(""),
tokenUrl
})
]).optional().default({ type: "implicit", authorizationUrl: "http://localhost:8080" });
const oasSecuritySchemeOauth2 = commonProps.extend({
"type": z$8.literal("oauth2"),
/** REQUIRED. An object containing configuration information for the flow types supported. */
"flow": oasOauthFlowSchema,
/** Extension to save the client Id associated with an oauth flow */
"x-scalar-client-id": z$8.string().optional().default("")
});
const securityOauthSchema = oasSecuritySchemeOauth2.merge(extendedSecuritySchema);
const oasSecurityRequirementSchema = z$8.record(z$8.string(), z$8.array(z$8.string()).optional().default([]));
z$8.union([
oasSecuritySchemeApiKey,
oasSecuritySchemeHttp,
oasSecuritySchemeOauth2,
oasSecuritySchemeOpenId
]);
const securitySchemeSchema = z$8.union([
securityApiKeySchema,
securityHttpSchema,
securityOpenIdSchema,
securityOauthSchema
]);
const oasLicenseSchema = z$8.object({
/** REQUIRED. The license name used for the API. */
name: z$8.string().optional().default("name"),
/** An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. */
identifier: z$8.string().optional(),
/**
* A URL to the license used for the API. This MUST be in the form of a URL. The url field
* is mutually exclusive of the identifier field.
*/
url: z$8.string().url().optional()
});
const oasContactSchema = z$8.object({
/** The identifying name of the contact person/organization. */
name: z$8.string().optional(),
/** The URL pointing to the contact information. This MUST be in the form of a URL. */
url: z$8.string().url().optional(),
/** The email address of the contact person/organization. This MUST be in the form of an email address. */
email: z$8.string().email().optional()
});
const oasInfoSchema = z$8.object({
/** REQUIRED. The title of the API. */
title: z$8.string().optional().default("OpenAPI Spec"),
/** A short summary of the API. */
summary: z$8.string().optional(),
/** A description of the API. CommonMark syntax MAY be used for rich text representation. */
description: z$8.string().optional(),
/** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */
termsOfService: z$8.string().optional(),
/** The contact information for the exposed API. */
contact: oasContactSchema.optional(),
/** The license information for the exposed API. */
license: oasLicenseSchema.optional(),
/**
* REQUIRED. The version of the OpenAPI document (which is distinct from the OpenAPI
* Specification version or the API implementation version).
*/
version: z$8.string().optional().default("1.0")
});
const oasExternalDocumentationSchema = z$8.object({
/** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */
description: z$8.string().optional(),
/** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */
url: z$8.string().default("")
});
const xScalarNestedSchema = z$8.object({
tagName: z$8.string()
}).array();
const oasTagSchema = z$8.object({
"type": z$8.literal("tag").optional().default("tag"),
/** REQUIRED. The name of the tag. */
"name": z$8.string(),
/** A description for the tag. CommonMark syntax MAY be used for rich text representation. */
"description": z$8.string().optional(),
/** Additional external documentation for this tag. */
"externalDocs": oasExternalDocumentationSchema.optional(),
"x-scalar-children": xScalarNestedSchema.default([])
});
const tagSchema = oasTagSchema.extend({
uid: nanoidSchema,
children: nanoidSchema.array().default([])
});
const oasCollectionSchema = z$8.object({
"type": z$8.literal("collection").optional().default("collection"),
"openapi": z$8.union([
z$8.string(),
z$8.literal("3.0.0"),
z$8.literal("3.1.0"),
z$8.literal("4.0.0")
]).optional().default("3.1.0"),
"jsonSchemaDialect": z$8.string().optional(),
"info": oasInfoSchema.optional(),
/**
* A declaration of which security mechanisms can be used across the API. The list of
* values includes alternative security requirement objects that can be used. Only
* one of the security requirement objects need to be satisfied to authorize a request.
* Individual operations can override this definition. To make security optional, an empty
* security requirement ({}) can be included in the array.
*/
"security": z$8.array(oasSecurityRequirementSchema).optional().default([]),
"externalDocs": oasExternalDocumentationSchema.optional(),
/** TODO: Type these */
"components": z$8.record(z$8.string(), z$8.unknown()).optional(),
/** TODO: Type these */
"webhooks": z$8.record(z$8.string(), z$8.unknown()).optional(),
/** A custom icon representing the collection */
"x-scalar-icon": z$8.string().optional().default("interface-content-folder")
// These properties will be stripped out and mapped back as id lists
// servers
// paths/**
// servers
// tags
// security
});
const extendedCollectionSchema = z$8.object({
uid: nanoidSchema,
/** A list of security schemes UIDs associated with the collection */
securitySchemes: z$8.string().array().default([]),
/** The currently selected server */
selectedServerUid: z$8.string().default(""),
/** UIDs which refer to servers on the workspace base */
servers: nanoidSchema.array().default([]),
/** Request UIDs associated with a collection */
requests: nanoidSchema.array().default([]),
/** Tag UIDs associated with the collection */
tags: nanoidSchema.array().default([]),
/** List of requests without tags and top level tag "folders" */
children: nanoidSchema.array().default([]),
/**
* Map of security schemas to their value sets
*
* For each selected security schema we should have an entry here
* The entry will contain the secret values (but not the schema definition)
*/
auth: z$8.record(nanoidSchema, securitySchemeExampleValueSchema).default({}),
/** A link to where this document is stored, useful for live sync and possibly git sync down the line */
documentUrl: z$8.string().optional(),
/**
* Enables polling of OpenAPI document urls
*
* @remarks Only effective when `documentUrl` is set
*/
watchForChanges: z$8.boolean().optional().default(false),
/**
* Status of the watcher from above
*
* @defaults to idle for all collections, doesn't mean that it can watch for changes
*/
watchForChangesStatus: z$8.enum(["IDLE", "WATCHING", "ERROR"]).optional().default("IDLE")
});
const collectionSchema = oasCollectionSchema.merge(extendedCollectionSchema);
const oasServerVariableSchema = z$8.object({
/**
* An enumeration of string values to be used if the substitution options are from a limited set.
* The array MUST NOT be empty.
*/
enum: z$8.string().array().min(1).optional(),
/**
* REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.
* Note this behavior is different than the Schema Object’s treatment of default values, because in those cases
* parameter values are optional. If the enum is defined, the value MUST exist in the enum’s values.
*/
default: z$8.string().optional().default("default"),
/** An optional description for the server variable. CommonMark syntax MAY be used for rich text representation. */
description: z$8.string().optional()
});
const oasServerSchema = z$8.object({
/**
* REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that
* the host location is relative to the location where the OpenAPI document is being served. Variable substitutions
* will be made when a variable is named in {brackets}.
*/
url: z$8.string().optional().default(""),
/**
* An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text
* representation.
*/
description: z$8.string().optional(),
/** A map between a variable name and its value. The value is used for substitution in the server’s URL template. */
variables: z$8.record(z$8.string(), oasServerVariableSchema).optional()
});
const serverSchema = oasServerSchema.extend({
uid: nanoidSchema
});
const parameterTypeSchema = z$8.enum(["path", "query", "header", "cookie"]);
const parameterStyleSchema = z$8.enum([
"matrix",
"simple",
"form",
"label",
"spaceDelimited",
"pipeDelimited",
"deepObject"
]);
const oasParameterSchema = z$8.object({
in: parameterTypeSchema,
name: z$8.string(),
description: z$8.string().optional(),
/** Defaulted to false */
required: z$8.boolean().optional().default(false),
/** Defaulted to false */
deprecated: z$8.boolean().optional().default(false),
schema: z$8.unknown().optional(),
content: z$8.unknown().optional(),
/** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */
style: parameterStyleSchema.optional()
});
const requestMethods = [
"connect",
"delete",
"get",
"head",
"options",
"patch",
"post",
"put",
"trace"
];
const requestBodySchema = z$8.any();
const oasRequestSchema = z$8.object({
/**
* A list of tags for API documentation control. Tags can be used for logical
* grouping of operations by resources or any other qualifier.
*
* These tags are the openapi spec tag names, not uids
*/
tags: z$8.string().array().optional(),
/** A short summary of what the operation does. */
summary: z$8.string().optional(),
/** A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. */
description: z$8.string().optional(),
/**
* Unique string used to identify the operation. The id MUST be unique among all operations described in the API.
* The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an
* operation, therefore, it is RECOMMENDED to follow bin common programming naming conventions./
*/
operationId: z$8.string().optional(),
/**
* A declaration of which security mechanisms can be used across the API. The list of
* values includes alternative security requirement objects that can be used. Only
* one of the security requirement objects need to be satisfied to authorize a request.
* Individual operations can override this definition. To make security optional, an empty
* security requirement ({}) can be included in the array.
*/
security: z$8.array(oasSecurityRequirementSchema).optional(),
/**
* The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the
* HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the
* HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined
* semantics and SHOULD be avoided if possible.
*/
requestBody: requestBodySchema.optional(),
/**
* Request parameters
*/
parameters: oasParameterSchema.array().optional(),
/**
* External documentation object
*/
externalDocs: oasExternalDocumentationSchema.optional(),
deprecated: z$8.boolean().optional(),
/** Response formats */
responses: z$8.record(z$8.string(), z$8.any()).optional()
});
const extendedRequestSchema = z$8.object({
type: z$8.literal("request").optional().default("request"),
uid: nanoidSchema,
/** Path Key */
path: z$8.string().optional().default(""),
/** Request Method */
method: z$8.enum(requestMethods).default("get"),
/** List of server UIDs specific to the request */
servers: nanoidSchema.array().default([]),
/** The currently selected server */
selectedServerUid: z$8.string().default(""),
/** List of example UIDs associated with the request */
examples: nanoidSchema.array().default([]),
/** List of security scheme UIDs associated with the request */
selectedSecuritySchemeUids: nanoidSchema.array().default([])
});
const requestSchema = oasRequestSchema.merge(extendedRequestSchema);
function schemaModel(data, schema2, throwError = true, errorLocation) {
const result = schema2.safeParse(data);
if (!result.success) {
console.group("Schema Error");
console.warn(JSON.stringify(result.error.format(), null, 2));
console.log("Received: ", data);
console.groupEnd();
}
if (throwError && !result.success)
throw new Error("Zod validation failure");
return result.data;
}
function json2xml(data, tab) {
const toXml = function(value, key2, indentation2) {
let xml3 = "";
if (value instanceof Array) {
for (let i2 = 0, n2 = value.length; i2 < n2; i2++) {
xml3 += indentation2 + toXml(value[i2], key2, indentation2 + " ") + "\n";
}
} else if (typeof value == "object") {
let hasChild2 = false;
xml3 += indentation2 + "<" + key2;
for (const m2 in value) {
if (m2.charAt(0) == "@")
xml3 += " " + m2.substr(1) + '="' + value[m2].toString() + '"';
else
hasChild2 = true;
}
xml3 += hasChild2 ? ">" : "/>";
if (hasChild2) {
for (const m2 in value) {
if (m2 == "#text")
xml3 += value[m2];
else if (m2 == "#cdata")
xml3 += "<![CDATA[" + value[m2] + "]]>";
else if (m2.charAt(0) != "@")
xml3 += toXml(value[m2], m2, indentation2 + " ");
}
xml3 += (xml3.charAt(xml3.length - 1) == "\n" ? indentation2 : "") + "</" + key2 + ">";
}
} else {
xml3 += indentation2 + "<" + key2 + ">" + value.toString() + "</" + key2 + ">";
}
return xml3;
};
let xml2 = "";
for (const key2 in data) {
xml2 += toXml(data[key2], key2, "");
}
return tab ? xml2.replace(/\t/g, tab) : xml2.replace(/\t|\n/g, "");
}
function normalizeMimeType(contentType) {
if (typeof contentType !== "string") {
return void 0;
}
return contentType.replace(/;.*$/, "").replace(/\/.+\+/, "/").trim();
}
function normalizeMimeTypeObject(content2) {
if (!content2) {
return content2;
}
const newContent = {
...content2
};
Object.keys(newContent).forEach((key2) => {
const newKey = normalizeMimeType(key2);
if (newKey === void 0) {
return;
}
newContent[newKey] = newContent[key2];
if (key2 !== newKey) {
delete newContent[key2];
}
});
return newContent;
}
const ALIAS = Symbol.for("yaml.alias");
const DOC = Symbol.for("yaml.document");
const MAP = Symbol.for("yaml.map");
const PAIR = Symbol.for("yaml.pair");
const SCALAR$1 = Symbol.for("yaml.scalar");
const SEQ = Symbol.for("yaml.seq");
const NODE_TYPE = Symbol.for("yaml.node.type");
const isAlias = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === ALIAS;
const isDocument = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === DOC;
const isMap = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === MAP;
const isPair = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === PAIR;
const isScalar = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SCALAR$1;
const isSeq = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SEQ;
function isCollection(node) {
if (node && typeof node === "object")
switch (node[NODE_TYPE]) {
case MAP:
case SEQ:
return true;
}
return false;
}
function isNode$2(node) {
if (node && typeof node === "object")
switch (node[NODE_TYPE]) {
case ALIAS:
case MAP:
case SCALAR$1:
case SEQ:
return true;
}
return false;
}
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
const BREAK = Symbol("break visit");
const SKIP$1 = Symbol("skip children");
const REMOVE = Symbol("remove node");
function visit$1(node, visitor) {
const visitor_ = initVisitor(visitor);
if (isDocument(node)) {
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
if (cd === REMOVE)
node.contents = null;
} else
visit_(null, node, visitor_, Object.freeze([]));
}
visit$1.BREAK = BREAK;
visit$1.SKIP = SKIP$1;
visit$1.REMOVE = REMOVE;
function visit_(key2, node, visitor, path2) {
const ctrl = callVisitor(key2, node, visitor, path2);
if (isNode$2(ctrl) || isPair(ctrl)) {
replaceNode(key2, path2, ctrl);
return visit_(key2, ctrl, visitor, path2);
}
if (typeof ctrl !== "symbol") {
if (isCollection(node)) {
path2 = Object.freeze(path2.concat(node));
for (let i2 = 0; i2 < node.items.length; ++i2) {
const ci = visit_(i2, node.items[i2], visitor, path2);
if (typeof ci === "number")
i2 = ci - 1;
else if (ci === BREAK)
return BREAK;
else if (ci === REMOVE) {
node.items.splice(i2, 1);
i2 -= 1;
}
}
} else if (isPair(node)) {
path2 = Object.freeze(path2.concat(node));
const ck = visit_("key", node.key, visitor, path2);
if (ck === BREAK)
return BREAK;
else if (ck === REMOVE)
node.key = null;
const cv = visit_("value", node.value, visitor, path2);
if (cv === BREAK)
return BREAK;
else if (cv === REMOVE)
node.value = null;
}
}
return ctrl;
}
function initVisitor(visitor) {
if (typeof visitor === "object" && (visitor.Collection || visitor.Node || visitor.Value)) {
return Object.assign({
Alias: visitor.Node,
Map: visitor.Node,
Scalar: visitor.Node,
Seq: visitor.Node
}, visitor.Value && {
Map: visitor.Value,
Scalar: visitor.Value,
Seq: visitor.Value
}, visitor.Collection && {
Map: visitor.Collection,
Seq: visitor.Collection
}, visitor);
}
return visitor;
}
function callVisitor(key2, node, visitor, path2) {
var _a2, _b, _c, _d, _e;
if (typeof visitor === "function")
return visitor(key2, node, path2);
if (isMap(node))
return (_a2 = visitor.Map) == null ? void 0 : _a2.call(visitor, key2, node, path2);
if (isSeq(node))
return (_b = visitor.Seq) == null ? void 0 : _b.call(visitor, key2, node, path2);
if (isPair(node))
return (_c = visitor.Pair) == null ? void 0 : _c.call(visitor, key2, node, path2);
if (isScalar(node))
return (_d = visitor.Scalar) == null ? void 0 : _d.call(visitor, key2, node, path2);
if (isAlias(node))
return (_e = visitor.Alias) == null ? void 0 : _e.call(visitor, key2, node, path2);
return void 0;
}
function replaceNode(key2, path2, node) {
const parent = path2[path2.length - 1];
if (isCollection(parent)) {
parent.items[key2] = node;
} else if (isPair(parent)) {
if (key2 === "key")
parent.key = node;
else
parent.value = node;
} else if (isDocument(parent)) {
parent.contents = node;
} else {
const pt = isAlias(parent) ? "alias" : "scalar";
throw new Error(`Cannot replace node with ${pt} parent`);
}
}
const escapeChars = {
"!": "%21",
",": "%2C",
"[": "%5B",
"]": "%5D",
"{": "%7B",
"}": "%7D"
};
const escapeTagName = (tn) => tn.replace(/[!,[\]{}]/g, (ch) => escapeChars[ch]);
class Directives {
constructor(yaml2, tags2) {
this.docStart = null;
this.docEnd = false;
this.yaml = Object.assign({}, Directives.defaultYaml, yaml2);
this.tags = Object.assign({}, Directives.defaultTags, tags2);
}
clone() {
const copy = new Directives(this.yaml, this.tags);
copy.docStart = this.docStart;
return copy;
}
/**
* During parsing, get a Directives instance for the current document and
* update the stream state according to the current version's spec.
*/
atDocument() {
const res = new Directives(this.yaml, this.tags);
switch (this.yaml.version) {
case "1.1":
this.atNextDocument = true;
break;
case "1.2":
this.atNextDocument = false;
this.yaml = {
explicit: Directives.defaultYaml.explicit,
version: "1.2"
};
this.tags = Object.assign({}, Directives.defaultTags);
break;
}
return res;
}
/**
* @param onError - May be called even if the action was successful
* @returns `true` on success
*/
add(line, onError) {
if (this.atNextDocument) {
this.yaml = { explicit: Directives.defaultYaml.explicit, version: "1.1" };
this.tags = Object.assign({}, Directives.defaultTags);
this.atNextDocument = false;
}
const parts = line.trim().split(/[ \t]+/);
const name2 = parts.shift();
switch (name2) {
case "%TAG": {
if (parts.length !== 2) {
onError(0, "%TAG directive should contain exactly two parts");
if (parts.length < 2)
return false;
}
const [handle2, prefix] = parts;
this.tags[handle2] = prefix;
return true;
}
case "%YAML": {
this.yaml.explicit = true;
if (parts.length !== 1) {
onError(0, "%YAML directive should contain exactly one part");
return false;
}
const [version2] = parts;
if (version2 === "1.1" || version2 === "1.2") {
this.yaml.version = version2;
return true;
} else {
const isValid2 = /^\d+\.\d+$/.test(version2);
onError(6, `Unsupported YAML version ${version2}`, isValid2);
return false;
}
}
default:
onError(0, `Unknown directive ${name2}`, true);
return false;
}
}
/**
* Resolves a tag, matching handles to those defined in %TAG directives.
*
* @returns Resolved tag, which may also be the non-specific tag `'!'` or a
* `'!local'` tag, or `null` if unresolvable.
*/
tagName(source2, onError) {
if (source2 === "!")
return "!";
if (source2[0] !== "!") {
onError(`Not a valid tag: ${source2}`);
return null;
}
if (source2[1] === "<") {
const verbatim = source2.slice(2, -1);
if (verbatim === "!" || verbatim === "!!") {
onError(`Verbatim tags aren't resolved, so ${source2} is invalid.`);
return null;
}
if (source2[source2.length - 1] !== ">")
onError("Verbatim tags must end with a >");
return verbatim;
}
const [, handle2, suffix] = source2.match(/^(.*!)([^!]*)$/s);
if (!suffix)
onError(`The ${source2} tag has no suffix`);
const prefix = this.tags[handle2];
if (prefix) {
try {
return prefix + decodeURIComponent(suffix);
} catch (error2) {
onError(String(error2));
return null;
}
}
if (handle2 === "!")
return source2;
onError(`Could not resolve tag: ${source2}`);
return null;
}
/**
* Given a fully resolved tag, returns its printable string form,
* taking into account current tag prefixes and defaults.
*/
tagString(tag) {
for (const [handle2, prefix] of Object.entries(this.tags)) {
if (tag.startsWith(prefix))
return handle2 + escapeTagName(tag.substring(prefix.length));
}
return tag[0] === "!" ? tag : `!<${tag}>`;
}
toString(doc2) {
const lines = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : [];
const tagEntries = Object.entries(this.tags);
let tagNames;
if (doc2 && tagEntries.length > 0 && isNode$2(doc2.contents)) {
const tags2 = {};
visit$1(doc2.contents, (_key, node) => {
if (isNode$2(node) && node.tag)
tags2[node.tag] = true;
});
tagNames = Object.keys(tags2);
} else
tagNames = [];
for (const [handle2, prefix] of tagEntries) {
if (handle2 === "!!" && prefix === "tag:yaml.org,2002:")
continue;
if (!doc2 || tagNames.some((tn) => tn.startsWith(prefix)))
lines.push(`%TAG ${handle2} ${prefix}`);
}
return lines.join("\n");
}
}
Directives.defaultYaml = { explicit: false, version: "1.2" };
Directives.defaultTags = { "!!": "tag:yaml.org,2002:" };
function anchorIsValid(anchor) {
if (/[\x00-\x19\s,[\]{}]/.test(anchor)) {
const sa = JSON.stringify(anchor);
const msg = `Anchor must not contain whitespace or control characters: ${sa}`;
throw new Error(msg);
}
return true;
}
function anchorNames(root2) {
const anchors = /* @__PURE__ */ new Set();
visit$1(root2, {
Value(_key, node) {
if (node.anchor)
anchors.add(node.anchor);
}
});
return anchors;
}
function findNewAnchor(prefix, exclude) {
for (let i2 = 1; true; ++i2) {
const name2 = `${prefix}${i2}`;
if (!exclude.has(name2))
return name2;
}
}
function createNodeAnchors(doc2, prefix) {
const aliasObjects = [];
const sourceObjects = /* @__PURE__ */ new Map();
let prevAnchors = null;
return {
onAnchor: (source2) => {
aliasObjects.push(source2);
if (!prevAnchors)
prevAnchors = anchorNames(doc2);
const anchor = findNewAnchor(prefix, prevAnchors);
prevAnchors.add(anchor);
return anchor;
},
/**
* With circular references, the source node is only resolved after all
* of its child nodes are. This is why anchors are set only after all of
* the nodes have been created.
*/
setAnchors: () => {
for (const source2 of aliasObjects) {
const ref2 = sourceObjects.get(source2);
if (typeof ref2 === "object" && ref2.anchor && (isScalar(ref2.node) || isCollection(ref2.node))) {
ref2.node.anchor = ref2.anchor;
} else {
const error2 = new Error("Failed to resolve repeated object (this should not happen)");
error2.source = source2;
throw error2;
}
}
},
sourceObjects
};
}
function applyReviver(reviver, obj, key2, val) {
if (val && typeof val === "object") {
if (Array.isArray(val)) {
for (let i2 = 0, len = val.length; i2 < len; ++i2) {
const v0 = val[i2];
const v1 = applyReviver(reviver, val, String(i2), v0);
if (v1 === void 0)
delete val[i2];
else if (v1 !== v0)
val[i2] = v1;
}
} else if (val instanceof Map) {
for (const k2 of Array.from(val.keys())) {
const v0 = val.get(k2);
const v1 = applyReviver(reviver, val, k2, v0);
if (v1 === void 0)
val.delete(k2);
else if (v1 !== v0)
val.set(k2, v1);
}
} else if (val instanceof Set) {
for (const v0 of Array.from(val)) {
const v1 = applyReviver(reviver, val, v0, v0);
if (v1 === void 0)
val.delete(v0);
else if (v1 !== v0) {
val.delete(v0);
val.add(v1);
}
}
} else {
for (const [k2, v0] of Object.entries(val)) {
const v1 = applyReviver(reviver, val, k2, v0);
if (v1 === void 0)
delete val[k2];
else if (v1 !== v0)
val[k2] = v1;
}
}
}
return reviver.call(obj, key2, val);
}
function toJS(value, arg, ctx) {
if (Array.isArray(value))
return value.map((v2, i2) => toJS(v2, String(i2), ctx));
if (value && typeof value.toJSON === "function") {
if (!ctx || !hasAnchor(value))
return value.toJSON(arg, ctx);
const data = { aliasCount: 0, count: 1, res: void 0 };
ctx.anchors.set(value, data);
ctx.onCreate = (res2) => {
data.res = res2;
delete ctx.onCreate;
};
const res = value.toJSON(arg, ctx);
if (ctx.onCreate)
ctx.onCreate(res);
return res;
}
if (typeof value === "bigint" && !(ctx == null ? void 0 : ctx.keep))
return Number(value);
return value;
}
class NodeBase {
constructor(type2) {
Object.defineProperty(this, NODE_TYPE, { value: type2 });
}
/** Create a copy of this node. */
clone() {
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
if (this.range)
copy.range = this.range.slice();
return copy;
}
/** A plain JavaScript representation of this node. */
toJS(doc2, { mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
if (!isDocument(doc2))
throw new TypeError("A document argument is required");
const ctx = {
anchors: /* @__PURE__ */ new Map(),
doc: doc2,
keep: true,
mapAsMap: mapAsMap === true,
mapKeyWarned: false,
maxAliasCount: typeof maxAliasCount === "number" ? maxAliasCount : 100
};
const res = toJS(this, "", ctx);
if (typeof onAnchor === "function")
for (const { count, res: res2 } of ctx.anchors.values())
onAnchor(res2, count);
return typeof reviver === "function" ? applyReviver(reviver, { "": res }, "", res) : res;
}
}
let Alias$1 = class Alias extends NodeBase {
constructor(source2) {
super(ALIAS);
this.source = source2;
Object.defineProperty(this, "tag", {
set() {
throw new Error("Alias nodes cannot have tags");
}
});
}
/**
* Resolve the value of this alias within `doc`, finding the last
* instance of the `source` anchor before this node.
*/
resolve(doc2) {
let found = void 0;
visit$1(doc2, {
Node: (_key, node) => {
if (node === this)
return visit$1.BREAK;
if (node.anchor === this.source)
found = node;
}
});
return found;
}
toJSON(_arg, ctx) {
if (!ctx)
return { source: this.source };
const { anchors, doc: doc2, maxAliasCount } = ctx;
const source2 = this.resolve(doc2);
if (!source2) {
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
throw new ReferenceError(msg);
}
let data = anchors.get(source2);
if (!data) {
toJS(source2, null, ctx);
data = anchors.get(source2);
}
if (!data || data.res === void 0) {
const msg = "This should not happen: Alias anchor was not resolved?";
throw new ReferenceError(msg);
}
if (maxAliasCount >= 0) {
data.count += 1;
if (data.aliasCount === 0)
data.aliasCount = getAliasCount(doc2, source2, anchors);
if (data.count * data.aliasCount > maxAliasCount) {
const msg = "Excessive alias count indicates a resource exhaustion attack";
throw new ReferenceError(msg);
}
}
return data.res;
}
toString(ctx, _onComment, _onChompKeep) {
const src = `*${this.source}`;
if (ctx) {
anchorIsValid(this.source);
if (ctx.options.verifyAliasOrder && !ctx.anchors.has(this.source)) {
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
throw new Error(msg);
}
if (ctx.implicitKey)
return `${src} `;
}
return src;
}
};
function getAliasCount(doc2, node, anchors) {
if (isAlias(node)) {
const source2 = node.resolve(doc2);
const anchor = anchors && source2 && anchors.get(source2);
return anchor ? anchor.count * anchor.aliasCount : 0;
} else if (isCollection(node)) {
let count = 0;
for (const item of node.items) {
const c2 = getAliasCount(doc2, item, anchors);
if (c2 > count)
count = c2;
}
return count;
} else if (isPair(node)) {
const kc = getAliasCount(doc2, node.key, anchors);
const vc = getAliasCount(doc2, node.value, anchors);
return Math.max(kc, vc);
}
return 1;
}
const isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object";
class Scalar extends NodeBase {
constructor(value) {
super(SCALAR$1);
this.value = value;
}
toJSON(arg, ctx) {
return (ctx == null ? void 0 : ctx.keep) ? this.value : toJS(this.value, arg, ctx);
}
toString() {
return String(this.value);
}
}
Scalar.BLOCK_FOLDED = "BLOCK_FOLDED";
Scalar.BLOCK_LITERAL = "BLOCK_LITERAL";
Scalar.PLAIN = "PLAIN";
Scalar.QUOTE_DOUBLE = "QUOTE_DOUBLE";
Scalar.QUOTE_SINGLE = "QUOTE_SINGLE";
const defaultTagPrefix = "tag:yaml.org,2002:";
function findTagObject(value, tagName2, tags2) {
if (tagName2) {
const match = tags2.filter((t2) => t2.tag === tagName2);
const tagObj = match.find((t2) => !t2.format) ?? match[0];
if (!tagObj)
throw new Error(`Tag ${tagName2} not found`);
return tagObj;
}
return tags2.find((t2) => {
var _a2;
return ((_a2 = t2.identify) == null ? void 0 : _a2.call(t2, value)) && !t2.format;
});
}
function createNode(value, tagName2, ctx) {
var _a2, _b, _c;
if (isDocument(value))
value = value.contents;
if (isNode$2(value))
return value;
if (isPair(value)) {
const map2 = (_b = (_a2 = ctx.schema[MAP]).createNode) == null ? void 0 : _b.call(_a2, ctx.schema, null, ctx);
map2.items.push(value);
return map2;
}
if (value instanceof String || value instanceof Number || value instanceof Boolean || typeof BigInt !== "undefined" && value instanceof BigInt) {
value = value.valueOf();
}
const { aliasDuplicateObjects, onAnchor, onTagObj, schema: schema2, sourceObjects } = ctx;
let ref2 = void 0;
if (aliasDuplicateObjects && value && typeof value === "object") {
ref2 = sourceObjects.get(value);
if (ref2) {
if (!ref2.anchor)
ref2.anchor = onAnchor(value);
return new Alias$1(ref2.anchor);
} else {
ref2 = { anchor: null, node: null };
sourceObjects.set(value, ref2);
}
}
if (tagName2 == null ? void 0 : tagName2.startsWith("!!"))
tagName2 = defaultTagPrefix + tagName2.slice(2);
let tagObj = findTagObject(value, tagName2, schema2.tags);
if (!tagObj) {
if (value && typeof value.toJSON === "function") {
value = value.toJSON();
}
if (!value || typeof value !== "object") {
const node2 = new Scalar(value);
if (ref2)
ref2.node = node2;
return node2;
}
tagObj = value instanceof Map ? schema2[MAP] : Symbol.iterator in Object(value) ? schema2[SEQ] : schema2[MAP];
}
if (onTagObj) {
onTagObj(tagObj);
delete ctx.onTagObj;
}
const node = (tagObj == null ? void 0 : tagObj.createNode) ? tagObj.createNode(ctx.schema, value, ctx) : typeof ((_c = tagObj == null ? void 0 : tagObj.nodeClass) == null ? void 0 : _c.from) === "function" ? tagObj.nodeClass.from(ctx.schema, value, ctx) : new Scalar(value);
if (tagName2)
node.tag = tagName2;
else if (!tagObj.default)
node.tag = tagObj.tag;
if (ref2)
ref2.node = node;
return node;
}
function collectionFromPath(schema2, path2, value) {
let v2 = value;
for (let i2 = path2.length - 1; i2 >= 0; --i2) {
const k2 = path2[i2];
if (typeof k2 === "number" && Number.isInteger(k2) && k2 >= 0) {
const a2 = [];
a2[k2] = v2;
v2 = a2;
} else {
v2 = /* @__PURE__ */ new Map([[k2, v2]]);
}
}
return createNode(v2, void 0, {
aliasDuplicateObjects: false,
keepUndefined: false,
onAnchor: () => {
throw new Error("This should not happen, please report a bug.");
},
schema: schema2,
sourceObjects: /* @__PURE__ */ new Map()
});
}
const isEmptyPath = (path2) => path2 == null || typeof path2 === "object" && !!path2[Symbol.iterator]().next().done;
class Collection extends NodeBase {
constructor(type2, schema2) {
super(type2);
Object.defineProperty(this, "schema", {
value: schema2,
configurable: true,
enumerable: false,
writable: true
});
}
/**
* Create a copy of this collection.
*
* @param schema - If defined, overwrites the original's schema
*/
clone(schema2) {
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
if (schema2)
copy.schema = schema2;
copy.items = copy.items.map((it) => isNode$2(it) || isPair(it) ? it.clone(schema2) : it);
if (this.range)
copy.range = this.range.slice();
return copy;
}
/**
* Adds a value to the collection. For `!!map` and `!!omap` the value must
* be a Pair instance or a `{ key, value }` object, which may not have a key
* that already exists in the map.
*/
addIn(path2, value) {
if (isEmptyPath(path2))
this.add(value);
else {
const [key2, ...rest] = path2;
const node = this.get(key2, true);
if (isCollection(node))
node.addIn(rest, value);
else if (node === void 0 && this.schema)
this.set(key2, collectionFromPath(this.schema, rest, value));
else
throw new Error(`Expected YAML collection at ${key2}. Remaining path: ${rest}`);
}
}
/**
* Removes a value from the collection.
* @returns `true` if the item was found and removed.
*/
deleteIn(path2) {
const [key2, ...rest] = path2;
if (rest.length === 0)
return this.delete(key2);
const node = this.get(key2, true);
if (isCollection(node))
return node.deleteIn(rest);
else
throw new Error(`Expected YAML collection at ${key2}. Remaining path: ${rest}`);
}
/**
* Returns item at `key`, or `undefined` if not found. By default unwraps
* scalar values from their surrounding node; to disable set `keepScalar` to
* `true` (collections are always returned intact).
*/
getIn(path2, keepScalar) {
const [key2, ...rest] = path2;
const node = this.get(key2, true);
if (rest.length === 0)
return !keepScalar && isScalar(node) ? node.value : node;
else
return isCollection(node) ? node.getIn(rest, keepScalar) : void 0;
}
hasAllNullValues(allowScalar) {
return this.items.every((node) => {
if (!isPair(node))
return false;
const n2 = node.value;
return n2 == null || allowScalar && isScalar(n2) && n2.value == null && !n2.commentBefore && !n2.comment && !n2.tag;
});
}
/**
* Checks if the collection includes a value with the key `key`.
*/
hasIn(path2) {
const [key2, ...rest] = path2;
if (rest.length === 0)
return this.has(key2);
const node = this.get(key2, true);
return isCollection(node) ? node.hasIn(rest) : false;
}
/**
* Sets a value in this collection. For `!!set`, `value` needs to be a
* boolean to add/remove the item from the set.
*/
setIn(path2, value) {
const [key2, ...rest] = path2;
if (rest.length === 0) {
this.set(key2, value);
} else {
const node = this.get(key2, true);
if (isCollection(node))
node.setIn(rest, value);
else if (node === void 0 && this.schema)
this.set(key2, collectionFromPath(this.schema, rest, value));
else
throw new Error(`Expected YAML collection at ${key2}. Remaining path: ${rest}`);
}
}
}
Collection.maxFlowStringSingleLineLength = 60;
const stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#");
function indentComment(comment2, indent) {
if (/^\n+$/.test(comment2))
return comment2.substring(1);
return indent ? comment2.replace(/^(?! *$)/gm, indent) : comment2;
}
const lineComment = (str, indent, comment2) => str.endsWith("\n") ? indentComment(comment2, indent) : comment2.includes("\n") ? "\n" + indentComment(comment2, indent) : (str.endsWith(" ") ? "" : " ") + comment2;
const FOLD_FLOW = "flow";
const FOLD_BLOCK = "block";
const FOLD_QUOTED = "quoted";
function foldFlowLines(text2, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
if (!lineWidth || lineWidth < 0)
return text2;
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
if (text2.length <= endStep)
return text2;
const folds = [];
const escapedFolds = {};
let end = lineWidth - indent.length;
if (typeof indentAtStart === "number") {
if (indentAtStart > lineWidth - Math.max(2, minContentWidth))
folds.push(0);
else
end = lineWidth - indentAtStart;
}
let split = void 0;
let prev = void 0;
let overflow = false;
let i2 = -1;
let escStart = -1;
let escEnd = -1;
if (mode === FOLD_BLOCK) {
i2 = consumeMoreIndentedLines(text2, i2, indent.length);
if (i2 !== -1)
end = i2 + endStep;
}
for (let ch; ch = text2[i2 += 1]; ) {
if (mode === FOLD_QUOTED && ch === "\\") {
escStart = i2;
switch (text2[i2 + 1]) {
case "x":
i2 += 3;
break;
case "u":
i2 += 5;
break;
case "U":
i2 += 9;
break;
default:
i2 += 1;
}
escEnd = i2;
}
if (ch === "\n") {
if (mode === FOLD_BLOCK)
i2 = consumeMoreIndentedLines(text2, i2, indent.length);
end = i2 + indent.length + endStep;
split = void 0;
} else {
if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
const next = text2[i2 + 1];
if (next && next !== " " && next !== "\n" && next !== " ")
split = i2;
}
if (i2 >= end) {
if (split) {
folds.push(split);
end = split + endStep;
split = void 0;
} else if (mode === FOLD_QUOTED) {
while (prev === " " || prev === " ") {
prev = ch;
ch = text2[i2 += 1];
overflow = true;
}
const j2 = i2 > escEnd + 1 ? i2 - 2 : escStart - 1;
if (escapedFolds[j2])
return text2;
folds.push(j2);
escapedFolds[j2] = true;
end = j2 + endStep;
split = void 0;
} else {
overflow = true;
}
}
}
prev = ch;
}
if (overflow && onOverflow)
onOverflow();
if (folds.length === 0)
return text2;
if (onFold)
onFold();
let res = text2.slice(0, folds[0]);
for (let i3 = 0; i3 < folds.length; ++i3) {
const fold = folds[i3];
const end2 = folds[i3 + 1] || text2.length;
if (fold === 0)
res = `
${indent}${text2.slice(0, end2)}`;
else {
if (mode === FOLD_QUOTED && escapedFolds[fold])
res += `${text2[fold]}\\`;
res += `
${indent}${text2.slice(fold + 1, end2)}`;
}
}
return res;
}
function consumeMoreIndentedLines(text2, i2, indent) {
let end = i2;
let start = i2 + 1;
let ch = text2[start];
while (ch === " " || ch === " ") {
if (i2 < start + indent) {
ch = text2[++i2];
} else {
do {
ch = text2[++i2];
} while (ch && ch !== "\n");
end = i2;
start = i2 + 1;
ch = text2[start];
}
}
return end;
}
const getFoldOptions = (ctx, isBlock2) => ({
indentAtStart: isBlock2 ? ctx.indent.length : ctx.indentAtStart,
lineWidth: ctx.options.lineWidth,
minContentWidth: ctx.options.minContentWidth
});
const containsDocumentMarker = (str) => /^(%|---|\.\.\.)/m.test(str);
function lineLengthOverLimit(str, lineWidth, indentLength) {
if (!lineWidth || lineWidth < 0)
return false;
const limit = lineWidth - indentLength;
const strLen = str.length;
if (strLen <= limit)
return false;
for (let i2 = 0, start = 0; i2 < strLen; ++i2) {
if (str[i2] === "\n") {
if (i2 - start > limit)
return true;
start = i2 + 1;
if (strLen - start <= limit)
return false;
}
}
return true;
}
function doubleQuotedString(value, ctx) {
const json2 = JSON.stringify(value);
if (ctx.options.doubleQuotedAsJSON)
return json2;
const { implicitKey } = ctx;
const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength;
const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
let str = "";
let start = 0;
for (let i2 = 0, ch = json2[i2]; ch; ch = json2[++i2]) {
if (ch === " " && json2[i2 + 1] === "\\" && json2[i2 + 2] === "n") {
str += json2.slice(start, i2) + "\\ ";
i2 += 1;
start = i2;
ch = "\\";
}
if (ch === "\\")
switch (json2[i2 + 1]) {
case "u":
{
str += json2.slice(start, i2);
const code = json2.substr(i2 + 2, 4);
switch (code) {
case "0000":
str += "\\0";
break;
case "0007":
str += "\\a";
break;
case "000b":
str += "\\v";
break;
case "001b":
str += "\\e";
break;
case "0085":
str += "\\N";
break;
case "00a0":
str += "\\_";
break;
case "2028":
str += "\\L";
break;
case "2029":
str += "\\P";
break;
default:
if (code.substr(0, 2) === "00")
str += "\\x" + code.substr(2);
else
str += json2.substr(i2, 6);
}
i2 += 5;
start = i2 + 1;
}
break;
case "n":
if (implicitKey || json2[i2 + 2] === '"' || json2.length < minMultiLineLength) {
i2 += 1;
} else {
str += json2.slice(start, i2) + "\n\n";
while (json2[i2 + 2] === "\\" && json2[i2 + 3] === "n" && json2[i2 + 4] !== '"') {
str += "\n";
i2 += 2;
}
str += indent;
if (json2[i2 + 2] === " ")
str += "\\";
i2 += 1;
start = i2 + 1;
}
break;
default:
i2 += 1;
}
}
str = start ? str + json2.slice(start) : json2;
return implicitKey ? str : foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx, false));
}
function singleQuotedString(value, ctx) {
if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value))
return doubleQuotedString(value, ctx);
const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&
${indent}`) + "'";
return ctx.implicitKey ? res : foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx, false));
}
function quotedString(value, ctx) {
const { singleQuote } = ctx.options;
let qs;
if (singleQuote === false)
qs = doubleQuotedString;
else {
const hasDouble = value.includes('"');
const hasSingle = value.includes("'");
if (hasDouble && !hasSingle)
qs = singleQuotedString;
else if (hasSingle && !hasDouble)
qs = doubleQuotedString;
else
qs = singleQuote ? singleQuotedString : doubleQuotedString;
}
return qs(value, ctx);
}
let blockEndNewlines;
try {
blockEndNewlines = new RegExp("(^|(?<!\n))\n+(?!\n|$)", "g");
} catch {
blockEndNewlines = /\n+(?!\n|$)/g;
}
function blockString({ comment: comment2, type: type2, value }, ctx, onComment, onChompKeep) {
const { blockQuote, commentString, lineWidth } = ctx.options;
if (!blockQuote || /\n[\t ]+$/.test(value) || /^\s*$/.test(value)) {
return quotedString(value, ctx);
}
const indent = ctx.indent || (ctx.forceBlockIndent || containsDocumentMarker(value) ? " " : "");
const literal2 = blockQuote === "literal" ? true : blockQuote === "folded" || type2 === Scalar.BLOCK_FOLDED ? false : type2 === Scalar.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, lineWidth, indent.length);
if (!value)
return literal2 ? "|\n" : ">\n";
let chomp;
let endStart;
for (endStart = value.length; endStart > 0; --endStart) {
const ch = value[endStart - 1];
if (ch !== "\n" && ch !== " " && ch !== " ")
break;
}
let end = value.substring(endStart);
const endNlPos = end.indexOf("\n");
if (endNlPos === -1) {
chomp = "-";
} else if (value === end || endNlPos !== end.length - 1) {
chomp = "+";
if (onChompKeep)
onChompKeep();
} else {
chomp = "";
}
if (end) {
value = value.slice(0, -end.length);
if (end[end.length - 1] === "\n")
end = end.slice(0, -1);
end = end.replace(blockEndNewlines, `$&${indent}`);
}
let startWithSpace = false;
let startEnd;
let startNlPos = -1;
for (startEnd = 0; startEnd < value.length; ++startEnd) {
const ch = value[startEnd];
if (ch === " ")
startWithSpace = true;
else if (ch === "\n")
startNlPos = startEnd;
else
break;
}
let start = value.substring(0, startNlPos < startEnd ? startNlPos + 1 : startEnd);
if (start) {
value = value.substring(start.length);
start = start.replace(/\n+/g, `$&${indent}`);
}
const indentSize = indent ? "2" : "1";
let header = (literal2 ? "|" : ">") + (startWithSpace ? indentSize : "") + chomp;
if (comment2) {
header += " " + commentString(comment2.replace(/ ?[\r\n]+/g, " "));
if (onComment)
onComment();
}
if (literal2) {
value = value.replace(/\n+/g, `$&${indent}`);
return `${header}
${indent}${start}${value}${end}`;
}
value = value.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${indent}`);
const body2 = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
return `${header}
${indent}${body2}`;
}
function plainString(item, ctx, onComment, onChompKeep) {
const { type: type2, value } = item;
const { actualString, implicitKey, indent, indentStep, inFlow } = ctx;
if (implicitKey && value.includes("\n") || inFlow && /[[\]{},]/.test(value)) {
return quotedString(value, ctx);
}
if (!value || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
return implicitKey || inFlow || !value.includes("\n") ? quotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep);
}
if (!implicitKey && !inFlow && type2 !== Scalar.PLAIN && value.includes("\n")) {
return blockString(item, ctx, onComment, onChompKeep);
}
if (containsDocumentMarker(value)) {
if (indent === "") {
ctx.forceBlockIndent = true;
return blockString(item, ctx, onComment, onChompKeep);
} else if (implicitKey && indent === indentStep) {
return quotedString(value, ctx);
}
}
const str = value.replace(/\n+/g, `$&
${indent}`);
if (actualString) {
const test = (tag) => {
var _a2;
return tag.default && tag.tag !== "tag:yaml.org,2002:str" && ((_a2 = tag.test) == null ? void 0 : _a2.test(str));
};
const { compat, tags: tags2 } = ctx.doc.schema;
if (tags2.some(test) || (compat == null ? void 0 : compat.some(test)))
return quotedString(value, ctx);
}
return implicitKey ? str : foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx, false));
}
function stringifyString(item, ctx, onComment, onChompKeep) {
const { implicitKey, inFlow } = ctx;
const ss = typeof item.value === "string" ? item : Object.assign({}, item, { value: String(item.value) });
let { type: type2 } = item;
if (type2 !== Scalar.QUOTE_DOUBLE) {
if (/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(ss.value))
type2 = Scalar.QUOTE_DOUBLE;
}
const _stringify = (_type) => {
switch (_type) {
case Scalar.BLOCK_FOLDED:
case Scalar.BLOCK_LITERAL:
return implicitKey || inFlow ? quotedString(ss.value, ctx) : blockString(ss, ctx, onComment, onChompKeep);
case Scalar.QUOTE_DOUBLE:
return doubleQuotedString(ss.value, ctx);
case Scalar.QUOTE_SINGLE:
return singleQuotedString(ss.value, ctx);
case Scalar.PLAIN:
return plainString(ss, ctx, onComment, onChompKeep);
default:
return null;
}
};
let res = _stringify(type2);
if (res === null) {
const { defaultKeyType, defaultStringType } = ctx.options;
const t2 = implicitKey && defaultKeyType || defaultStringType;
res = _stringify(t2);
if (res === null)
throw new Error(`Unsupported default string type ${t2}`);
}
return res;
}
function createStringifyContext(doc2, options) {
const opt = Object.assign({
blockQuote: true,
commentString: stringifyComment,
defaultKeyType: null,
defaultStringType: "PLAIN",
directives: null,
doubleQuotedAsJSON: false,
doubleQuotedMinMultiLineLength: 40,
falseStr: "false",
flowCollectionPadding: true,
indentSeq: true,
lineWidth: 80,
minContentWidth: 20,
nullStr: "null",
simpleKeys: false,
singleQuote: null,
trueStr: "true",
verifyAliasOrder: true
}, doc2.schema.toStringOptions, options);
let inFlow;
switch (opt.collectionStyle) {
case "block":
inFlow = false;
break;
case "flow":
inFlow = true;
break;
default:
inFlow = null;
}
return {
anchors: /* @__PURE__ */ new Set(),
doc: doc2,
flowCollectionPadding: opt.flowCollectionPadding ? " " : "",
indent: "",
indentStep: typeof opt.indent === "number" ? " ".repeat(opt.indent) : " ",
inFlow,
options: opt
};
}
function getTagObject(tags2, item) {
var _a2;
if (item.tag) {
const match = tags2.filter((t2) => t2.tag === item.tag);
if (match.length > 0)
return match.find((t2) => t2.format === item.format) ?? match[0];
}
let tagObj = void 0;
let obj;
if (isScalar(item)) {
obj = item.value;
const match = tags2.filter((t2) => {
var _a3;
return (_a3 = t2.identify) == null ? void 0 : _a3.call(t2, obj);
});
tagObj = match.find((t2) => t2.format === item.format) ?? match.find((t2) => !t2.format);
} else {
obj = item;
tagObj = tags2.find((t2) => t2.nodeClass && obj instanceof t2.nodeClass);
}
if (!tagObj) {
const name2 = ((_a2 = obj == null ? void 0 : obj.constructor) == null ? void 0 : _a2.name) ?? typeof obj;
throw new Error(`Tag not resolved for ${name2} value`);
}
return tagObj;
}
function stringifyProps(node, tagObj, { anchors, doc: doc2 }) {
if (!doc2.directives)
return "";
const props = [];
const anchor = (isScalar(node) || isCollection(node)) && node.anchor;
if (anchor && anchorIsValid(anchor)) {
anchors.add(anchor);
props.push(`&${anchor}`);
}
const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
if (tag)
props.push(doc2.directives.tagString(tag));
return props.join(" ");
}
function stringify$3(item, ctx, onComment, onChompKeep) {
var _a2;
if (isPair(item))
return item.toString(ctx, onComment, onChompKeep);
if (isAlias(item)) {
if (ctx.doc.directives)
return item.toString(ctx);
if ((_a2 = ctx.resolvedAliases) == null ? void 0 : _a2.has(item)) {
throw new TypeError(`Cannot stringify circular structure without alias nodes`);
} else {
if (ctx.resolvedAliases)
ctx.resolvedAliases.add(item);
else
ctx.resolvedAliases = /* @__PURE__ */ new Set([item]);
item = item.resolve(ctx.doc);
}
}
let tagObj = void 0;
const node = isNode$2(item) ? item : ctx.doc.createNode(item, { onTagObj: (o2) => tagObj = o2 });
if (!tagObj)
tagObj = getTagObject(ctx.doc.schema.tags, node);
const props = stringifyProps(node, tagObj, ctx);
if (props.length > 0)
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
const str = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : isScalar(node) ? stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep);
if (!props)
return str;
return isScalar(node) || str[0] === "{" || str[0] === "[" ? `${props} ${str}` : `${props}
${ctx.indent}${str}`;
}
function stringifyPair({ key: key2, value }, ctx, onComment, onChompKeep) {
const { allNullValues, doc: doc2, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
let keyComment = isNode$2(key2) && key2.comment || null;
if (simpleKeys) {
if (keyComment) {
throw new Error("With simple keys, key nodes cannot have comments");
}
if (isCollection(key2) || !isNode$2(key2) && typeof key2 === "object") {
const msg = "With simple keys, collection cannot be used as a key value";
throw new Error(msg);
}
}
let explicitKey = !simpleKeys && (!key2 || keyComment && value == null && !ctx.inFlow || isCollection(key2) || (isScalar(key2) ? key2.type === Scalar.BLOCK_FOLDED || key2.type === Scalar.BLOCK_LITERAL : typeof key2 === "object"));
ctx = Object.assign({}, ctx, {
allNullValues: false,
implicitKey: !explicitKey && (simpleKeys || !allNullValues),
indent: indent + indentStep
});
let keyCommentDone = false;
let chompKeep = false;
let str = stringify$3(key2, ctx, () => keyCommentDone = true, () => chompKeep = true);
if (!explicitKey && !ctx.inFlow && str.length > 1024) {
if (simpleKeys)
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
explicitKey = true;
}
if (ctx.inFlow) {
if (allNullValues || value == null) {
if (keyCommentDone && onComment)
onComment();
return str === "" ? "?" : explicitKey ? `? ${str}` : str;
}
} else if (allNullValues && !simpleKeys || value == null && explicitKey) {
str = `? ${str}`;
if (keyComment && !keyCommentDone) {
str += lineComment(str, ctx.indent, commentString(keyComment));
} else if (chompKeep && onChompKeep)
onChompKeep();
return str;
}
if (keyCommentDone)
keyComment = null;
if (explicitKey) {
if (keyComment)
str += lineComment(str, ctx.indent, commentString(keyComment));
str = `? ${str}
${indent}:`;
} else {
str = `${str}:`;
if (keyComment)
str += lineComment(str, ctx.indent, commentString(keyComment));
}
let vsb, vcb, valueComment;
if (isNode$2(value)) {
vsb = !!value.spaceBefore;
vcb = value.commentBefore;
valueComment = value.comment;
} else {
vsb = false;
vcb = null;
valueComment = null;
if (value && typeof value === "object")
value = doc2.createNode(value);
}
ctx.implicitKey = false;
if (!explicitKey && !keyComment && isScalar(value))
ctx.indentAtStart = str.length + 1;
chompKeep = false;
if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && isSeq(value) && !value.flow && !value.tag && !value.anchor) {
ctx.indent = ctx.indent.substring(2);
}
let valueCommentDone = false;
const valueStr = stringify$3(value, ctx, () => valueCommentDone = true, () => chompKeep = true);
let ws = " ";
if (keyComment || vsb || vcb) {
ws = vsb ? "\n" : "";
if (vcb) {
const cs = commentString(vcb);
ws += `
${indentComment(cs, ctx.indent)}`;
}
if (valueStr === "" && !ctx.inFlow) {
if (ws === "\n")
ws = "\n\n";
} else {
ws += `
${ctx.indent}`;
}
} else if (!explicitKey && isCollection(value)) {
const vs0 = valueStr[0];
const nl0 = valueStr.indexOf("\n");
const hasNewline = nl0 !== -1;
const flow = ctx.inFlow ?? value.flow ?? value.items.length === 0;
if (hasNewline || !flow) {
let hasPropsLine = false;
if (hasNewline && (vs0 === "&" || vs0 === "!")) {
let sp0 = valueStr.indexOf(" ");
if (vs0 === "&" && sp0 !== -1 && sp0 < nl0 && valueStr[sp0 + 1] === "!") {
sp0 = valueStr.indexOf(" ", sp0 + 1);
}
if (sp0 === -1 || nl0 < sp0)
hasPropsLine = true;
}
if (!hasPropsLine)
ws = `
${ctx.indent}`;
}
} else if (valueStr === "" || valueStr[0] === "\n") {
ws = "";
}
str += ws + valueStr;
if (ctx.inFlow) {
if (valueCommentDone && onComment)
onComment();
} else if (valueComment && !valueCommentDone) {
str += lineComment(str, ctx.indent, commentString(valueComment));
} else if (chompKeep && onChompKeep) {
onChompKeep();
}
return str;
}
function warn$1(logLevel, warning) {
if (logLevel === "debug" || logLevel === "warn") {
if (typeof process !== "undefined" && process.emitWarning)
process.emitWarning(warning);
else
console.warn(warning);
}
}
const MERGE_KEY = "<<";
function addPairToJSMap(ctx, map2, { key: key2, value }) {
if ((ctx == null ? void 0 : ctx.doc.schema.merge) && isMergeKey(key2)) {
value = isAlias(value) ? value.resolve(ctx.doc) : value;
if (isSeq(value))
for (const it of value.items)
mergeToJSMap(ctx, map2, it);
else if (Array.isArray(value))
for (const it of value)
mergeToJSMap(ctx, map2, it);
else
mergeToJSMap(ctx, map2, value);
} else {
const jsKey = toJS(key2, "", ctx);
if (map2 instanceof Map) {
map2.set(jsKey, toJS(value, jsKey, ctx));
} else if (map2 instanceof Set) {
map2.add(jsKey);
} else {
const stringKey = stringifyKey(key2, jsKey, ctx);
const jsValue = toJS(value, stringKey, ctx);
if (stringKey in map2)
Object.defineProperty(map2, stringKey, {
value: jsValue,
writable: true,
enumerable: true,
configurable: true
});
else
map2[stringKey] = jsValue;
}
}
return map2;
}
const isMergeKey = (key2) => key2 === MERGE_KEY || isScalar(key2) && key2.value === MERGE_KEY && (!key2.type || key2.type === Scalar.PLAIN);
function mergeToJSMap(ctx, map2, value) {
const source2 = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
if (!isMap(source2))
throw new Error("Merge sources must be maps or map aliases");
const srcMap = source2.toJSON(null, ctx, Map);
for (const [key2, value2] of srcMap) {
if (map2 instanceof Map) {
if (!map2.has(key2))
map2.set(key2, value2);
} else if (map2 instanceof Set) {
map2.add(key2);
} else if (!Object.prototype.hasOwnProperty.call(map2, key2)) {
Object.defineProperty(map2, key2, {
value: value2,
writable: true,
enumerable: true,
configurable: true
});
}
}
return map2;
}
function stringifyKey(key2, jsKey, ctx) {
if (jsKey === null)
return "";
if (typeof jsKey !== "object")
return String(jsKey);
if (isNode$2(key2) && (ctx == null ? void 0 : ctx.doc)) {
const strCtx = createStringifyContext(ctx.doc, {});
strCtx.anchors = /* @__PURE__ */ new Set();
for (const node of ctx.anchors.keys())
strCtx.anchors.add(node.anchor);
strCtx.inFlow = true;
strCtx.inStringifyKey = true;
const strKey = key2.toString(strCtx);
if (!ctx.mapKeyWarned) {
let jsonStr = JSON.stringify(strKey);
if (jsonStr.length > 40)
jsonStr = jsonStr.substring(0, 36) + '..."';
warn$1(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
ctx.mapKeyWarned = true;
}
return strKey;
}
return JSON.stringify(jsKey);
}
function createPair(key2, value, ctx) {
const k2 = createNode(key2, void 0, ctx);
const v2 = createNode(value, void 0, ctx);
return new Pair(k2, v2);
}
class Pair {
constructor(key2, value = null) {
Object.defineProperty(this, NODE_TYPE, { value: PAIR });
this.key = key2;
this.value = value;
}
clone(schema2) {
let { key: key2, value } = this;
if (isNode$2(key2))
key2 = key2.clone(schema2);
if (isNode$2(value))
value = value.clone(schema2);
return new Pair(key2, value);
}
toJSON(_2, ctx) {
const pair2 = (ctx == null ? void 0 : ctx.mapAsMap) ? /* @__PURE__ */ new Map() : {};
return addPairToJSMap(ctx, pair2, this);
}
toString(ctx, onComment, onChompKeep) {
return (ctx == null ? void 0 : ctx.doc) ? stringifyPair(this, ctx, onComment, onChompKeep) : JSON.stringify(this);
}
}
function stringifyCollection(collection, ctx, options) {
const flow = ctx.inFlow ?? collection.flow;
const stringify2 = flow ? stringifyFlowCollection : stringifyBlockCollection;
return stringify2(collection, ctx, options);
}
function stringifyBlockCollection({ comment: comment2, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
const { indent, options: { commentString } } = ctx;
const itemCtx = Object.assign({}, ctx, { indent: itemIndent, type: null });
let chompKeep = false;
const lines = [];
for (let i2 = 0; i2 < items.length; ++i2) {
const item = items[i2];
let comment3 = null;
if (isNode$2(item)) {
if (!chompKeep && item.spaceBefore)
lines.push("");
addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
if (item.comment)
comment3 = item.comment;
} else if (isPair(item)) {
const ik = isNode$2(item.key) ? item.key : null;
if (ik) {
if (!chompKeep && ik.spaceBefore)
lines.push("");
addCommentBefore(ctx, lines, ik.commentBefore, chompKeep);
}
}
chompKeep = false;
let str2 = stringify$3(item, itemCtx, () => comment3 = null, () => chompKeep = true);
if (comment3)
str2 += lineComment(str2, itemIndent, commentString(comment3));
if (chompKeep && comment3)
chompKeep = false;
lines.push(blockItemPrefix + str2);
}
let str;
if (lines.length === 0) {
str = flowChars.start + flowChars.end;
} else {
str = lines[0];
for (let i2 = 1; i2 < lines.length; ++i2) {
const line = lines[i2];
str += line ? `
${indent}${line}` : "\n";
}
}
if (comment2) {
str += "\n" + indentComment(commentString(comment2), indent);
if (onComment)
onComment();
} else if (chompKeep && onChompKeep)
onChompKeep();
return str;
}
function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
itemIndent += indentStep;
const itemCtx = Object.assign({}, ctx, {
indent: itemIndent,
inFlow: true,
type: null
});
let reqNewline = false;
let linesAtValue = 0;
const lines = [];
for (let i2 = 0; i2 < items.length; ++i2) {
const item = items[i2];
let comment2 = null;
if (isNode$2(item)) {
if (item.spaceBefore)
lines.push("");
addCommentBefore(ctx, lines, item.commentBefore, false);
if (item.comment)
comment2 = item.comment;
} else if (isPair(item)) {
const ik = isNode$2(item.key) ? item.key : null;
if (ik) {
if (ik.spaceBefore)
lines.push("");
addCommentBefore(ctx, lines, ik.commentBefore, false);
if (ik.comment)
reqNewline = true;
}
const iv = isNode$2(item.value) ? item.value : null;
if (iv) {
if (iv.comment)
comment2 = iv.comment;
if (iv.commentBefore)
reqNewline = true;
} else if (item.value == null && (ik == null ? void 0 : ik.comment)) {
comment2 = ik.comment;
}
}
if (comment2)
reqNewline = true;
let str = stringify$3(item, itemCtx, () => comment2 = null);
if (i2 < items.length - 1)
str += ",";
if (comment2)
str += lineComment(str, itemIndent, commentString(comment2));
if (!reqNewline && (lines.length > linesAtValue || str.includes("\n")))
reqNewline = true;
lines.push(str);
linesAtValue = lines.length;
}
const { start, end } = flowChars;
if (lines.length === 0) {
return start + end;
} else {
if (!reqNewline) {
const len = lines.reduce((sum, line) => sum + line.length + 2, 2);
reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
}
if (reqNewline) {
let str = start;
for (const line of lines)
str += line ? `
${indentStep}${indent}${line}` : "\n";
return `${str}
${indent}${end}`;
} else {
return `${start}${fcPadding}${lines.join(" ")}${fcPadding}${end}`;
}
}
}
function addCommentBefore({ indent, options: { commentString } }, lines, comment2, chompKeep) {
if (comment2 && chompKeep)
comment2 = comment2.replace(/^\n+/, "");
if (comment2) {
const ic = indentComment(commentString(comment2), indent);
lines.push(ic.trimStart());
}
}
function findPair(items, key2) {
const k2 = isScalar(key2) ? key2.value : key2;
for (const it of items) {
if (isPair(it)) {
if (it.key === key2 || it.key === k2)
return it;
if (isScalar(it.key) && it.key.value === k2)
return it;
}
}
return void 0;
}
class YAMLMap extends Collection {
static get tagName() {
return "tag:yaml.org,2002:map";
}
constructor(schema2) {
super(MAP, schema2);
this.items = [];
}
/**
* A generic collection parsing method that can be extended
* to other node classes that inherit from YAMLMap
*/
static from(schema2, obj, ctx) {
const { keepUndefined, replacer: replacer2 } = ctx;
const map2 = new this(schema2);
const add2 = (key2, value) => {
if (typeof replacer2 === "function")
value = replacer2.call(obj, key2, value);
else if (Array.isArray(replacer2) && !replacer2.includes(key2))
return;
if (value !== void 0 || keepUndefined)
map2.items.push(createPair(key2, value, ctx));
};
if (obj instanceof Map) {
for (const [key2, value] of obj)
add2(key2, value);
} else if (obj && typeof obj === "object") {
for (const key2 of Object.keys(obj))
add2(key2, obj[key2]);
}
if (typeof schema2.sortMapEntries === "function") {
map2.items.sort(schema2.sortMapEntries);
}
return map2;
}
/**
* Adds a value to the collection.
*
* @param overwrite - If not set `true`, using a key that is already in the
* collection will throw. Otherwise, overwrites the previous value.
*/
add(pair2, overwrite) {
var _a2;
let _pair;
if (isPair(pair2))
_pair = pair2;
else if (!pair2 || typeof pair2 !== "object" || !("key" in pair2)) {
_pair = new Pair(pair2, pair2 == null ? void 0 : pair2.value);
} else
_pair = new Pair(pair2.key, pair2.value);
const prev = findPair(this.items, _pair.key);
const sortEntries = (_a2 = this.schema) == null ? void 0 : _a2.sortMapEntries;
if (prev) {
if (!overwrite)
throw new Error(`Key ${_pair.key} already set`);
if (isScalar(prev.value) && isScalarValue(_pair.value))
prev.value.value = _pair.value;
else
prev.value = _pair.value;
} else if (sortEntries) {
const i2 = this.items.findIndex((item) => sortEntries(_pair, item) < 0);
if (i2 === -1)
this.items.push(_pair);
else
this.items.splice(i2, 0, _pair);
} else {
this.items.push(_pair);
}
}
delete(key2) {
const it = findPair(this.items, key2);
if (!it)
return false;
const del = this.items.splice(this.items.indexOf(it), 1);
return del.length > 0;
}
get(key2, keepScalar) {
const it = findPair(this.items, key2);
const node = it == null ? void 0 : it.value;
return (!keepScalar && isScalar(node) ? node.value : node) ?? void 0;
}
has(key2) {
return !!findPair(this.items, key2);
}
set(key2, value) {
this.add(new Pair(key2, value), true);
}
/**
* @param ctx - Conversion context, originally set in Document#toJS()
* @param {Class} Type - If set, forces the returned collection type
* @returns Instance of Type, Map, or Object
*/
toJSON(_2, ctx, Type) {
const map2 = Type ? new Type() : (ctx == null ? void 0 : ctx.mapAsMap) ? /* @__PURE__ */ new Map() : {};
if (ctx == null ? void 0 : ctx.onCreate)
ctx.onCreate(map2);
for (const item of this.items)
addPairToJSMap(ctx, map2, item);
return map2;
}
toString(ctx, onComment, onChompKeep) {
if (!ctx)
return JSON.stringify(this);
for (const item of this.items) {
if (!isPair(item))
throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`);
}
if (!ctx.allNullValues && this.hasAllNullValues(false))
ctx = Object.assign({}, ctx, { allNullValues: true });
return stringifyCollection(this, ctx, {
blockItemPrefix: "",
flowChars: { start: "{", end: "}" },
itemIndent: ctx.indent || "",
onChompKeep,
onComment
});
}
}
const map = {
collection: "map",
default: true,
nodeClass: YAMLMap,
tag: "tag:yaml.org,2002:map",
resolve(map2, onError) {
if (!isMap(map2))
onError("Expected a mapping for this tag");
return map2;
},
createNode: (schema2, obj, ctx) => YAMLMap.from(schema2, obj, ctx)
};
class YAMLSeq extends Collection {
static get tagName() {
return "tag:yaml.org,2002:seq";
}
constructor(schema2) {
super(SEQ, schema2);
this.items = [];
}
add(value) {
this.items.push(value);
}
/**
* Removes a value from the collection.
*
* `key` must contain a representation of an integer for this to succeed.
* It may be wrapped in a `Scalar`.
*
* @returns `true` if the item was found and removed.
*/
delete(key2) {
const idx = asItemIndex(key2);
if (typeof idx !== "number")
return false;
const del = this.items.splice(idx, 1);
return del.length > 0;
}
get(key2, keepScalar) {
const idx = asItemIndex(key2);
if (typeof idx !== "number")
return void 0;
const it = this.items[idx];
return !keepScalar && isScalar(it) ? it.value : it;
}
/**
* Checks if the collection includes a value with the key `key`.
*
* `key` must contain a representation of an integer for this to succeed.
* It may be wrapped in a `Scalar`.
*/
has(key2) {
const idx = asItemIndex(key2);
return typeof idx === "number" && idx < this.items.length;
}
/**
* Sets a value in this collection. For `!!set`, `value` needs to be a
* boolean to add/remove the item from the set.
*
* If `key` does not contain a representation of an integer, this will throw.
* It may be wrapped in a `Scalar`.
*/
set(key2, value) {
const idx = asItemIndex(key2);
if (typeof idx !== "number")
throw new Error(`Expected a valid index, not ${key2}.`);
const prev = this.items[idx];
if (isScalar(prev) && isScalarValue(value))
prev.value = value;
else
this.items[idx] = value;
}
toJSON(_2, ctx) {
const seq2 = [];
if (ctx == null ? void 0 : ctx.onCreate)
ctx.onCreate(seq2);
let i2 = 0;
for (const item of this.items)
seq2.push(toJS(item, String(i2++), ctx));
return seq2;
}
toString(ctx, onComment, onChompKeep) {
if (!ctx)
return JSON.stringify(this);
return stringifyCollection(this, ctx, {
blockItemPrefix: "- ",
flowChars: { start: "[", end: "]" },
itemIndent: (ctx.indent || "") + " ",
onChompKeep,
onComment
});
}
static from(schema2, obj, ctx) {
const { replacer: replacer2 } = ctx;
const seq2 = new this(schema2);
if (obj && Symbol.iterator in Object(obj)) {
let i2 = 0;
for (let it of obj) {
if (typeof replacer2 === "function") {
const key2 = obj instanceof Set ? it : String(i2++);
it = replacer2.call(obj, key2, it);
}
seq2.items.push(createNode(it, void 0, ctx));
}
}
return seq2;
}
}
function asItemIndex(key2) {
let idx = isScalar(key2) ? key2.value : key2;
if (idx && typeof idx === "string")
idx = Number(idx);
return typeof idx === "number" && Number.isInteger(idx) && idx >= 0 ? idx : null;
}
const seq = {
collection: "seq",
default: true,
nodeClass: YAMLSeq,
tag: "tag:yaml.org,2002:seq",
resolve(seq2, onError) {
if (!isSeq(seq2))
onError("Expected a sequence for this tag");
return seq2;
},
createNode: (schema2, obj, ctx) => YAMLSeq.from(schema2, obj, ctx)
};
const string$1 = {
identify: (value) => typeof value === "string",
default: true,
tag: "tag:yaml.org,2002:str",
resolve: (str) => str,
stringify(item, ctx, onComment, onChompKeep) {
ctx = Object.assign({ actualString: true }, ctx);
return stringifyString(item, ctx, onComment, onChompKeep);
}
};
const nullTag = {
identify: (value) => value == null,
createNode: () => new Scalar(null),
default: true,
tag: "tag:yaml.org,2002:null",
test: /^(?:~|[Nn]ull|NULL)?$/,
resolve: () => new Scalar(null),
stringify: ({ source: source2 }, ctx) => typeof source2 === "string" && nullTag.test.test(source2) ? source2 : ctx.options.nullStr
};
const boolTag = {
identify: (value) => typeof value === "boolean",
default: true,
tag: "tag:yaml.org,2002:bool",
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
resolve: (str) => new Scalar(str[0] === "t" || str[0] === "T"),
stringify({ source: source2, value }, ctx) {
if (source2 && boolTag.test.test(source2)) {
const sv = source2[0] === "t" || source2[0] === "T";
if (value === sv)
return source2;
}
return value ? ctx.options.trueStr : ctx.options.falseStr;
}
};
function stringifyNumber({ format: format2, minFractionDigits, tag, value }) {
if (typeof value === "bigint")
return String(value);
const num = typeof value === "number" ? value : Number(value);
if (!isFinite(num))
return isNaN(num) ? ".nan" : num < 0 ? "-.inf" : ".inf";
let n2 = JSON.stringify(value);
if (!format2 && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^\d/.test(n2)) {
let i2 = n2.indexOf(".");
if (i2 < 0) {
i2 = n2.length;
n2 += ".";
}
let d2 = minFractionDigits - (n2.length - i2 - 1);
while (d2-- > 0)
n2 += "0";
}
return n2;
}
const floatNaN$1 = {
identify: (value) => typeof value === "number",
default: true,
tag: "tag:yaml.org,2002:float",
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
resolve: (str) => str.slice(-3).toLowerCase() === "nan" ? NaN : str[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
stringify: stringifyNumber
};
const floatExp$1 = {
identify: (value) => typeof value === "number",
default: true,
tag: "tag:yaml.org,2002:float",
format: "EXP",
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
resolve: (str) => parseFloat(str),
stringify(node) {
const num = Number(node.value);
return isFinite(num) ? num.toExponential() : stringifyNumber(node);
}
};
const float$1 = {
identify: (value) => typeof value === "number",
default: true,
tag: "tag:yaml.org,2002:float",
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
resolve(str) {
const node = new Scalar(parseFloat(str));
const dot2 = str.indexOf(".");
if (dot2 !== -1 && str[str.length - 1] === "0")
node.minFractionDigits = str.length - dot2 - 1;
return node;
},
stringify: stringifyNumber
};
const intIdentify$2 = (value) => typeof value === "bigint" || Number.isInteger(value);
const intResolve$1 = (str, offset2, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str) : parseInt(str.substring(offset2), radix);
function intStringify$1(node, radix, prefix) {
const { value } = node;
if (intIdentify$2(value) && value >= 0)
return prefix + value.toString(radix);
return stringifyNumber(node);
}
const intOct$1 = {
identify: (value) => intIdentify$2(value) && value >= 0,
default: true,
tag: "tag:yaml.org,2002:int",
format: "OCT",
test: /^0o[0-7]+$/,
resolve: (str, _onError, opt) => intResolve$1(str, 2, 8, opt),
stringify: (node) => intStringify$1(node, 8, "0o")
};
const int$1 = {
identify: intIdentify$2,
default: true,
tag: "tag:yaml.org,2002:int",
test: /^[-+]?[0-9]+$/,
resolve: (str, _onError, opt) => intResolve$1(str, 0, 10, opt),
stringify: stringifyNumber
};
const intHex$1 = {
identify: (value) => intIdentify$2(value) && value >= 0,
default: true,
tag: "tag:yaml.org,2002:int",
format: "HEX",
test: /^0x[0-9a-fA-F]+$/,
resolve: (str, _onError, opt) => intResolve$1(str, 2, 16, opt),
stringify: (node) => intStringify$1(node, 16, "0x")
};
const schema$2 = [
map,
seq,
string$1,
nullTag,
boolTag,
intOct$1,
int$1,
intHex$1,
floatNaN$1,
floatExp$1,
float$1
];
function intIdentify$1(value) {
return typeof value === "bigint" || Number.isInteger(value);
}
const stringifyJSON = ({ value }) => JSON.stringify(value);
const jsonScalars = [
{
identify: (value) => typeof value === "string",
default: true,
tag: "tag:yaml.org,2002:str",
resolve: (str) => str,
stringify: stringifyJSON
},
{
identify: (value) => value == null,
createNode: () => new Scalar(null),
default: true,
tag: "tag:yaml.org,2002:null",
test: /^null$/,
resolve: () => null,
stringify: stringifyJSON
},
{
identify: (value) => typeof value === "boolean",
default: true,
tag: "tag:yaml.org,2002:bool",
test: /^true|false$/,
resolve: (str) => str === "true",
stringify: stringifyJSON
},
{
identify: intIdentify$1,
default: true,
tag: "tag:yaml.org,2002:int",
test: /^-?(?:0|[1-9][0-9]*)$/,
resolve: (str, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str) : parseInt(str, 10),
stringify: ({ value }) => intIdentify$1(value) ? value.toString() : JSON.stringify(value)
},
{
identify: (value) => typeof value === "number",
default: true,
tag: "tag:yaml.org,2002:float",
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
resolve: (str) => parseFloat(str),
stringify: stringifyJSON
}
];
const jsonError = {
default: true,
tag: "",
test: /^/,
resolve(str, onError) {
onError(`Unresolved plain scalar ${JSON.stringify(str)}`);
return str;
}
};
const schema$1 = [map, seq].concat(jsonScalars, jsonError);
const binary = {
identify: (value) => value instanceof Uint8Array,
// Buffer inherits from Uint8Array
default: false,
tag: "tag:yaml.org,2002:binary",
/**
* Returns a Buffer in node and an Uint8Array in browsers
*
* To use the resulting buffer as an image, you'll want to do something like:
*
* const blob = new Blob([buffer], { type: 'image/jpeg' })
* document.querySelector('#photo').src = URL.createObjectURL(blob)
*/
resolve(src, onError) {
if (typeof Buffer === "function") {
return Buffer.from(src, "base64");
} else if (typeof atob === "function") {
const str = atob(src.replace(/[\n\r]/g, ""));
const buffer = new Uint8Array(str.length);
for (let i2 = 0; i2 < str.length; ++i2)
buffer[i2] = str.charCodeAt(i2);
return buffer;
} else {
onError("This environment does not support reading binary tags; either Buffer or atob is required");
return src;
}
},
stringify({ comment: comment2, type: type2, value }, ctx, onComment, onChompKeep) {
const buf = value;
let str;
if (typeof Buffer === "function") {
str = buf instanceof Buffer ? buf.toString("base64") : Buffer.from(buf.buffer).toString("base64");
} else if (typeof btoa === "function") {
let s3 = "";
for (let i2 = 0; i2 < buf.length; ++i2)
s3 += String.fromCharCode(buf[i2]);
str = btoa(s3);
} else {
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
}
if (!type2)
type2 = Scalar.BLOCK_LITERAL;
if (type2 !== Scalar.QUOTE_DOUBLE) {
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
const n2 = Math.ceil(str.length / lineWidth);
const lines = new Array(n2);
for (let i2 = 0, o2 = 0; i2 < n2; ++i2, o2 += lineWidth) {
lines[i2] = str.substr(o2, lineWidth);
}
str = lines.join(type2 === Scalar.BLOCK_LITERAL ? "\n" : " ");
}
return stringifyString({ comment: comment2, type: type2, value: str }, ctx, onComment, onChompKeep);
}
};
function resolvePairs(seq2, onError) {
if (isSeq(seq2)) {
for (let i2 = 0; i2 < seq2.items.length; ++i2) {
let item = seq2.items[i2];
if (isPair(item))
continue;
else if (isMap(item)) {
if (item.items.length > 1)
onError("Each pair must have its own sequence indicator");
const pair2 = item.items[0] || new Pair(new Scalar(null));
if (item.commentBefore)
pair2.key.commentBefore = pair2.key.commentBefore ? `${item.commentBefore}
${pair2.key.commentBefore}` : item.commentBefore;
if (item.comment) {
const cn = pair2.value ?? pair2.key;
cn.comment = cn.comment ? `${item.comment}
${cn.comment}` : item.comment;
}
item = pair2;
}
seq2.items[i2] = isPair(item) ? item : new Pair(item);
}
} else
onError("Expected a sequence for this tag");
return seq2;
}
function createPairs(schema2, iterable, ctx) {
const { replacer: replacer2 } = ctx;
const pairs2 = new YAMLSeq(schema2);
pairs2.tag = "tag:yaml.org,2002:pairs";
let i2 = 0;
if (iterable && Symbol.iterator in Object(iterable))
for (let it of iterable) {
if (typeof replacer2 === "function")
it = replacer2.call(iterable, String(i2++), it);
let key2, value;
if (Array.isArray(it)) {
if (it.length === 2) {
key2 = it[0];
value = it[1];
} else
throw new TypeError(`Expected [key, value] tuple: ${it}`);
} else if (it && it instanceof Object) {
const keys2 = Object.keys(it);
if (keys2.length === 1) {
key2 = keys2[0];
value = it[key2];
} else {
throw new TypeError(`Expected tuple with one key, not ${keys2.length} keys`);
}
} else {
key2 = it;
}
pairs2.items.push(createPair(key2, value, ctx));
}
return pairs2;
}
const pairs = {
collection: "seq",
default: false,
tag: "tag:yaml.org,2002:pairs",
resolve: resolvePairs,
createNode: createPairs
};
class YAMLOMap extends YAMLSeq {
constructor() {
super();
this.add = YAMLMap.prototype.add.bind(this);
this.delete = YAMLMap.prototype.delete.bind(this);
this.get = YAMLMap.prototype.get.bind(this);
this.has = YAMLMap.prototype.has.bind(this);
this.set = YAMLMap.prototype.set.bind(this);
this.tag = YAMLOMap.tag;
}
/**
* If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
* but TypeScript won't allow widening the signature of a child method.
*/
toJSON(_2, ctx) {
if (!ctx)
return super.toJSON(_2);
const map2 = /* @__PURE__ */ new Map();
if (ctx == null ? void 0 : ctx.onCreate)
ctx.onCreate(map2);
for (const pair2 of this.items) {
let key2, value;
if (isPair(pair2)) {
key2 = toJS(pair2.key, "", ctx);
value = toJS(pair2.value, key2, ctx);
} else {
key2 = toJS(pair2, "", ctx);
}
if (map2.has(key2))
throw new Error("Ordered maps must not include duplicate keys");
map2.set(key2, value);
}
return map2;
}
static from(schema2, iterable, ctx) {
const pairs2 = createPairs(schema2, iterable, ctx);
const omap2 = new this();
omap2.items = pairs2.items;
return omap2;
}
}
YAMLOMap.tag = "tag:yaml.org,2002:omap";
const omap = {
collection: "seq",
identify: (value) => value instanceof Map,
nodeClass: YAMLOMap,
default: false,
tag: "tag:yaml.org,2002:omap",
resolve(seq2, onError) {
const pairs2 = resolvePairs(seq2, onError);
const seenKeys = [];
for (const { key: key2 } of pairs2.items) {
if (isScalar(key2)) {
if (seenKeys.includes(key2.value)) {
onError(`Ordered maps must not include duplicate keys: ${key2.value}`);
} else {
seenKeys.push(key2.value);
}
}
}
return Object.assign(new YAMLOMap(), pairs2);
},
createNode: (schema2, iterable, ctx) => YAMLOMap.from(schema2, iterable, ctx)
};
function boolStringify({ value, source: source2 }, ctx) {
const boolObj = value ? trueTag : falseTag;
if (source2 && boolObj.test.test(source2))
return source2;
return value ? ctx.options.trueStr : ctx.options.falseStr;
}
const trueTag = {
identify: (value) => value === true,
default: true,
tag: "tag:yaml.org,2002:bool",
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
resolve: () => new Scalar(true),
stringify: boolStringify
};
const falseTag = {
identify: (value) => value === false,
default: true,
tag: "tag:yaml.org,2002:bool",
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
resolve: () => new Scalar(false),
stringify: boolStringify
};
const floatNaN = {
identify: (value) => typeof value === "number",
default: true,
tag: "tag:yaml.org,2002:float",
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
resolve: (str) => str.slice(-3).toLowerCase() === "nan" ? NaN : str[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
stringify: stringifyNumber
};
const floatExp = {
identify: (value) => typeof value === "number",
default: true,
tag: "tag:yaml.org,2002:float",
format: "EXP",
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
resolve: (str) => parseFloat(str.replace(/_/g, "")),
stringify(node) {
const num = Number(node.value);
return isFinite(num) ? num.toExponential() : stringifyNumber(node);
}
};
const float = {
identify: (value) => typeof value === "number",
default: true,
tag: "tag:yaml.org,2002:float",
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
resolve(str) {
const node = new Scalar(parseFloat(str.replace(/_/g, "")));
const dot2 = str.indexOf(".");
if (dot2 !== -1) {
const f2 = str.substring(dot2 + 1).replace(/_/g, "");
if (f2[f2.length - 1] === "0")
node.minFractionDigits = f2.length;
}
return node;
},
stringify: stringifyNumber
};
const intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
function intResolve(str, offset2, radix, { intAsBigInt }) {
const sign = str[0];
if (sign === "-" || sign === "+")
offset2 += 1;
str = str.substring(offset2).replace(/_/g, "");
if (intAsBigInt) {
switch (radix) {
case 2:
str = `0b${str}`;
break;
case 8:
str = `0o${str}`;
break;
case 16:
str = `0x${str}`;
break;
}
const n3 = BigInt(str);
return sign === "-" ? BigInt(-1) * n3 : n3;
}
const n2 = parseInt(str, radix);
return sign === "-" ? -1 * n2 : n2;
}
function intStringify(node, radix, prefix) {
const { value } = node;
if (intIdentify(value)) {
const str = value.toString(radix);
return value < 0 ? "-" + prefix + str.substr(1) : prefix + str;
}
return stringifyNumber(node);
}
const intBin = {
identify: intIdentify,
default: true,
tag: "tag:yaml.org,2002:int",
format: "BIN",
test: /^[-+]?0b[0-1_]+$/,
resolve: (str, _onError, opt) => intResolve(str, 2, 2, opt),
stringify: (node) => intStringify(node, 2, "0b")
};
const intOct = {
identify: intIdentify,
default: true,
tag: "tag:yaml.org,2002:int",
format: "OCT",
test: /^[-+]?0[0-7_]+$/,
resolve: (str, _onError, opt) => intResolve(str, 1, 8, opt),
stringify: (node) => intStringify(node, 8, "0")
};
const int = {
identify: intIdentify,
default: true,
tag: "tag:yaml.org,2002:int",
test: /^[-+]?[0-9][0-9_]*$/,
resolve: (str, _onError, opt) => intResolve(str, 0, 10, opt),
stringify: stringifyNumber
};
const intHex = {
identify: intIdentify,
default: true,
tag: "tag:yaml.org,2002:int",
format: "HEX",
test: /^[-+]?0x[0-9a-fA-F_]+$/,
resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt),
stringify: (node) => intStringify(node, 16, "0x")
};
class YAMLSet extends YAMLMap {
constructor(schema2) {
super(schema2);
this.tag = YAMLSet.tag;
}
add(key2) {
let pair2;
if (isPair(key2))
pair2 = key2;
else if (key2 && typeof key2 === "object" && "key" in key2 && "value" in key2 && key2.value === null)
pair2 = new Pair(key2.key, null);
else
pair2 = new Pair(key2, null);
const prev = findPair(this.items, pair2.key);
if (!prev)
this.items.push(pair2);
}
/**
* If `keepPair` is `true`, returns the Pair matching `key`.
* Otherwise, returns the value of that Pair's key.
*/
get(key2, keepPair) {
const pair2 = findPair(this.items, key2);
return !keepPair && isPair(pair2) ? isScalar(pair2.key) ? pair2.key.value : pair2.key : pair2;
}
set(key2, value) {
if (typeof value !== "boolean")
throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`);
const prev = findPair(this.items, key2);
if (prev && !value) {
this.items.splice(this.items.indexOf(prev), 1);
} else if (!prev && value) {
this.items.push(new Pair(key2));
}
}
toJSON(_2, ctx) {
return super.toJSON(_2, ctx, Set);
}
toString(ctx, onComment, onChompKeep) {
if (!ctx)
return JSON.stringify(this);
if (this.hasAllNullValues(true))
return super.toString(Object.assign({}, ctx, { allNullValues: true }), onComment, onChompKeep);
else
throw new Error("Set items must all have null values");
}
static from(schema2, iterable, ctx) {
const { replacer: replacer2 } = ctx;
const set2 = new this(schema2);
if (iterable && Symbol.iterator in Object(iterable))
for (let value of iterable) {
if (typeof replacer2 === "function")
value = replacer2.call(iterable, value, value);
set2.items.push(createPair(value, null, ctx));
}
return set2;
}
}
YAMLSet.tag = "tag:yaml.org,2002:set";
const set$1 = {
collection: "map",
identify: (value) => value instanceof Set,
nodeClass: YAMLSet,
default: false,
tag: "tag:yaml.org,2002:set",
createNode: (schema2, iterable, ctx) => YAMLSet.from(schema2, iterable, ctx),
resolve(map2, onError) {
if (isMap(map2)) {
if (map2.hasAllNullValues(true))
return Object.assign(new YAMLSet(), map2);
else
onError("Set items must all have null values");
} else
onError("Expected a mapping for this tag");
return map2;
}
};
function parseSexagesimal(str, asBigInt) {
const sign = str[0];
const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
const num = (n2) => asBigInt ? BigInt(n2) : Number(n2);
const res = parts.replace(/_/g, "").split(":").reduce((res2, p2) => res2 * num(60) + num(p2), num(0));
return sign === "-" ? num(-1) * res : res;
}
function stringifySexagesimal(node) {
let { value } = node;
let num = (n2) => n2;
if (typeof value === "bigint")
num = (n2) => BigInt(n2);
else if (isNaN(value) || !isFinite(value))
return stringifyNumber(node);
let sign = "";
if (value < 0) {
sign = "-";
value *= num(-1);
}
const _60 = num(60);
const parts = [value % _60];
if (value < 60) {
parts.unshift(0);
} else {
value = (value - parts[0]) / _60;
parts.unshift(value % _60);
if (value >= 60) {
value = (value - parts[0]) / _60;
parts.unshift(value);
}
}
return sign + parts.map((n2) => String(n2).padStart(2, "0")).join(":").replace(/000000\d*$/, "");
}
const intTime = {
identify: (value) => typeof value === "bigint" || Number.isInteger(value),
default: true,
tag: "tag:yaml.org,2002:int",
format: "TIME",
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
resolve: (str, _onError, { intAsBigInt }) => parseSexagesimal(str, intAsBigInt),
stringify: stringifySexagesimal
};
const floatTime = {
identify: (value) => typeof value === "number",
default: true,
tag: "tag:yaml.org,2002:float",
format: "TIME",
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
resolve: (str) => parseSexagesimal(str, false),
stringify: stringifySexagesimal
};
const timestamp = {
identify: (value) => value instanceof Date,
default: true,
tag: "tag:yaml.org,2002:timestamp",
// If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
// may be omitted altogether, resulting in a date format. In such a case, the time part is
// assumed to be 00:00:00Z (start of day, UTC).
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(str) {
const match = str.match(timestamp.test);
if (!match)
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
const [, year, month, day, hour, minute, second] = match.map(Number);
const millisec = match[7] ? Number((match[7] + "00").substr(1, 3)) : 0;
let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
const tz = match[8];
if (tz && tz !== "Z") {
let d2 = parseSexagesimal(tz, false);
if (Math.abs(d2) < 30)
d2 *= 60;
date -= 6e4 * d2;
}
return new Date(date);
},
stringify: ({ value }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, "")
};
const schema = [
map,
seq,
string$1,
nullTag,
trueTag,
falseTag,
intBin,
intOct,
int,
intHex,
floatNaN,
floatExp,
float,
binary,
omap,
pairs,
set$1,
intTime,
floatTime,
timestamp
];
const schemas = /* @__PURE__ */ new Map([
["core", schema$2],
["failsafe", [map, seq, string$1]],
["json", schema$1],
["yaml11", schema],
["yaml-1.1", schema]
]);
const tagsByName = {
binary,
bool: boolTag,
float: float$1,
floatExp: floatExp$1,
floatNaN: floatNaN$1,
floatTime,
int: int$1,
intHex: intHex$1,
intOct: intOct$1,
intTime,
map,
null: nullTag,
omap,
pairs,
seq,
set: set$1,
timestamp
};
const coreKnownTags = {
"tag:yaml.org,2002:binary": binary,
"tag:yaml.org,2002:omap": omap,
"tag:yaml.org,2002:pairs": pairs,
"tag:yaml.org,2002:set": set$1,
"tag:yaml.org,2002:timestamp": timestamp
};
function getTags(customTags, schemaName) {
let tags2 = schemas.get(schemaName);
if (!tags2) {
if (Array.isArray(customTags))
tags2 = [];
else {
const keys2 = Array.from(schemas.keys()).filter((key2) => key2 !== "yaml11").map((key2) => JSON.stringify(key2)).join(", ");
throw new Error(`Unknown schema "${schemaName}"; use one of ${keys2} or define customTags array`);
}
}
if (Array.isArray(customTags)) {
for (const tag of customTags)
tags2 = tags2.concat(tag);
} else if (typeof customTags === "function") {
tags2 = customTags(tags2.slice());
}
return tags2.map((tag) => {
if (typeof tag !== "string")
return tag;
const tagObj = tagsByName[tag];
if (tagObj)
return tagObj;
const keys2 = Object.keys(tagsByName).map((key2) => JSON.stringify(key2)).join(", ");
throw new Error(`Unknown custom tag "${tag}"; use one of ${keys2}`);
});
}
const sortMapEntriesByKey = (a2, b2) => a2.key < b2.key ? -1 : a2.key > b2.key ? 1 : 0;
let Schema$2 = class Schema {
constructor({ compat, customTags, merge: merge2, resolveKnownTags, schema: schema2, sortMapEntries, toStringDefaults }) {
this.compat = Array.isArray(compat) ? getTags(compat, "compat") : compat ? getTags(null, compat) : null;
this.merge = !!merge2;
this.name = typeof schema2 === "string" && schema2 || "core";
this.knownTags = resolveKnownTags ? coreKnownTags : {};
this.tags = getTags(customTags, this.name);
this.toStringOptions = toStringDefaults ?? null;
Object.defineProperty(this, MAP, { value: map });
Object.defineProperty(this, SCALAR$1, { value: string$1 });
Object.defineProperty(this, SEQ, { value: seq });
this.sortMapEntries = typeof sortMapEntries === "function" ? sortMapEntries : sortMapEntries === true ? sortMapEntriesByKey : null;
}
clone() {
const copy = Object.create(Schema.prototype, Object.getOwnPropertyDescriptors(this));
copy.tags = this.tags.slice();
return copy;
}
};
function stringifyDocument(doc2, options) {
var _a2;
const lines = [];
let hasDirectives = options.directives === true;
if (options.directives !== false && doc2.directives) {
const dir = doc2.directives.toString(doc2);
if (dir) {
lines.push(dir);
hasDirectives = true;
} else if (doc2.directives.docStart)
hasDirectives = true;
}
if (hasDirectives)
lines.push("---");
const ctx = createStringifyContext(doc2, options);
const { commentString } = ctx.options;
if (doc2.commentBefore) {
if (lines.length !== 1)
lines.unshift("");
const cs = commentString(doc2.commentBefore);
lines.unshift(indentComment(cs, ""));
}
let chompKeep = false;
let contentComment = null;
if (doc2.contents) {
if (isNode$2(doc2.contents)) {
if (doc2.contents.spaceBefore && hasDirectives)
lines.push("");
if (doc2.contents.commentBefore) {
const cs = commentString(doc2.contents.commentBefore);
lines.push(indentComment(cs, ""));
}
ctx.forceBlockIndent = !!doc2.comment;
contentComment = doc2.contents.comment;
}
const onChompKeep = contentComment ? void 0 : () => chompKeep = true;
let body2 = stringify$3(doc2.contents, ctx, () => contentComment = null, onChompKeep);
if (contentComment)
body2 += lineComment(body2, "", commentString(contentComment));
if ((body2[0] === "|" || body2[0] === ">") && lines[lines.length - 1] === "---") {
lines[lines.length - 1] = `--- ${body2}`;
} else
lines.push(body2);
} else {
lines.push(stringify$3(doc2.contents, ctx));
}
if ((_a2 = doc2.directives) == null ? void 0 : _a2.docEnd) {
if (doc2.comment) {
const cs = commentString(doc2.comment);
if (cs.includes("\n")) {
lines.push("...");
lines.push(indentComment(cs, ""));
} else {
lines.push(`... ${cs}`);
}
} else {
lines.push("...");
}
} else {
let dc = doc2.comment;
if (dc && chompKeep)
dc = dc.replace(/^\n+/, "");
if (dc) {
if ((!chompKeep || contentComment) && lines[lines.length - 1] !== "")
lines.push("");
lines.push(indentComment(commentString(dc), ""));
}
}
return lines.join("\n") + "\n";
}
class Document {
constructor(value, replacer2, options) {
this.commentBefore = null;
this.comment = null;
this.errors = [];
this.warnings = [];
Object.defineProperty(this, NODE_TYPE, { value: DOC });
let _replacer = null;
if (typeof replacer2 === "function" || Array.isArray(replacer2)) {
_replacer = replacer2;
} else if (options === void 0 && replacer2) {
options = replacer2;
replacer2 = void 0;
}
const opt = Object.assign({
intAsBigInt: false,
keepSourceTokens: false,
logLevel: "warn",
prettyErrors: true,
strict: true,
uniqueKeys: true,
version: "1.2"
}, options);
this.options = opt;
let { version: version2 } = opt;
if (options == null ? void 0 : options._directives) {
this.directives = options._directives.atDocument();
if (this.directives.yaml.explicit)
version2 = this.directives.yaml.version;
} else
this.directives = new Directives({ version: version2 });
this.setSchema(version2, options);
this.contents = value === void 0 ? null : this.createNode(value, _replacer, options);
}
/**
* Create a deep copy of this Document and its contents.
*
* Custom Node values that inherit from `Object` still refer to their original instances.
*/
clone() {
const copy = Object.create(Document.prototype, {
[NODE_TYPE]: { value: DOC }
});
copy.commentBefore = this.commentBefore;
copy.comment = this.comment;
copy.errors = this.errors.slice();
copy.warnings = this.warnings.slice();
copy.options = Object.assign({}, this.options);
if (this.directives)
copy.directives = this.directives.clone();
copy.schema = this.schema.clone();
copy.contents = isNode$2(this.contents) ? this.contents.clone(copy.schema) : this.contents;
if (this.range)
copy.range = this.range.slice();
return copy;
}
/** Adds a value to the document. */
add(value) {
if (assertCollection(this.contents))
this.contents.add(value);
}
/** Adds a value to the document. */
addIn(path2, value) {
if (assertCollection(this.contents))
this.contents.addIn(path2, value);
}
/**
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
*
* If `node` already has an anchor, `name` is ignored.
* Otherwise, the `node.anchor` value will be set to `name`,
* or if an anchor with that name is already present in the document,
* `name` will be used as a prefix for a new unique anchor.
* If `name` is undefined, the generated anchor will use 'a' as a prefix.
*/
createAlias(node, name2) {
if (!node.anchor) {
const prev = anchorNames(this);
node.anchor = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
!name2 || prev.has(name2) ? findNewAnchor(name2 || "a", prev) : name2;
}
return new Alias$1(node.anchor);
}
createNode(value, replacer2, options) {
let _replacer = void 0;
if (typeof replacer2 === "function") {
value = replacer2.call({ "": value }, "", value);
_replacer = replacer2;
} else if (Array.isArray(replacer2)) {
const keyToStr = (v2) => typeof v2 === "number" || v2 instanceof String || v2 instanceof Number;
const asStr = replacer2.filter(keyToStr).map(String);
if (asStr.length > 0)
replacer2 = replacer2.concat(asStr);
_replacer = replacer2;
} else if (options === void 0 && replacer2) {
options = replacer2;
replacer2 = void 0;
}
const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options ?? {};
const { onAnchor, setAnchors, sourceObjects } = createNodeAnchors(
this,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
anchorPrefix || "a"
);
const ctx = {
aliasDuplicateObjects: aliasDuplicateObjects ?? true,
keepUndefined: keepUndefined ?? false,
onAnchor,
onTagObj,
replacer: _replacer,
schema: this.schema,
sourceObjects
};
const node = createNode(value, tag, ctx);
if (flow && isCollection(node))
node.flow = true;
setAnchors();
return node;
}
/**
* Convert a key and a value into a `Pair` using the current schema,
* recursively wrapping all values as `Scalar` or `Collection` nodes.
*/
createPair(key2, value, options = {}) {
const k2 = this.createNode(key2, null, options);
const v2 = this.createNode(value, null, options);
return new Pair(k2, v2);
}
/**
* Removes a value from the document.
* @returns `true` if the item was found and removed.
*/
delete(key2) {
return assertCollection(this.contents) ? this.contents.delete(key2) : false;
}
/**
* Removes a value from the document.
* @returns `true` if the item was found and removed.
*/
deleteIn(path2) {
if (isEmptyPath(path2)) {
if (this.contents == null)
return false;
this.contents = null;
return true;
}
return assertCollection(this.contents) ? this.contents.deleteIn(path2) : false;
}
/**
* Returns item at `key`, or `undefined` if not found. By default unwraps
* scalar values from their surrounding node; to disable set `keepScalar` to
* `true` (collections are always returned intact).
*/
get(key2, keepScalar) {
return isCollection(this.contents) ? this.contents.get(key2, keepScalar) : void 0;
}
/**
* Returns item at `path`, or `undefined` if not found. By default unwraps
* scalar values from their surrounding node; to disable set `keepScalar` to
* `true` (collections are always returned intact).
*/
getIn(path2, keepScalar) {
if (isEmptyPath(path2))
return !keepScalar && isScalar(this.contents) ? this.contents.value : this.contents;
return isCollection(this.contents) ? this.contents.getIn(path2, keepScalar) : void 0;
}
/**
* Checks if the document includes a value with the key `key`.
*/
has(key2) {
return isCollection(this.contents) ? this.contents.has(key2) : false;
}
/**
* Checks if the document includes a value at `path`.
*/
hasIn(path2) {
if (isEmptyPath(path2))
return this.contents !== void 0;
return isCollection(this.contents) ? this.contents.hasIn(path2) : false;
}
/**
* Sets a value in this document. For `!!set`, `value` needs to be a
* boolean to add/remove the item from the set.
*/
set(key2, value) {
if (this.contents == null) {
this.contents = collectionFromPath(this.schema, [key2], value);
} else if (assertCollection(this.contents)) {
this.contents.set(key2, value);
}
}
/**
* Sets a value in this document. For `!!set`, `value` needs to be a
* boolean to add/remove the item from the set.
*/
setIn(path2, value) {
if (isEmptyPath(path2)) {
this.contents = value;
} else if (this.contents == null) {
this.contents = collectionFromPath(this.schema, Array.from(path2), value);
} else if (assertCollection(this.contents)) {
this.contents.setIn(path2, value);
}
}
/**
* Change the YAML version and schema used by the document.
* A `null` version disables support for directives, explicit tags, anchors, and aliases.
* It also requires the `schema` option to be given as a `Schema` instance value.
*
* Overrides all previously set schema options.
*/
setSchema(version2, options = {}) {
if (typeof version2 === "number")
version2 = String(version2);
let opt;
switch (version2) {
case "1.1":
if (this.directives)
this.directives.yaml.version = "1.1";
else
this.directives = new Directives({ version: "1.1" });
opt = { merge: true, resolveKnownTags: false, schema: "yaml-1.1" };
break;
case "1.2":
case "next":
if (this.directives)
this.directives.yaml.version = version2;
else
this.directives = new Directives({ version: version2 });
opt = { merge: false, resolveKnownTags: true, schema: "core" };
break;
case null:
if (this.directives)
delete this.directives;
opt = null;
break;
default: {
const sv = JSON.stringify(version2);
throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${sv}`);
}
}
if (options.schema instanceof Object)
this.schema = options.schema;
else if (opt)
this.schema = new Schema$2(Object.assign(opt, options));
else
throw new Error(`With a null YAML version, the { schema: Schema } option is required`);
}
// json & jsonArg are only used from toJSON()
toJS({ json: json2, jsonArg, mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
const ctx = {
anchors: /* @__PURE__ */ new Map(),
doc: this,
keep: !json2,
mapAsMap: mapAsMap === true,
mapKeyWarned: false,
maxAliasCount: typeof maxAliasCount === "number" ? maxAliasCount : 100
};
const res = toJS(this.contents, jsonArg ?? "", ctx);
if (typeof onAnchor === "function")
for (const { count, res: res2 } of ctx.anchors.values())
onAnchor(res2, count);
return typeof reviver === "function" ? applyReviver(reviver, { "": res }, "", res) : res;
}
/**
* A JSON representation of the document `contents`.
*
* @param jsonArg Used by `JSON.stringify` to indicate the array index or
* property name.
*/
toJSON(jsonArg, onAnchor) {
return this.toJS({ json: true, jsonArg, mapAsMap: false, onAnchor });
}
/** A YAML representation of the document. */
toString(options = {}) {
if (this.errors.length > 0)
throw new Error("Document with errors cannot be stringified");
if ("indent" in options && (!Number.isInteger(options.indent) || Number(options.indent) <= 0)) {
const s3 = JSON.stringify(options.indent);
throw new Error(`"indent" option must be a positive integer, not ${s3}`);
}
return stringifyDocument(this, options);
}
}
function assertCollection(contents) {
if (isCollection(contents))
return true;
throw new Error("Expected a YAML collection as document contents");
}
class YAMLError extends Error {
constructor(name2, pos, code, message) {
super();
this.name = name2;
this.code = code;
this.message = message;
this.pos = pos;
}
}
class YAMLParseError extends YAMLError {
constructor(pos, code, message) {
super("YAMLParseError", pos, code, message);
}
}
class YAMLWarning extends YAMLError {
constructor(pos, code, message) {
super("YAMLWarning", pos, code, message);
}
}
const prettifyError = (src, lc) => (error2) => {
if (error2.pos[0] === -1)
return;
error2.linePos = error2.pos.map((pos) => lc.linePos(pos));
const { line, col } = error2.linePos[0];
error2.message += ` at line ${line}, column ${col}`;
let ci = col - 1;
let lineStr = src.substring(lc.lineStarts[line - 1], lc.lineStarts[line]).replace(/[\n\r]+$/, "");
if (ci >= 60 && lineStr.length > 80) {
const trimStart = Math.min(ci - 39, lineStr.length - 79);
lineStr = "…" + lineStr.substring(trimStart);
ci -= trimStart - 1;
}
if (lineStr.length > 80)
lineStr = lineStr.substring(0, 79) + "…";
if (line > 1 && /^ *$/.test(lineStr.substring(0, ci))) {
let prev = src.substring(lc.lineStarts[line - 2], lc.lineStarts[line - 1]);
if (prev.length > 80)
prev = prev.substring(0, 79) + "…\n";
lineStr = prev + lineStr;
}
if (/[^ ]/.test(lineStr)) {
let count = 1;
const end = error2.linePos[1];
if (end && end.line === line && end.col > col) {
count = Math.max(1, Math.min(end.col - col, 80 - ci));
}
const pointer = " ".repeat(ci) + "^".repeat(count);
error2.message += `:
${lineStr}
${pointer}
`;
}
};
function resolveProps(tokens, { flow, indicator, next, offset: offset2, onError, parentIndent, startOnNewline }) {
let spaceBefore = false;
let atNewline = startOnNewline;
let hasSpace = startOnNewline;
let comment2 = "";
let commentSep = "";
let hasNewline = false;
let hasNewlineAfterProp = false;
let reqSpace = false;
let tab = null;
let anchor = null;
let tag = null;
let comma2 = null;
let found = null;
let start = null;
for (const token of tokens) {
if (reqSpace) {
if (token.type !== "space" && token.type !== "newline" && token.type !== "comma")
onError(token.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space");
reqSpace = false;
}
if (tab) {
if (atNewline && token.type !== "comment" && token.type !== "newline") {
onError(tab, "TAB_AS_INDENT", "Tabs are not allowed as indentation");
}
tab = null;
}
switch (token.type) {
case "space":
if (!flow && (indicator !== "doc-start" || (next == null ? void 0 : next.type) !== "flow-collection") && token.source.includes(" ")) {
tab = token;
}
hasSpace = true;
break;
case "comment": {
if (!hasSpace)
onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
const cb = token.source.substring(1) || " ";
if (!comment2)
comment2 = cb;
else
comment2 += commentSep + cb;
commentSep = "";
atNewline = false;
break;
}
case "newline":
if (atNewline) {
if (comment2)
comment2 += token.source;
else
spaceBefore = true;
} else
commentSep += token.source;
atNewline = true;
hasNewline = true;
if (anchor || tag)
hasNewlineAfterProp = true;
hasSpace = true;
break;
case "anchor":
if (anchor)
onError(token, "MULTIPLE_ANCHORS", "A node can have at most one anchor");
if (token.source.endsWith(":"))
onError(token.offset + token.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", true);
anchor = token;
if (start === null)
start = token.offset;
atNewline = false;
hasSpace = false;
reqSpace = true;
break;
case "tag": {
if (tag)
onError(token, "MULTIPLE_TAGS", "A node can have at most one tag");
tag = token;
if (start === null)
start = token.offset;
atNewline = false;
hasSpace = false;
reqSpace = true;
break;
}
case indicator:
if (anchor || tag)
onError(token, "BAD_PROP_ORDER", `Anchors and tags must be after the ${token.source} indicator`);
if (found)
onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.source} in ${flow ?? "collection"}`);
found = token;
atNewline = indicator === "seq-item-ind" || indicator === "explicit-key-ind";
hasSpace = false;
break;
case "comma":
if (flow) {
if (comma2)
onError(token, "UNEXPECTED_TOKEN", `Unexpected , in ${flow}`);
comma2 = token;
atNewline = false;
hasSpace = false;
break;
}
default:
onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.type} token`);
atNewline = false;
hasSpace = false;
}
}
const last = tokens[tokens.length - 1];
const end = last ? last.offset + last.source.length : offset2;
if (reqSpace && next && next.type !== "space" && next.type !== "newline" && next.type !== "comma" && (next.type !== "scalar" || next.source !== "")) {
onError(next.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space");
}
if (tab && (atNewline && tab.indent <= parentIndent || (next == null ? void 0 : next.type) === "block-map" || (next == null ? void 0 : next.type) === "block-seq"))
onError(tab, "TAB_AS_INDENT", "Tabs are not allowed as indentation");
return {
comma: comma2,
found,
spaceBefore,
comment: comment2,
hasNewline,
hasNewlineAfterProp,
anchor,
tag,
end,
start: start ?? end
};
}
function containsNewline(key2) {
if (!key2)
return null;
switch (key2.type) {
case "alias":
case "scalar":
case "double-quoted-scalar":
case "single-quoted-scalar":
if (key2.source.includes("\n"))
return true;
if (key2.end) {
for (const st of key2.end)
if (st.type === "newline")
return true;
}
return false;
case "flow-collection":
for (const it of key2.items) {
for (const st of it.start)
if (st.type === "newline")
return true;
if (it.sep) {
for (const st of it.sep)
if (st.type === "newline")
return true;
}
if (containsNewline(it.key) || containsNewline(it.value))
return true;
}
return false;
default:
return true;
}
}
function flowIndentCheck(indent, fc, onError) {
if ((fc == null ? void 0 : fc.type) === "flow-collection") {
const end = fc.end[0];
if (end.indent === indent && (end.source === "]" || end.source === "}") && containsNewline(fc)) {
const msg = "Flow end indicator should be more indented than parent";
onError(end, "BAD_INDENT", msg, true);
}
}
}
function mapIncludes(ctx, items, search2) {
const { uniqueKeys } = ctx.options;
if (uniqueKeys === false)
return false;
const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a2, b2) => a2 === b2 || isScalar(a2) && isScalar(b2) && a2.value === b2.value && !(a2.value === "<<" && ctx.schema.merge);
return items.some((pair2) => isEqual(pair2.key, search2));
}
const startColMsg = "All mapping items must start at the same column";
function resolveBlockMap({ composeNode: composeNode2, composeEmptyNode: composeEmptyNode2 }, ctx, bm, onError, tag) {
var _a2;
const NodeClass = (tag == null ? void 0 : tag.nodeClass) ?? YAMLMap;
const map2 = new NodeClass(ctx.schema);
if (ctx.atRoot)
ctx.atRoot = false;
let offset2 = bm.offset;
let commentEnd = null;
for (const collItem of bm.items) {
const { start, key: key2, sep, value } = collItem;
const keyProps = resolveProps(start, {
indicator: "explicit-key-ind",
next: key2 ?? (sep == null ? void 0 : sep[0]),
offset: offset2,
onError,
parentIndent: bm.indent,
startOnNewline: true
});
const implicitKey = !keyProps.found;
if (implicitKey) {
if (key2) {
if (key2.type === "block-seq")
onError(offset2, "BLOCK_AS_IMPLICIT_KEY", "A block sequence may not be used as an implicit map key");
else if ("indent" in key2 && key2.indent !== bm.indent)
onError(offset2, "BAD_INDENT", startColMsg);
}
if (!keyProps.anchor && !keyProps.tag && !sep) {
commentEnd = keyProps.end;
if (keyProps.comment) {
if (map2.comment)
map2.comment += "\n" + keyProps.comment;
else
map2.comment = keyProps.comment;
}
continue;
}
if (keyProps.hasNewlineAfterProp || containsNewline(key2)) {
onError(key2 ?? start[start.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line");
}
} else if (((_a2 = keyProps.found) == null ? void 0 : _a2.indent) !== bm.indent) {
onError(offset2, "BAD_INDENT", startColMsg);
}
const keyStart = keyProps.end;
const keyNode = key2 ? composeNode2(ctx, key2, keyProps, onError) : composeEmptyNode2(ctx, keyStart, start, null, keyProps, onError);
if (ctx.schema.compat)
flowIndentCheck(bm.indent, key2, onError);
if (mapIncludes(ctx, map2.items, keyNode))
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
const valueProps = resolveProps(sep ?? [], {
indicator: "map-value-ind",
next: value,
offset: keyNode.range[2],
onError,
parentIndent: bm.indent,
startOnNewline: !key2 || key2.type === "block-scalar"
});
offset2 = valueProps.end;
if (valueProps.found) {
if (implicitKey) {
if ((value == null ? void 0 : value.type) === "block-map" && !valueProps.hasNewline)
onError(offset2, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings");
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
}
const valueNode = value ? composeNode2(ctx, value, valueProps, onError) : composeEmptyNode2(ctx, offset2, sep, null, valueProps, onError);
if (ctx.schema.compat)
flowIndentCheck(bm.indent, value, onError);
offset2 = valueNode.range[2];
const pair2 = new Pair(keyNode, valueNode);
if (ctx.options.keepSourceTokens)
pair2.srcToken = collItem;
map2.items.push(pair2);
} else {
if (implicitKey)
onError(keyNode.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values");
if (valueProps.comment) {
if (keyNode.comment)
keyNode.comment += "\n" + valueProps.comment;
else
keyNode.comment = valueProps.comment;
}
const pair2 = new Pair(keyNode);
if (ctx.options.keepSourceTokens)
pair2.srcToken = collItem;
map2.items.push(pair2);
}
}
if (commentEnd && commentEnd < offset2)
onError(commentEnd, "IMPOSSIBLE", "Map comment with trailing content");
map2.range = [bm.offset, offset2, commentEnd ?? offset2];
return map2;
}
function resolveBlockSeq({ composeNode: composeNode2, composeEmptyNode: composeEmptyNode2 }, ctx, bs, onError, tag) {
const NodeClass = (tag == null ? void 0 : tag.nodeClass) ?? YAMLSeq;
const seq2 = new NodeClass(ctx.schema);
if (ctx.atRoot)
ctx.atRoot = false;
let offset2 = bs.offset;
let commentEnd = null;
for (const { start, value } of bs.items) {
const props = resolveProps(start, {
indicator: "seq-item-ind",
next: value,
offset: offset2,
onError,
parentIndent: bs.indent,
startOnNewline: true
});
if (!props.found) {
if (props.anchor || props.tag || value) {
if (value && value.type === "block-seq")
onError(props.end, "BAD_INDENT", "All sequence items must start at the same column");
else
onError(offset2, "MISSING_CHAR", "Sequence item without - indicator");
} else {
commentEnd = props.end;
if (props.comment)
seq2.comment = props.comment;
continue;
}
}
const node = value ? composeNode2(ctx, value, props, onError) : composeEmptyNode2(ctx, props.end, start, null, props, onError);
if (ctx.schema.compat)
flowIndentCheck(bs.indent, value, onError);
offset2 = node.range[2];
seq2.items.push(node);
}
seq2.range = [bs.offset, offset2, commentEnd ?? offset2];
return seq2;
}
function resolveEnd(end, offset2, reqSpace, onError) {
let comment2 = "";
if (end) {
let hasSpace = false;
let sep = "";
for (const token of end) {
const { source: source2, type: type2 } = token;
switch (type2) {
case "space":
hasSpace = true;
break;
case "comment": {
if (reqSpace && !hasSpace)
onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
const cb = source2.substring(1) || " ";
if (!comment2)
comment2 = cb;
else
comment2 += sep + cb;
sep = "";
break;
}
case "newline":
if (comment2)
sep += source2;
hasSpace = true;
break;
default:
onError(token, "UNEXPECTED_TOKEN", `Unexpected ${type2} at node end`);
}
offset2 += source2.length;
}
}
return { comment: comment2, offset: offset2 };
}
const blockMsg = "Block collections are not allowed within flow collections";
const isBlock = (token) => token && (token.type === "block-map" || token.type === "block-seq");
function resolveFlowCollection({ composeNode: composeNode2, composeEmptyNode: composeEmptyNode2 }, ctx, fc, onError, tag) {
const isMap2 = fc.start.source === "{";
const fcName = isMap2 ? "flow map" : "flow sequence";
const NodeClass = (tag == null ? void 0 : tag.nodeClass) ?? (isMap2 ? YAMLMap : YAMLSeq);
const coll = new NodeClass(ctx.schema);
coll.flow = true;
const atRoot = ctx.atRoot;
if (atRoot)
ctx.atRoot = false;
let offset2 = fc.offset + fc.start.source.length;
for (let i2 = 0; i2 < fc.items.length; ++i2) {
const collItem = fc.items[i2];
const { start, key: key2, sep, value } = collItem;
const props = resolveProps(start, {
flow: fcName,
indicator: "explicit-key-ind",
next: key2 ?? (sep == null ? void 0 : sep[0]),
offset: offset2,
onError,
parentIndent: fc.indent,
startOnNewline: false
});
if (!props.found) {
if (!props.anchor && !props.tag && !sep && !value) {
if (i2 === 0 && props.comma)
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
else if (i2 < fc.items.length - 1)
onError(props.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${fcName}`);
if (props.comment) {
if (coll.comment)
coll.comment += "\n" + props.comment;
else
coll.comment = props.comment;
}
offset2 = props.end;
continue;
}
if (!isMap2 && ctx.options.strict && containsNewline(key2))
onError(
key2,
// checked by containsNewline()
"MULTILINE_IMPLICIT_KEY",
"Implicit keys of flow sequence pairs need to be on a single line"
);
}
if (i2 === 0) {
if (props.comma)
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
} else {
if (!props.comma)
onError(props.start, "MISSING_CHAR", `Missing , between ${fcName} items`);
if (props.comment) {
let prevItemComment = "";
loop: for (const st of start) {
switch (st.type) {
case "comma":
case "space":
break;
case "comment":
prevItemComment = st.source.substring(1);
break loop;
default:
break loop;
}
}
if (prevItemComment) {
let prev = coll.items[coll.items.length - 1];
if (isPair(prev))
prev = prev.value ?? prev.key;
if (prev.comment)
prev.comment += "\n" + prevItemComment;
else
prev.comment = prevItemComment;
props.comment = props.comment.substring(prevItemComment.length + 1);
}
}
}
if (!isMap2 && !sep && !props.found) {
const valueNode = value ? composeNode2(ctx, value, props, onError) : composeEmptyNode2(ctx, props.end, sep, null, props, onError);
coll.items.push(valueNode);
offset2 = valueNode.range[2];
if (isBlock(value))
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
} else {
const keyStart = props.end;
const keyNode = key2 ? composeNode2(ctx, key2, props, onError) : composeEmptyNode2(ctx, keyStart, start, null, props, onError);
if (isBlock(key2))
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
const valueProps = resolveProps(sep ?? [], {
flow: fcName,
indicator: "map-value-ind",
next: value,
offset: keyNode.range[2],
onError,
parentIndent: fc.indent,
startOnNewline: false
});
if (valueProps.found) {
if (!isMap2 && !props.found && ctx.options.strict) {
if (sep)
for (const st of sep) {
if (st === valueProps.found)
break;
if (st.type === "newline") {
onError(st, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line");
break;
}
}
if (props.start < valueProps.found.offset - 1024)
onError(valueProps.found, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit flow sequence key");
}
} else if (value) {
if ("source" in value && value.source && value.source[0] === ":")
onError(value, "MISSING_CHAR", `Missing space after : in ${fcName}`);
else
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
}
const valueNode = value ? composeNode2(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode2(ctx, valueProps.end, sep, null, valueProps, onError) : null;
if (valueNode) {
if (isBlock(value))
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
} else if (valueProps.comment) {
if (keyNode.comment)
keyNode.comment += "\n" + valueProps.comment;
else
keyNode.comment = valueProps.comment;
}
const pair2 = new Pair(keyNode, valueNode);
if (ctx.options.keepSourceTokens)
pair2.srcToken = collItem;
if (isMap2) {
const map2 = coll;
if (mapIncludes(ctx, map2.items, keyNode))
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
map2.items.push(pair2);
} else {
const map2 = new YAMLMap(ctx.schema);
map2.flow = true;
map2.items.push(pair2);
coll.items.push(map2);
}
offset2 = valueNode ? valueNode.range[2] : valueProps.end;
}
}
const expectedEnd = isMap2 ? "}" : "]";
const [ce2, ...ee2] = fc.end;
let cePos = offset2;
if (ce2 && ce2.source === expectedEnd)
cePos = ce2.offset + ce2.source.length;
else {
const name2 = fcName[0].toUpperCase() + fcName.substring(1);
const msg = atRoot ? `${name2} must end with a ${expectedEnd}` : `${name2} in block collection must be sufficiently indented and end with a ${expectedEnd}`;
onError(offset2, atRoot ? "MISSING_CHAR" : "BAD_INDENT", msg);
if (ce2 && ce2.source.length !== 1)
ee2.unshift(ce2);
}
if (ee2.length > 0) {
const end = resolveEnd(ee2, cePos, ctx.options.strict, onError);
if (end.comment) {
if (coll.comment)
coll.comment += "\n" + end.comment;
else
coll.comment = end.comment;
}
coll.range = [fc.offset, cePos, end.offset];
} else {
coll.range = [fc.offset, cePos, cePos];
}
return coll;
}
function resolveCollection(CN2, ctx, token, onError, tagName2, tag) {
const coll = token.type === "block-map" ? resolveBlockMap(CN2, ctx, token, onError, tag) : token.type === "block-seq" ? resolveBlockSeq(CN2, ctx, token, onError, tag) : resolveFlowCollection(CN2, ctx, token, onError, tag);
const Coll = coll.constructor;
if (tagName2 === "!" || tagName2 === Coll.tagName) {
coll.tag = Coll.tagName;
return coll;
}
if (tagName2)
coll.tag = tagName2;
return coll;
}
function composeCollection(CN2, ctx, token, tagToken, onError) {
var _a2;
const tagName2 = !tagToken ? null : ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg));
const expType = token.type === "block-map" ? "map" : token.type === "block-seq" ? "seq" : token.start.source === "{" ? "map" : "seq";
if (!tagToken || !tagName2 || tagName2 === "!" || tagName2 === YAMLMap.tagName && expType === "map" || tagName2 === YAMLSeq.tagName && expType === "seq" || !expType) {
return resolveCollection(CN2, ctx, token, onError, tagName2);
}
let tag = ctx.schema.tags.find((t2) => t2.tag === tagName2 && t2.collection === expType);
if (!tag) {
const kt = ctx.schema.knownTags[tagName2];
if (kt && kt.collection === expType) {
ctx.schema.tags.push(Object.assign({}, kt, { default: false }));
tag = kt;
} else {
if (kt == null ? void 0 : kt.collection) {
onError(tagToken, "BAD_COLLECTION_TYPE", `${kt.tag} used for ${expType} collection, but expects ${kt.collection}`, true);
} else {
onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName2}`, true);
}
return resolveCollection(CN2, ctx, token, onError, tagName2);
}
}
const coll = resolveCollection(CN2, ctx, token, onError, tagName2, tag);
const res = ((_a2 = tag.resolve) == null ? void 0 : _a2.call(tag, coll, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg), ctx.options)) ?? coll;
const node = isNode$2(res) ? res : new Scalar(res);
node.range = coll.range;
node.tag = tagName2;
if (tag == null ? void 0 : tag.format)
node.format = tag.format;
return node;
}
function resolveBlockScalar(ctx, scalar, onError) {
const start = scalar.offset;
const header = parseBlockScalarHeader(scalar, ctx.options.strict, onError);
if (!header)
return { value: "", type: null, comment: "", range: [start, start, start] };
const type2 = header.mode === ">" ? Scalar.BLOCK_FOLDED : Scalar.BLOCK_LITERAL;
const lines = scalar.source ? splitLines(scalar.source) : [];
let chompStart = lines.length;
for (let i2 = lines.length - 1; i2 >= 0; --i2) {
const content2 = lines[i2][1];
if (content2 === "" || content2 === "\r")
chompStart = i2;
else
break;
}
if (chompStart === 0) {
const value2 = header.chomp === "+" && lines.length > 0 ? "\n".repeat(Math.max(1, lines.length - 1)) : "";
let end2 = start + header.length;
if (scalar.source)
end2 += scalar.source.length;
return { value: value2, type: type2, comment: header.comment, range: [start, end2, end2] };
}
let trimIndent = scalar.indent + header.indent;
let offset2 = scalar.offset + header.length;
let contentStart = 0;
for (let i2 = 0; i2 < chompStart; ++i2) {
const [indent, content2] = lines[i2];
if (content2 === "" || content2 === "\r") {
if (header.indent === 0 && indent.length > trimIndent)
trimIndent = indent.length;
} else {
if (indent.length < trimIndent) {
const message = "Block scalars with more-indented leading empty lines must use an explicit indentation indicator";
onError(offset2 + indent.length, "MISSING_CHAR", message);
}
if (header.indent === 0)
trimIndent = indent.length;
contentStart = i2;
if (trimIndent === 0 && !ctx.atRoot) {
const message = "Block scalar values in collections must be indented";
onError(offset2, "BAD_INDENT", message);
}
break;
}
offset2 += indent.length + content2.length + 1;
}
for (let i2 = lines.length - 1; i2 >= chompStart; --i2) {
if (lines[i2][0].length > trimIndent)
chompStart = i2 + 1;
}
let value = "";
let sep = "";
let prevMoreIndented = false;
for (let i2 = 0; i2 < contentStart; ++i2)
value += lines[i2][0].slice(trimIndent) + "\n";
for (let i2 = contentStart; i2 < chompStart; ++i2) {
let [indent, content2] = lines[i2];
offset2 += indent.length + content2.length + 1;
const crlf = content2[content2.length - 1] === "\r";
if (crlf)
content2 = content2.slice(0, -1);
if (content2 && indent.length < trimIndent) {
const src = header.indent ? "explicit indentation indicator" : "first line";
const message = `Block scalar lines must not be less indented than their ${src}`;
onError(offset2 - content2.length - (crlf ? 2 : 1), "BAD_INDENT", message);
indent = "";
}
if (type2 === Scalar.BLOCK_LITERAL) {
value += sep + indent.slice(trimIndent) + content2;
sep = "\n";
} else if (indent.length > trimIndent || content2[0] === " ") {
if (sep === " ")
sep = "\n";
else if (!prevMoreIndented && sep === "\n")
sep = "\n\n";
value += sep + indent.slice(trimIndent) + content2;
sep = "\n";
prevMoreIndented = true;
} else if (content2 === "") {
if (sep === "\n")
value += "\n";
else
sep = "\n";
} else {
value += sep + content2;
sep = " ";
prevMoreIndented = false;
}
}
switch (header.chomp) {
case "-":
break;
case "+":
for (let i2 = chompStart; i2 < lines.length; ++i2)
value += "\n" + lines[i2][0].slice(trimIndent);
if (value[value.length - 1] !== "\n")
value += "\n";
break;
default:
value += "\n";
}
const end = start + header.length + scalar.source.length;
return { value, type: type2, comment: header.comment, range: [start, end, end] };
}
function parseBlockScalarHeader({ offset: offset2, props }, strict, onError) {
if (props[0].type !== "block-scalar-header") {
onError(props[0], "IMPOSSIBLE", "Block scalar header not found");
return null;
}
const { source: source2 } = props[0];
const mode = source2[0];
let indent = 0;
let chomp = "";
let error2 = -1;
for (let i2 = 1; i2 < source2.length; ++i2) {
const ch = source2[i2];
if (!chomp && (ch === "-" || ch === "+"))
chomp = ch;
else {
const n2 = Number(ch);
if (!indent && n2)
indent = n2;
else if (error2 === -1)
error2 = offset2 + i2;
}
}
if (error2 !== -1)
onError(error2, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source2}`);
let hasSpace = false;
let comment2 = "";
let length = source2.length;
for (let i2 = 1; i2 < props.length; ++i2) {
const token = props[i2];
switch (token.type) {
case "space":
hasSpace = true;
case "newline":
length += token.source.length;
break;
case "comment":
if (strict && !hasSpace) {
const message = "Comments must be separated from other tokens by white space characters";
onError(token, "MISSING_CHAR", message);
}
length += token.source.length;
comment2 = token.source.substring(1);
break;
case "error":
onError(token, "UNEXPECTED_TOKEN", token.message);
length += token.source.length;
break;
default: {
const message = `Unexpected token in block scalar header: ${token.type}`;
onError(token, "UNEXPECTED_TOKEN", message);
const ts = token.source;
if (ts && typeof ts === "string")
length += ts.length;
}
}
}
return { mode, indent, chomp, comment: comment2, length };
}
function splitLines(source2) {
const split = source2.split(/\n( *)/);
const first = split[0];
const m2 = first.match(/^( *)/);
const line0 = (m2 == null ? void 0 : m2[1]) ? [m2[1], first.slice(m2[1].length)] : ["", first];
const lines = [line0];
for (let i2 = 1; i2 < split.length; i2 += 2)
lines.push([split[i2], split[i2 + 1]]);
return lines;
}
function resolveFlowScalar(scalar, strict, onError) {
const { offset: offset2, type: type2, source: source2, end } = scalar;
let _type;
let value;
const _onError = (rel, code, msg) => onError(offset2 + rel, code, msg);
switch (type2) {
case "scalar":
_type = Scalar.PLAIN;
value = plainValue(source2, _onError);
break;
case "single-quoted-scalar":
_type = Scalar.QUOTE_SINGLE;
value = singleQuotedValue(source2, _onError);
break;
case "double-quoted-scalar":
_type = Scalar.QUOTE_DOUBLE;
value = doubleQuotedValue(source2, _onError);
break;
default:
onError(scalar, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type2}`);
return {
value: "",
type: null,
comment: "",
range: [offset2, offset2 + source2.length, offset2 + source2.length]
};
}
const valueEnd = offset2 + source2.length;
const re2 = resolveEnd(end, valueEnd, strict, onError);
return {
value,
type: _type,
comment: re2.comment,
range: [offset2, valueEnd, re2.offset]
};
}
function plainValue(source2, onError) {
let badChar = "";
switch (source2[0]) {
case " ":
badChar = "a tab character";
break;
case ",":
badChar = "flow indicator character ,";
break;
case "%":
badChar = "directive indicator character %";
break;
case "|":
case ">": {
badChar = `block scalar indicator ${source2[0]}`;
break;
}
case "@":
case "`": {
badChar = `reserved character ${source2[0]}`;
break;
}
}
if (badChar)
onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
return foldLines(source2);
}
function singleQuotedValue(source2, onError) {
if (source2[source2.length - 1] !== "'" || source2.length === 1)
onError(source2.length, "MISSING_CHAR", "Missing closing 'quote");
return foldLines(source2.slice(1, -1)).replace(/''/g, "'");
}
function foldLines(source2) {
let first, line;
try {
first = new RegExp("(.*?)(?<![ ])[ ]*\r?\n", "sy");
line = new RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n", "sy");
} catch (_2) {
first = /(.*?)[ \t]*\r?\n/sy;
line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
}
let match = first.exec(source2);
if (!match)
return source2;
let res = match[1];
let sep = " ";
let pos = first.lastIndex;
line.lastIndex = pos;
while (match = line.exec(source2)) {
if (match[1] === "") {
if (sep === "\n")
res += sep;
else
sep = "\n";
} else {
res += sep + match[1];
sep = " ";
}
pos = line.lastIndex;
}
const last = /[ \t]*(.*)/sy;
last.lastIndex = pos;
match = last.exec(source2);
return res + sep + ((match == null ? void 0 : match[1]) ?? "");
}
function doubleQuotedValue(source2, onError) {
let res = "";
for (let i2 = 1; i2 < source2.length - 1; ++i2) {
const ch = source2[i2];
if (ch === "\r" && source2[i2 + 1] === "\n")
continue;
if (ch === "\n") {
const { fold, offset: offset2 } = foldNewline(source2, i2);
res += fold;
i2 = offset2;
} else if (ch === "\\") {
let next = source2[++i2];
const cc = escapeCodes[next];
if (cc)
res += cc;
else if (next === "\n") {
next = source2[i2 + 1];
while (next === " " || next === " ")
next = source2[++i2 + 1];
} else if (next === "\r" && source2[i2 + 1] === "\n") {
next = source2[++i2 + 1];
while (next === " " || next === " ")
next = source2[++i2 + 1];
} else if (next === "x" || next === "u" || next === "U") {
const length = { x: 2, u: 4, U: 8 }[next];
res += parseCharCode(source2, i2 + 1, length, onError);
i2 += length;
} else {
const raw2 = source2.substr(i2 - 1, 2);
onError(i2 - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw2}`);
res += raw2;
}
} else if (ch === " " || ch === " ") {
const wsStart = i2;
let next = source2[i2 + 1];
while (next === " " || next === " ")
next = source2[++i2 + 1];
if (next !== "\n" && !(next === "\r" && source2[i2 + 2] === "\n"))
res += i2 > wsStart ? source2.slice(wsStart, i2 + 1) : ch;
} else {
res += ch;
}
}
if (source2[source2.length - 1] !== '"' || source2.length === 1)
onError(source2.length, "MISSING_CHAR", 'Missing closing "quote');
return res;
}
function foldNewline(source2, offset2) {
let fold = "";
let ch = source2[offset2 + 1];
while (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
if (ch === "\r" && source2[offset2 + 2] !== "\n")
break;
if (ch === "\n")
fold += "\n";
offset2 += 1;
ch = source2[offset2 + 1];
}
if (!fold)
fold = " ";
return { fold, offset: offset2 };
}
const escapeCodes = {
"0": "\0",
// null character
a: "\x07",
// bell character
b: "\b",
// backspace
e: "\x1B",
// escape character
f: "\f",
// form feed
n: "\n",
// line feed
r: "\r",
// carriage return
t: " ",
// horizontal tab
v: "\v",
// vertical tab
N: "…",
// Unicode next line
_: " ",
// Unicode non-breaking space
L: "\u2028",
// Unicode line separator
P: "\u2029",
// Unicode paragraph separator
" ": " ",
'"': '"',
"/": "/",
"\\": "\\",
" ": " "
};
function parseCharCode(source2, offset2, length, onError) {
const cc = source2.substr(offset2, length);
const ok2 = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
const code = ok2 ? parseInt(cc, 16) : NaN;
if (isNaN(code)) {
const raw2 = source2.substr(offset2 - 2, length + 2);
onError(offset2 - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw2}`);
return raw2;
}
return String.fromCodePoint(code);
}
function composeScalar(ctx, token, tagToken, onError) {
const { value, type: type2, comment: comment2, range } = token.type === "block-scalar" ? resolveBlockScalar(ctx, token, onError) : resolveFlowScalar(token, ctx.options.strict, onError);
const tagName2 = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null;
const tag = tagToken && tagName2 ? findScalarTagByName(ctx.schema, value, tagName2, tagToken, onError) : token.type === "scalar" ? findScalarTagByTest(ctx, value, token, onError) : ctx.schema[SCALAR$1];
let scalar;
try {
const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
scalar = isScalar(res) ? res : new Scalar(res);
} catch (error2) {
const msg = error2 instanceof Error ? error2.message : String(error2);
onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
scalar = new Scalar(value);
}
scalar.range = range;
scalar.source = value;
if (type2)
scalar.type = type2;
if (tagName2)
scalar.tag = tagName2;
if (tag.format)
scalar.format = tag.format;
if (comment2)
scalar.comment = comment2;
return scalar;
}
function findScalarTagByName(schema2, value, tagName2, tagToken, onError) {
var _a2;
if (tagName2 === "!")
return schema2[SCALAR$1];
const matchWithTest = [];
for (const tag of schema2.tags) {
if (!tag.collection && tag.tag === tagName2) {
if (tag.default && tag.test)
matchWithTest.push(tag);
else
return tag;
}
}
for (const tag of matchWithTest)
if ((_a2 = tag.test) == null ? void 0 : _a2.test(value))
return tag;
const kt = schema2.knownTags[tagName2];
if (kt && !kt.collection) {
schema2.tags.push(Object.assign({}, kt, { default: false, test: void 0 }));
return kt;
}
onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName2}`, tagName2 !== "tag:yaml.org,2002:str");
return schema2[SCALAR$1];
}
function findScalarTagByTest({ directives, schema: schema2 }, value, token, onError) {
const tag = schema2.tags.find((tag2) => {
var _a2;
return tag2.default && ((_a2 = tag2.test) == null ? void 0 : _a2.test(value));
}) || schema2[SCALAR$1];
if (schema2.compat) {
const compat = schema2.compat.find((tag2) => {
var _a2;
return tag2.default && ((_a2 = tag2.test) == null ? void 0 : _a2.test(value));
}) ?? schema2[SCALAR$1];
if (tag.tag !== compat.tag) {
const ts = directives.tagString(tag.tag);
const cs = directives.tagString(compat.tag);
const msg = `Value may be parsed as either ${ts} or ${cs}`;
onError(token, "TAG_RESOLVE_FAILED", msg, true);
}
}
return tag;
}
function emptyScalarPosition(offset2, before, pos) {
if (before) {
if (pos === null)
pos = before.length;
for (let i2 = pos - 1; i2 >= 0; --i2) {
let st = before[i2];
switch (st.type) {
case "space":
case "comment":
case "newline":
offset2 -= st.source.length;
continue;
}
st = before[++i2];
while ((st == null ? void 0 : st.type) === "space") {
offset2 += st.source.length;
st = before[++i2];
}
break;
}
}
return offset2;
}
const CN = { composeNode, composeEmptyNode };
function composeNode(ctx, token, props, onError) {
const { spaceBefore, comment: comment2, anchor, tag } = props;
let node;
let isSrcToken = true;
switch (token.type) {
case "alias":
node = composeAlias(ctx, token, onError);
if (anchor || tag)
onError(token, "ALIAS_PROPS", "An alias node must not specify any properties");
break;
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar":
case "block-scalar":
node = composeScalar(ctx, token, tag, onError);
if (anchor)
node.anchor = anchor.source.substring(1);
break;
case "block-map":
case "block-seq":
case "flow-collection":
node = composeCollection(CN, ctx, token, tag, onError);
if (anchor)
node.anchor = anchor.source.substring(1);
break;
default: {
const message = token.type === "error" ? token.message : `Unsupported token (type: ${token.type})`;
onError(token, "UNEXPECTED_TOKEN", message);
node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError);
isSrcToken = false;
}
}
if (anchor && node.anchor === "")
onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string");
if (spaceBefore)
node.spaceBefore = true;
if (comment2) {
if (token.type === "scalar" && token.source === "")
node.comment = comment2;
else
node.commentBefore = comment2;
}
if (ctx.options.keepSourceTokens && isSrcToken)
node.srcToken = token;
return node;
}
function composeEmptyNode(ctx, offset2, before, pos, { spaceBefore, comment: comment2, anchor, tag, end }, onError) {
const token = {
type: "scalar",
offset: emptyScalarPosition(offset2, before, pos),
indent: -1,
source: ""
};
const node = composeScalar(ctx, token, tag, onError);
if (anchor) {
node.anchor = anchor.source.substring(1);
if (node.anchor === "")
onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string");
}
if (spaceBefore)
node.spaceBefore = true;
if (comment2) {
node.comment = comment2;
node.range[2] = end;
}
return node;
}
function composeAlias({ options }, { offset: offset2, source: source2, end }, onError) {
const alias = new Alias$1(source2.substring(1));
if (alias.source === "")
onError(offset2, "BAD_ALIAS", "Alias cannot be an empty string");
if (alias.source.endsWith(":"))
onError(offset2 + source2.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", true);
const valueEnd = offset2 + source2.length;
const re2 = resolveEnd(end, valueEnd, options.strict, onError);
alias.range = [offset2, valueEnd, re2.offset];
if (re2.comment)
alias.comment = re2.comment;
return alias;
}
function composeDoc(options, directives, { offset: offset2, start, value, end }, onError) {
const opts = Object.assign({ _directives: directives }, options);
const doc2 = new Document(void 0, opts);
const ctx = {
atRoot: true,
directives: doc2.directives,
options: doc2.options,
schema: doc2.schema
};
const props = resolveProps(start, {
indicator: "doc-start",
next: value ?? (end == null ? void 0 : end[0]),
offset: offset2,
onError,
parentIndent: 0,
startOnNewline: true
});
if (props.found) {
doc2.directives.docStart = true;
if (value && (value.type === "block-map" || value.type === "block-seq") && !props.hasNewline)
onError(props.end, "MISSING_CHAR", "Block collection cannot start on same line with directives-end marker");
}
doc2.contents = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, start, null, props, onError);
const contentEnd = doc2.contents.range[2];
const re2 = resolveEnd(end, contentEnd, false, onError);
if (re2.comment)
doc2.comment = re2.comment;
doc2.range = [offset2, contentEnd, re2.offset];
return doc2;
}
function getErrorPos(src) {
if (typeof src === "number")
return [src, src + 1];
if (Array.isArray(src))
return src.length === 2 ? src : [src[0], src[1]];
const { offset: offset2, source: source2 } = src;
return [offset2, offset2 + (typeof source2 === "string" ? source2.length : 1)];
}
function parsePrelude(prelude) {
var _a2;
let comment2 = "";
let atComment = false;
let afterEmptyLine = false;
for (let i2 = 0; i2 < prelude.length; ++i2) {
const source2 = prelude[i2];
switch (source2[0]) {
case "#":
comment2 += (comment2 === "" ? "" : afterEmptyLine ? "\n\n" : "\n") + (source2.substring(1) || " ");
atComment = true;
afterEmptyLine = false;
break;
case "%":
if (((_a2 = prelude[i2 + 1]) == null ? void 0 : _a2[0]) !== "#")
i2 += 1;
atComment = false;
break;
default:
if (!atComment)
afterEmptyLine = true;
atComment = false;
}
}
return { comment: comment2, afterEmptyLine };
}
class Composer {
constructor(options = {}) {
this.doc = null;
this.atDirectives = false;
this.prelude = [];
this.errors = [];
this.warnings = [];
this.onError = (source2, code, message, warning) => {
const pos = getErrorPos(source2);
if (warning)
this.warnings.push(new YAMLWarning(pos, code, message));
else
this.errors.push(new YAMLParseError(pos, code, message));
};
this.directives = new Directives({ version: options.version || "1.2" });
this.options = options;
}
decorate(doc2, afterDoc) {
const { comment: comment2, afterEmptyLine } = parsePrelude(this.prelude);
if (comment2) {
const dc = doc2.contents;
if (afterDoc) {
doc2.comment = doc2.comment ? `${doc2.comment}
${comment2}` : comment2;
} else if (afterEmptyLine || doc2.directives.docStart || !dc) {
doc2.commentBefore = comment2;
} else if (isCollection(dc) && !dc.flow && dc.items.length > 0) {
let it = dc.items[0];
if (isPair(it))
it = it.key;
const cb = it.commentBefore;
it.commentBefore = cb ? `${comment2}
${cb}` : comment2;
} else {
const cb = dc.commentBefore;
dc.commentBefore = cb ? `${comment2}
${cb}` : comment2;
}
}
if (afterDoc) {
Array.prototype.push.apply(doc2.errors, this.errors);
Array.prototype.push.apply(doc2.warnings, this.warnings);
} else {
doc2.errors = this.errors;
doc2.warnings = this.warnings;
}
this.prelude = [];
this.errors = [];
this.warnings = [];
}
/**
* Current stream status information.
*
* Mostly useful at the end of input for an empty stream.
*/
streamInfo() {
return {
comment: parsePrelude(this.prelude).comment,
directives: this.directives,
errors: this.errors,
warnings: this.warnings
};
}
/**
* Compose tokens into documents.
*
* @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
*/
*compose(tokens, forceDoc = false, endOffset = -1) {
for (const token of tokens)
yield* this.next(token);
yield* this.end(forceDoc, endOffset);
}
/** Advance the composer by one CST token. */
*next(token) {
switch (token.type) {
case "directive":
this.directives.add(token.source, (offset2, message, warning) => {
const pos = getErrorPos(token);
pos[0] += offset2;
this.onError(pos, "BAD_DIRECTIVE", message, warning);
});
this.prelude.push(token.source);
this.atDirectives = true;
break;
case "document": {
const doc2 = composeDoc(this.options, this.directives, token, this.onError);
if (this.atDirectives && !doc2.directives.docStart)
this.onError(token, "MISSING_CHAR", "Missing directives-end/doc-start indicator line");
this.decorate(doc2, false);
if (this.doc)
yield this.doc;
this.doc = doc2;
this.atDirectives = false;
break;
}
case "byte-order-mark":
case "space":
break;
case "comment":
case "newline":
this.prelude.push(token.source);
break;
case "error": {
const msg = token.source ? `${token.message}: ${JSON.stringify(token.source)}` : token.message;
const error2 = new YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
if (this.atDirectives || !this.doc)
this.errors.push(error2);
else
this.doc.errors.push(error2);
break;
}
case "doc-end": {
if (!this.doc) {
const msg = "Unexpected doc-end without preceding document";
this.errors.push(new YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg));
break;
}
this.doc.directives.docEnd = true;
const end = resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError);
this.decorate(this.doc, true);
if (end.comment) {
const dc = this.doc.comment;
this.doc.comment = dc ? `${dc}
${end.comment}` : end.comment;
}
this.doc.range[2] = end.offset;
break;
}
default:
this.errors.push(new YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`));
}
}
/**
* Call at end of input to yield any remaining document.
*
* @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
*/
*end(forceDoc = false, endOffset = -1) {
if (this.doc) {
this.decorate(this.doc, true);
yield this.doc;
this.doc = null;
} else if (forceDoc) {
const opts = Object.assign({ _directives: this.directives }, this.options);
const doc2 = new Document(void 0, opts);
if (this.atDirectives)
this.onError(endOffset, "MISSING_CHAR", "Missing directives-end indicator line");
doc2.range = [0, endOffset, endOffset];
this.decorate(doc2, false);
yield doc2;
}
}
}
const BOM = "\uFEFF";
const DOCUMENT = "";
const FLOW_END = "";
const SCALAR = "";
function tokenType(source2) {
switch (source2) {
case BOM:
return "byte-order-mark";
case DOCUMENT:
return "doc-mode";
case FLOW_END:
return "flow-error-end";
case SCALAR:
return "scalar";
case "---":
return "doc-start";
case "...":
return "doc-end";
case "":
case "\n":
case "\r\n":
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 (source2[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 isEmpty(ch) {
switch (ch) {
case void 0:
case " ":
case "\n":
case "\r":
case " ":
return true;
default:
return false;
}
}
const hexDigits$2 = new Set("0123456789ABCDEFabcdef");
const tagChars = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()");
const flowIndicatorChars = new Set(",[]{}");
const invalidAnchorChars = new Set(" ,[]{}\n\r ");
const isNotAnchorChar = (ch) => !ch || invalidAnchorChars.has(ch);
class Lexer {
constructor() {
this.atEnd = false;
this.blockScalarIndent = -1;
this.blockScalarKeep = false;
this.buffer = "";
this.flowKey = false;
this.flowLevel = 0;
this.indentNext = 0;
this.indentValue = 0;
this.lineEndPos = null;
this.next = null;
this.pos = 0;
}
/**
* Generate YAML tokens from the `source` string. If `incomplete`,
* a part of the last line may be left as a buffer for the next call.
*
* @returns A generator of lexical tokens
*/
*lex(source2, incomplete = false) {
if (source2) {
if (typeof source2 !== "string")
throw TypeError("source is not a string");
this.buffer = this.buffer ? this.buffer + source2 : source2;
this.lineEndPos = null;
}
this.atEnd = !incomplete;
let next = this.next ?? "stream";
while (next && (incomplete || this.hasChars(1)))
next = yield* this.parseNext(next);
}
atLineEnd() {
let i2 = this.pos;
let ch = this.buffer[i2];
while (ch === " " || ch === " ")
ch = this.buffer[++i2];
if (!ch || ch === "#" || ch === "\n")
return true;
if (ch === "\r")
return this.buffer[i2 + 1] === "\n";
return false;
}
charAt(n2) {
return this.buffer[this.pos + n2];
}
continueScalar(offset2) {
let ch = this.buffer[offset2];
if (this.indentNext > 0) {
let indent = 0;
while (ch === " ")
ch = this.buffer[++indent + offset2];
if (ch === "\r") {
const next = this.buffer[indent + offset2 + 1];
if (next === "\n" || !next && !this.atEnd)
return offset2 + indent + 1;
}
return ch === "\n" || indent >= this.indentNext || !ch && !this.atEnd ? offset2 + indent : -1;
}
if (ch === "-" || ch === ".") {
const dt2 = this.buffer.substr(offset2, 3);
if ((dt2 === "---" || dt2 === "...") && isEmpty(this.buffer[offset2 + 3]))
return -1;
}
return offset2;
}
getLine() {
let end = this.lineEndPos;
if (typeof end !== "number" || end !== -1 && end < this.pos) {
end = this.buffer.indexOf("\n", this.pos);
this.lineEndPos = end;
}
if (end === -1)
return this.atEnd ? this.buffer.substring(this.pos) : null;
if (this.buffer[end - 1] === "\r")
end -= 1;
return this.buffer.substring(this.pos, end);
}
hasChars(n2) {
return this.pos + n2 <= this.buffer.length;
}
setNext(state) {
this.buffer = this.buffer.substring(this.pos);
this.pos = 0;
this.lineEndPos = null;
this.next = state;
return null;
}
peek(n2) {
return this.buffer.substr(this.pos, n2);
}
*parseNext(next) {
switch (next) {
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 line = this.getLine();
if (line === null)
return this.setNext("stream");
if (line[0] === BOM) {
yield* this.pushCount(1);
line = line.substring(1);
}
if (line[0] === "%") {
let dirEnd = line.length;
let cs = line.indexOf("#");
while (cs !== -1) {
const ch = line[cs - 1];
if (ch === " " || ch === " ") {
dirEnd = cs - 1;
break;
} else {
cs = line.indexOf("#", cs + 1);
}
}
while (true) {
const ch = line[dirEnd - 1];
if (ch === " " || ch === " ")
dirEnd -= 1;
else
break;
}
const n2 = (yield* this.pushCount(dirEnd)) + (yield* this.pushSpaces(true));
yield* this.pushCount(line.length - n2);
this.pushNewline();
return "stream";
}
if (this.atLineEnd()) {
const sp = yield* this.pushSpaces(true);
yield* this.pushCount(line.length - sp);
yield* this.pushNewline();
return "stream";
}
yield DOCUMENT;
return yield* this.parseLineStart();
}
*parseLineStart() {
const ch = this.charAt(0);
if (!ch && !this.atEnd)
return this.setNext("line-start");
if (ch === "-" || ch === ".") {
if (!this.atEnd && !this.hasChars(4))
return this.setNext("line-start");
const s3 = this.peek(3);
if (s3 === "---" && isEmpty(this.charAt(3))) {
yield* this.pushCount(3);
this.indentValue = 0;
this.indentNext = 0;
return "doc";
} else if (s3 === "..." && isEmpty(this.charAt(3))) {
yield* this.pushCount(3);
return "stream";
}
}
this.indentValue = yield* this.pushSpaces(false);
if (this.indentNext > this.indentValue && !isEmpty(this.charAt(1)))
this.indentNext = this.indentValue;
return yield* this.parseBlockStart();
}
*parseBlockStart() {
const [ch0, ch1] = this.peek(2);
if (!ch1 && !this.atEnd)
return this.setNext("block-start");
if ((ch0 === "-" || ch0 === "?" || ch0 === ":") && isEmpty(ch1)) {
const n2 = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
this.indentNext = this.indentValue + 1;
this.indentValue += n2;
return yield* this.parseBlockStart();
}
return "doc";
}
*parseDocument() {
yield* this.pushSpaces(true);
const line = this.getLine();
if (line === null)
return this.setNext("doc");
let n2 = yield* this.pushIndicators();
switch (line[n2]) {
case "#":
yield* this.pushCount(line.length - n2);
case void 0:
yield* this.pushNewline();
return yield* this.parseLineStart();
case "{":
case "[":
yield* this.pushCount(1);
this.flowKey = false;
this.flowLevel = 1;
return "flow";
case "}":
case "]":
yield* this.pushCount(1);
return "doc";
case "*":
yield* this.pushUntil(isNotAnchorChar);
return "doc";
case '"':
case "'":
return yield* this.parseQuotedScalar();
case "|":
case ">":
n2 += yield* this.parseBlockScalarHeader();
n2 += yield* this.pushSpaces(true);
yield* this.pushCount(line.length - n2);
yield* this.pushNewline();
return yield* this.parseBlockScalar();
default:
return yield* this.parsePlainScalar();
}
}
*parseFlowCollection() {
let nl, sp;
let indent = -1;
do {
nl = yield* this.pushNewline();
if (nl > 0) {
sp = yield* this.pushSpaces(false);
this.indentValue = indent = sp;
} else {
sp = 0;
}
sp += yield* this.pushSpaces(true);
} while (nl + sp > 0);
const line = this.getLine();
if (line === null)
return this.setNext("flow");
if (indent !== -1 && indent < this.indentNext && line[0] !== "#" || indent === 0 && (line.startsWith("---") || line.startsWith("...")) && isEmpty(line[3])) {
const atFlowEndMarker = indent === this.indentNext - 1 && this.flowLevel === 1 && (line[0] === "]" || line[0] === "}");
if (!atFlowEndMarker) {
this.flowLevel = 0;
yield FLOW_END;
return yield* this.parseLineStart();
}
}
let n2 = 0;
while (line[n2] === ",") {
n2 += yield* this.pushCount(1);
n2 += yield* this.pushSpaces(true);
this.flowKey = false;
}
n2 += yield* this.pushIndicators();
switch (line[n2]) {
case void 0:
return "flow";
case "#":
yield* this.pushCount(line.length - n2);
return "flow";
case "{":
case "[":
yield* this.pushCount(1);
this.flowKey = false;
this.flowLevel += 1;
return "flow";
case "}":
case "]":
yield* this.pushCount(1);
this.flowKey = true;
this.flowLevel -= 1;
return this.flowLevel ? "flow" : "doc";
case "*":
yield* this.pushUntil(isNotAnchorChar);
return "flow";
case '"':
case "'":
this.flowKey = true;
return yield* this.parseQuotedScalar();
case ":": {
const next = this.charAt(1);
if (this.flowKey || isEmpty(next) || next === ",") {
this.flowKey = false;
yield* this.pushCount(1);
yield* this.pushSpaces(true);
return "flow";
}
}
default:
this.flowKey = false;
return yield* this.parsePlainScalar();
}
}
*parseQuotedScalar() {
const quote = this.charAt(0);
let end = this.buffer.indexOf(quote, this.pos + 1);
if (quote === "'") {
while (end !== -1 && this.buffer[end + 1] === "'")
end = this.buffer.indexOf("'", end + 2);
} else {
while (end !== -1) {
let n2 = 0;
while (this.buffer[end - 1 - n2] === "\\")
n2 += 1;
if (n2 % 2 === 0)
break;
end = this.buffer.indexOf('"', end + 1);
}
}
const qb = this.buffer.substring(0, end);
let nl = qb.indexOf("\n", this.pos);
if (nl !== -1) {
while (nl !== -1) {
const cs = this.continueScalar(nl + 1);
if (cs === -1)
break;
nl = qb.indexOf("\n", cs);
}
if (nl !== -1) {
end = nl - (qb[nl - 1] === "\r" ? 2 : 1);
}
}
if (end === -1) {
if (!this.atEnd)
return this.setNext("quoted-scalar");
end = this.buffer.length;
}
yield* this.pushToIndex(end + 1, false);
return this.flowLevel ? "flow" : "doc";
}
*parseBlockScalarHeader() {
this.blockScalarIndent = -1;
this.blockScalarKeep = false;
let i2 = this.pos;
while (true) {
const ch = this.buffer[++i2];
if (ch === "+")
this.blockScalarKeep = true;
else if (ch > "0" && ch <= "9")
this.blockScalarIndent = Number(ch) - 1;
else if (ch !== "-")
break;
}
return yield* this.pushUntil((ch) => isEmpty(ch) || ch === "#");
}
*parseBlockScalar() {
let nl = this.pos - 1;
let indent = 0;
let ch;
loop: for (let i3 = this.pos; ch = this.buffer[i3]; ++i3) {
switch (ch) {
case " ":
indent += 1;
break;
case "\n":
nl = i3;
indent = 0;
break;
case "\r": {
const next = this.buffer[i3 + 1];
if (!next && !this.atEnd)
return this.setNext("block-scalar");
if (next === "\n")
break;
}
default:
break loop;
}
}
if (!ch && !this.atEnd)
return this.setNext("block-scalar");
if (indent >= this.indentNext) {
if (this.blockScalarIndent === -1)
this.indentNext = indent;
else {
this.indentNext = this.blockScalarIndent + (this.indentNext === 0 ? 1 : this.indentNext);
}
do {
const cs = this.continueScalar(nl + 1);
if (cs === -1)
break;
nl = this.buffer.indexOf("\n", cs);
} while (nl !== -1);
if (nl === -1) {
if (!this.atEnd)
return this.setNext("block-scalar");
nl = this.buffer.length;
}
}
let i2 = nl + 1;
ch = this.buffer[i2];
while (ch === " ")
ch = this.buffer[++i2];
if (ch === " ") {
while (ch === " " || ch === " " || ch === "\r" || ch === "\n")
ch = this.buffer[++i2];
nl = i2 - 1;
} else if (!this.blockScalarKeep) {
do {
let i3 = nl - 1;
let ch2 = this.buffer[i3];
if (ch2 === "\r")
ch2 = this.buffer[--i3];
const lastChar = i3;
while (ch2 === " ")
ch2 = this.buffer[--i3];
if (ch2 === "\n" && i3 >= this.pos && i3 + 1 + indent > lastChar)
nl = i3;
else
break;
} while (true);
}
yield SCALAR;
yield* this.pushToIndex(nl + 1, true);
return yield* this.parseLineStart();
}
*parsePlainScalar() {
const inFlow = this.flowLevel > 0;
let end = this.pos - 1;
let i2 = this.pos - 1;
let ch;
while (ch = this.buffer[++i2]) {
if (ch === ":") {
const next = this.buffer[i2 + 1];
if (isEmpty(next) || inFlow && flowIndicatorChars.has(next))
break;
end = i2;
} else if (isEmpty(ch)) {
let next = this.buffer[i2 + 1];
if (ch === "\r") {
if (next === "\n") {
i2 += 1;
ch = "\n";
next = this.buffer[i2 + 1];
} else
end = i2;
}
if (next === "#" || inFlow && flowIndicatorChars.has(next))
break;
if (ch === "\n") {
const cs = this.continueScalar(i2 + 1);
if (cs === -1)
break;
i2 = Math.max(i2, cs - 2);
}
} else {
if (inFlow && flowIndicatorChars.has(ch))
break;
end = i2;
}
}
if (!ch && !this.atEnd)
return this.setNext("plain-scalar");
yield SCALAR;
yield* this.pushToIndex(end + 1, true);
return inFlow ? "flow" : "doc";
}
*pushCount(n2) {
if (n2 > 0) {
yield this.buffer.substr(this.pos, n2);
this.pos += n2;
return n2;
}
return 0;
}
*pushToIndex(i2, allowEmpty) {
const s3 = this.buffer.slice(this.pos, i2);
if (s3) {
yield s3;
this.pos += s3.length;
return s3.length;
} else if (allowEmpty)
yield "";
return 0;
}
*pushIndicators() {
switch (this.charAt(0)) {
case "!":
return (yield* this.pushTag()) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators());
case "&":
return (yield* this.pushUntil(isNotAnchorChar)) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators());
case "-":
case "?":
case ":": {
const inFlow = this.flowLevel > 0;
const ch1 = this.charAt(1);
if (isEmpty(ch1) || inFlow && flowIndicatorChars.has(ch1)) {
if (!inFlow)
this.indentNext = this.indentValue + 1;
else if (this.flowKey)
this.flowKey = false;
return (yield* this.pushCount(1)) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators());
}
}
}
return 0;
}
*pushTag() {
if (this.charAt(1) === "<") {
let i2 = this.pos + 2;
let ch = this.buffer[i2];
while (!isEmpty(ch) && ch !== ">")
ch = this.buffer[++i2];
return yield* this.pushToIndex(ch === ">" ? i2 + 1 : i2, false);
} else {
let i2 = this.pos + 1;
let ch = this.buffer[i2];
while (ch) {
if (tagChars.has(ch))
ch = this.buffer[++i2];
else if (ch === "%" && hexDigits$2.has(this.buffer[i2 + 1]) && hexDigits$2.has(this.buffer[i2 + 2])) {
ch = this.buffer[i2 += 3];
} else
break;
}
return yield* this.pushToIndex(i2, false);
}
}
*pushNewline() {
const ch = this.buffer[this.pos];
if (ch === "\n")
return yield* this.pushCount(1);
else if (ch === "\r" && this.charAt(1) === "\n")
return yield* this.pushCount(2);
else
return 0;
}
*pushSpaces(allowTabs) {
let i2 = this.pos - 1;
let ch;
do {
ch = this.buffer[++i2];
} while (ch === " " || allowTabs && ch === " ");
const n2 = i2 - this.pos;
if (n2 > 0) {
yield this.buffer.substr(this.pos, n2);
this.pos = i2;
}
return n2;
}
*pushUntil(test) {
let i2 = this.pos;
let ch = this.buffer[i2];
while (!test(ch))
ch = this.buffer[++i2];
return yield* this.pushToIndex(i2, false);
}
}
class LineCounter {
constructor() {
this.lineStarts = [];
this.addNewLine = (offset2) => this.lineStarts.push(offset2);
this.linePos = (offset2) => {
let low = 0;
let high = this.lineStarts.length;
while (low < high) {
const mid = low + high >> 1;
if (this.lineStarts[mid] < offset2)
low = mid + 1;
else
high = mid;
}
if (this.lineStarts[low] === offset2)
return { line: low + 1, col: 1 };
if (low === 0)
return { line: 0, col: offset2 };
const start = this.lineStarts[low - 1];
return { line: low, col: offset2 - start + 1 };
};
}
}
function includesToken(list, type2) {
for (let i2 = 0; i2 < list.length; ++i2)
if (list[i2].type === type2)
return true;
return false;
}
function findNonEmptyIndex(list) {
for (let i2 = 0; i2 < list.length; ++i2) {
switch (list[i2].type) {
case "space":
case "comment":
case "newline":
break;
default:
return i2;
}
}
return -1;
}
function isFlowToken(token) {
switch (token == null ? void 0 : token.type) {
case "alias":
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar":
case "flow-collection":
return true;
default:
return false;
}
}
function getPrevProps(parent) {
switch (parent.type) {
case "document":
return parent.start;
case "block-map": {
const it = parent.items[parent.items.length - 1];
return it.sep ?? it.start;
}
case "block-seq":
return parent.items[parent.items.length - 1].start;
default:
return [];
}
}
function getFirstKeyStartProps(prev) {
var _a2;
if (prev.length === 0)
return [];
let i2 = prev.length;
loop: while (--i2 >= 0) {
switch (prev[i2].type) {
case "doc-start":
case "explicit-key-ind":
case "map-value-ind":
case "seq-item-ind":
case "newline":
break loop;
}
}
while (((_a2 = prev[++i2]) == null ? void 0 : _a2.type) === "space") {
}
return prev.splice(i2, prev.length);
}
function fixFlowSeqItems(fc) {
if (fc.start.type === "flow-seq-start") {
for (const it of fc.items) {
if (it.sep && !it.value && !includesToken(it.start, "explicit-key-ind") && !includesToken(it.sep, "map-value-ind")) {
if (it.key)
it.value = it.key;
delete it.key;
if (isFlowToken(it.value)) {
if (it.value.end)
Array.prototype.push.apply(it.value.end, it.sep);
else
it.value.end = it.sep;
} else
Array.prototype.push.apply(it.start, it.sep);
delete it.sep;
}
}
}
}
let Parser$2 = class Parser {
/**
* @param onNewLine - If defined, called separately with the start position of
* each new line (in `parse()`, including the start of input).
*/
constructor(onNewLine) {
this.atNewLine = true;
this.atScalar = false;
this.indent = 0;
this.offset = 0;
this.onKeyLine = false;
this.stack = [];
this.source = "";
this.type = "";
this.lexer = new Lexer();
this.onNewLine = onNewLine;
}
/**
* Parse `source` as a YAML stream.
* If `incomplete`, a part of the last line may be left as a buffer for the next call.
*
* Errors are not thrown, but yielded as `{ type: 'error', message }` tokens.
*
* @returns A generator of tokens representing each directive, document, and other structure.
*/
*parse(source2, incomplete = false) {
if (this.onNewLine && this.offset === 0)
this.onNewLine(0);
for (const lexeme of this.lexer.lex(source2, incomplete))
yield* this.next(lexeme);
if (!incomplete)
yield* this.end();
}
/**
* Advance the parser by the `source` of one lexical token.
*/
*next(source2) {
this.source = source2;
if (this.atScalar) {
this.atScalar = false;
yield* this.step();
this.offset += source2.length;
return;
}
const type2 = tokenType(source2);
if (!type2) {
const message = `Not a YAML token: ${source2}`;
yield* this.pop({ type: "error", offset: this.offset, message, source: source2 });
this.offset += source2.length;
} else if (type2 === "scalar") {
this.atNewLine = false;
this.atScalar = true;
this.type = "scalar";
} else {
this.type = type2;
yield* this.step();
switch (type2) {
case "newline":
this.atNewLine = true;
this.indent = 0;
if (this.onNewLine)
this.onNewLine(this.offset + source2.length);
break;
case "space":
if (this.atNewLine && source2[0] === " ")
this.indent += source2.length;
break;
case "explicit-key-ind":
case "map-value-ind":
case "seq-item-ind":
if (this.atNewLine)
this.indent += source2.length;
break;
case "doc-mode":
case "flow-error-end":
return;
default:
this.atNewLine = false;
}
this.offset += source2.length;
}
}
/** Call at end of input to push out any remaining constructions */
*end() {
while (this.stack.length > 0)
yield* this.pop();
}
get sourceToken() {
const st = {
type: this.type,
offset: this.offset,
indent: this.indent,
source: this.source
};
return st;
}
*step() {
const top2 = this.peek(1);
if (this.type === "doc-end" && (!top2 || top2.type !== "doc-end")) {
while (this.stack.length > 0)
yield* this.pop();
this.stack.push({
type: "doc-end",
offset: this.offset,
source: this.source
});
return;
}
if (!top2)
return yield* this.stream();
switch (top2.type) {
case "document":
return yield* this.document(top2);
case "alias":
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar":
return yield* this.scalar(top2);
case "block-scalar":
return yield* this.blockScalar(top2);
case "block-map":
return yield* this.blockMap(top2);
case "block-seq":
return yield* this.blockSequence(top2);
case "flow-collection":
return yield* this.flowCollection(top2);
case "doc-end":
return yield* this.documentEnd(top2);
}
yield* this.pop();
}
peek(n2) {
return this.stack[this.stack.length - n2];
}
*pop(error2) {
const token = error2 ?? this.stack.pop();
if (!token) {
const message = "Tried to pop an empty stack";
yield { type: "error", offset: this.offset, source: "", message };
} else if (this.stack.length === 0) {
yield token;
} else {
const top2 = this.peek(1);
if (token.type === "block-scalar") {
token.indent = "indent" in top2 ? top2.indent : 0;
} else if (token.type === "flow-collection" && top2.type === "document") {
token.indent = 0;
}
if (token.type === "flow-collection")
fixFlowSeqItems(token);
switch (top2.type) {
case "document":
top2.value = token;
break;
case "block-scalar":
top2.props.push(token);
break;
case "block-map": {
const it = top2.items[top2.items.length - 1];
if (it.value) {
top2.items.push({ start: [], key: token, sep: [] });
this.onKeyLine = true;
return;
} else if (it.sep) {
it.value = token;
} else {
Object.assign(it, { key: token, sep: [] });
this.onKeyLine = !it.explicitKey;
return;
}
break;
}
case "block-seq": {
const it = top2.items[top2.items.length - 1];
if (it.value)
top2.items.push({ start: [], value: token });
else
it.value = token;
break;
}
case "flow-collection": {
const it = top2.items[top2.items.length - 1];
if (!it || it.value)
top2.items.push({ start: [], key: token, sep: [] });
else if (it.sep)
it.value = token;
else
Object.assign(it, { key: token, sep: [] });
return;
}
default:
yield* this.pop();
yield* this.pop(token);
}
if ((top2.type === "document" || top2.type === "block-map" || top2.type === "block-seq") && (token.type === "block-map" || token.type === "block-seq")) {
const last = token.items[token.items.length - 1];
if (last && !last.sep && !last.value && last.start.length > 0 && findNonEmptyIndex(last.start) === -1 && (token.indent === 0 || last.start.every((st) => st.type !== "comment" || st.indent < token.indent))) {
if (top2.type === "document")
top2.end = last.start;
else
top2.items.push({ start: last.start });
token.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": {
const doc2 = {
type: "document",
offset: this.offset,
start: []
};
if (this.type === "doc-start")
doc2.start.push(this.sourceToken);
this.stack.push(doc2);
return;
}
}
yield {
type: "error",
offset: this.offset,
message: `Unexpected ${this.type} token in YAML stream`,
source: this.source
};
}
*document(doc2) {
if (doc2.value)
return yield* this.lineEnd(doc2);
switch (this.type) {
case "doc-start": {
if (findNonEmptyIndex(doc2.start) !== -1) {
yield* this.pop();
yield* this.step();
} else
doc2.start.push(this.sourceToken);
return;
}
case "anchor":
case "tag":
case "space":
case "comment":
case "newline":
doc2.start.push(this.sourceToken);
return;
}
const bv = this.startBlockValue(doc2);
if (bv)
this.stack.push(bv);
else {
yield {
type: "error",
offset: this.offset,
message: `Unexpected ${this.type} token in YAML document`,
source: this.source
};
}
}
*scalar(scalar) {
if (this.type === "map-value-ind") {
const prev = getPrevProps(this.peek(2));
const start = getFirstKeyStartProps(prev);
let sep;
if (scalar.end) {
sep = scalar.end;
sep.push(this.sourceToken);
delete scalar.end;
} else
sep = [this.sourceToken];
const map2 = {
type: "block-map",
offset: scalar.offset,
indent: scalar.indent,
items: [{ start, key: scalar, sep }]
};
this.onKeyLine = true;
this.stack[this.stack.length - 1] = map2;
} else
yield* this.lineEnd(scalar);
}
*blockScalar(scalar) {
switch (this.type) {
case "space":
case "comment":
case "newline":
scalar.props.push(this.sourceToken);
return;
case "scalar":
scalar.source = this.source;
this.atNewLine = true;
this.indent = 0;
if (this.onNewLine) {
let nl = this.source.indexOf("\n") + 1;
while (nl !== 0) {
this.onNewLine(this.offset + nl);
nl = this.source.indexOf("\n", nl) + 1;
}
}
yield* this.pop();
break;
default:
yield* this.pop();
yield* this.step();
}
}
*blockMap(map2) {
var _a2;
const it = map2.items[map2.items.length - 1];
switch (this.type) {
case "newline":
this.onKeyLine = false;
if (it.value) {
const end = "end" in it.value ? it.value.end : void 0;
const last = Array.isArray(end) ? end[end.length - 1] : void 0;
if ((last == null ? void 0 : last.type) === "comment")
end == null ? void 0 : end.push(this.sourceToken);
else
map2.items.push({ start: [this.sourceToken] });
} else if (it.sep) {
it.sep.push(this.sourceToken);
} else {
it.start.push(this.sourceToken);
}
return;
case "space":
case "comment":
if (it.value) {
map2.items.push({ start: [this.sourceToken] });
} else if (it.sep) {
it.sep.push(this.sourceToken);
} else {
if (this.atIndentedComment(it.start, map2.indent)) {
const prev = map2.items[map2.items.length - 2];
const end = (_a2 = prev == null ? void 0 : prev.value) == null ? void 0 : _a2.end;
if (Array.isArray(end)) {
Array.prototype.push.apply(end, it.start);
end.push(this.sourceToken);
map2.items.pop();
return;
}
}
it.start.push(this.sourceToken);
}
return;
}
if (this.indent >= map2.indent) {
const atMapIndent = !this.onKeyLine && this.indent === map2.indent;
const atNextItem = atMapIndent && (it.sep || it.explicitKey) && this.type !== "seq-item-ind";
let start = [];
if (atNextItem && it.sep && !it.value) {
const nl = [];
for (let i2 = 0; i2 < it.sep.length; ++i2) {
const st = it.sep[i2];
switch (st.type) {
case "newline":
nl.push(i2);
break;
case "space":
break;
case "comment":
if (st.indent > map2.indent)
nl.length = 0;
break;
default:
nl.length = 0;
}
}
if (nl.length >= 2)
start = it.sep.splice(nl[1]);
}
switch (this.type) {
case "anchor":
case "tag":
if (atNextItem || it.value) {
start.push(this.sourceToken);
map2.items.push({ start });
this.onKeyLine = true;
} else if (it.sep) {
it.sep.push(this.sourceToken);
} else {
it.start.push(this.sourceToken);
}
return;
case "explicit-key-ind":
if (!it.sep && !it.explicitKey) {
it.start.push(this.sourceToken);
it.explicitKey = true;
} else if (atNextItem || it.value) {
start.push(this.sourceToken);
map2.items.push({ start, explicitKey: true });
} else {
this.stack.push({
type: "block-map",
offset: this.offset,
indent: this.indent,
items: [{ start: [this.sourceToken], explicitKey: true }]
});
}
this.onKeyLine = true;
return;
case "map-value-ind":
if (it.explicitKey) {
if (!it.sep) {
if (includesToken(it.start, "newline")) {
Object.assign(it, { key: null, sep: [this.sourceToken] });
} else {
const start2 = getFirstKeyStartProps(it.start);
this.stack.push({
type: "block-map",
offset: this.offset,
indent: this.indent,
items: [{ start: start2, key: null, sep: [this.sourceToken] }]
});
}
} else if (it.value) {
map2.items.push({ start: [], key: null, sep: [this.sourceToken] });
} else if (includesToken(it.sep, "map-value-ind")) {
this.stack.push({
type: "block-map",
offset: this.offset,
indent: this.indent,
items: [{ start, key: null, sep: [this.sourceToken] }]
});
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
const start2 = getFirstKeyStartProps(it.start);
const key2 = it.key;
const sep = it.sep;
sep.push(this.sourceToken);
delete it.key, delete it.sep;
this.stack.push({
type: "block-map",
offset: this.offset,
indent: this.indent,
items: [{ start: start2, key: key2, sep }]
});
} else if (start.length > 0) {
it.sep = it.sep.concat(start, this.sourceToken);
} else {
it.sep.push(this.sourceToken);
}
} else {
if (!it.sep) {
Object.assign(it, { key: null, sep: [this.sourceToken] });
} else if (it.value || atNextItem) {
map2.items.push({ start, key: null, sep: [this.sourceToken] });
} else if (includesToken(it.sep, "map-value-ind")) {
this.stack.push({
type: "block-map",
offset: this.offset,
indent: this.indent,
items: [{ start: [], key: null, sep: [this.sourceToken] }]
});
} else {
it.sep.push(this.sourceToken);
}
}
this.onKeyLine = true;
return;
case "alias":
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar": {
const fs = this.flowScalar(this.type);
if (atNextItem || it.value) {
map2.items.push({ start, key: fs, sep: [] });
this.onKeyLine = true;
} else if (it.sep) {
this.stack.push(fs);
} else {
Object.assign(it, { key: fs, sep: [] });
this.onKeyLine = true;
}
return;
}
default: {
const bv = this.startBlockValue(map2);
if (bv) {
if (atMapIndent && bv.type !== "block-seq") {
map2.items.push({ start });
}
this.stack.push(bv);
return;
}
}
}
}
yield* this.pop();
yield* this.step();
}
*blockSequence(seq2) {
var _a2;
const it = seq2.items[seq2.items.length - 1];
switch (this.type) {
case "newline":
if (it.value) {
const end = "end" in it.value ? it.value.end : void 0;
const last = Array.isArray(end) ? end[end.length - 1] : void 0;
if ((last == null ? void 0 : last.type) === "comment")
end == null ? void 0 : end.push(this.sourceToken);
else
seq2.items.push({ start: [this.sourceToken] });
} else
it.start.push(this.sourceToken);
return;
case "space":
case "comment":
if (it.value)
seq2.items.push({ start: [this.sourceToken] });
else {
if (this.atIndentedComment(it.start, seq2.indent)) {
const prev = seq2.items[seq2.items.length - 2];
const end = (_a2 = prev == null ? void 0 : prev.value) == null ? void 0 : _a2.end;
if (Array.isArray(end)) {
Array.prototype.push.apply(end, it.start);
end.push(this.sourceToken);
seq2.items.pop();
return;
}
}
it.start.push(this.sourceToken);
}
return;
case "anchor":
case "tag":
if (it.value || this.indent <= seq2.indent)
break;
it.start.push(this.sourceToken);
return;
case "seq-item-ind":
if (this.indent !== seq2.indent)
break;
if (it.value || includesToken(it.start, "seq-item-ind"))
seq2.items.push({ start: [this.sourceToken] });
else
it.start.push(this.sourceToken);
return;
}
if (this.indent > seq2.indent) {
const bv = this.startBlockValue(seq2);
if (bv) {
this.stack.push(bv);
return;
}
}
yield* this.pop();
yield* this.step();
}
*flowCollection(fc) {
const it = fc.items[fc.items.length - 1];
if (this.type === "flow-error-end") {
let top2;
do {
yield* this.pop();
top2 = this.peek(1);
} while (top2 && top2.type === "flow-collection");
} else if (fc.end.length === 0) {
switch (this.type) {
case "comma":
case "explicit-key-ind":
if (!it || it.sep)
fc.items.push({ start: [this.sourceToken] });
else
it.start.push(this.sourceToken);
return;
case "map-value-ind":
if (!it || it.value)
fc.items.push({ start: [], key: null, sep: [this.sourceToken] });
else if (it.sep)
it.sep.push(this.sourceToken);
else
Object.assign(it, { key: null, sep: [this.sourceToken] });
return;
case "space":
case "comment":
case "newline":
case "anchor":
case "tag":
if (!it || it.value)
fc.items.push({ start: [this.sourceToken] });
else if (it.sep)
it.sep.push(this.sourceToken);
else
it.start.push(this.sourceToken);
return;
case "alias":
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar": {
const fs = this.flowScalar(this.type);
if (!it || it.value)
fc.items.push({ start: [], key: fs, sep: [] });
else if (it.sep)
this.stack.push(fs);
else
Object.assign(it, { key: fs, sep: [] });
return;
}
case "flow-map-end":
case "flow-seq-end":
fc.end.push(this.sourceToken);
return;
}
const bv = this.startBlockValue(fc);
if (bv)
this.stack.push(bv);
else {
yield* this.pop();
yield* this.step();
}
} else {
const parent = this.peek(2);
if (parent.type === "block-map" && (this.type === "map-value-ind" && parent.indent === fc.indent || this.type === "newline" && !parent.items[parent.items.length - 1].sep)) {
yield* this.pop();
yield* this.step();
} else if (this.type === "map-value-ind" && parent.type !== "flow-collection") {
const prev = getPrevProps(parent);
const start = getFirstKeyStartProps(prev);
fixFlowSeqItems(fc);
const sep = fc.end.splice(1, fc.end.length);
sep.push(this.sourceToken);
const map2 = {
type: "block-map",
offset: fc.offset,
indent: fc.indent,
items: [{ start, key: fc, sep }]
};
this.onKeyLine = true;
this.stack[this.stack.length - 1] = map2;
} else {
yield* this.lineEnd(fc);
}
}
}
flowScalar(type2) {
if (this.onNewLine) {
let nl = this.source.indexOf("\n") + 1;
while (nl !== 0) {
this.onNewLine(this.offset + nl);
nl = this.source.indexOf("\n", nl) + 1;
}
}
return {
type: type2,
offset: this.offset,
indent: this.indent,
source: this.source
};
}
startBlockValue(parent) {
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 = true;
const prev = getPrevProps(parent);
const start = getFirstKeyStartProps(prev);
start.push(this.sourceToken);
return {
type: "block-map",
offset: this.offset,
indent: this.indent,
items: [{ start, explicitKey: true }]
};
}
case "map-value-ind": {
this.onKeyLine = true;
const prev = getPrevProps(parent);
const start = getFirstKeyStartProps(prev);
return {
type: "block-map",
offset: this.offset,
indent: this.indent,
items: [{ start, key: null, sep: [this.sourceToken] }]
};
}
}
return null;
}
atIndentedComment(start, indent) {
if (this.type !== "comment")
return false;
if (this.indent <= indent)
return false;
return start.every((st) => st.type === "newline" || st.type === "space");
}
*documentEnd(docEnd) {
if (this.type !== "doc-mode") {
if (docEnd.end)
docEnd.end.push(this.sourceToken);
else
docEnd.end = [this.sourceToken];
if (this.type === "newline")
yield* this.pop();
}
}
*lineEnd(token) {
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 = false;
case "space":
case "comment":
default:
if (token.end)
token.end.push(this.sourceToken);
else
token.end = [this.sourceToken];
if (this.type === "newline")
yield* this.pop();
}
}
};
function parseOptions(options) {
const prettyErrors = options.prettyErrors !== false;
const lineCounter = options.lineCounter || prettyErrors && new LineCounter() || null;
return { lineCounter, prettyErrors };
}
function parseDocument(source2, options = {}) {
const { lineCounter, prettyErrors } = parseOptions(options);
const parser2 = new Parser$2(lineCounter == null ? void 0 : lineCounter.addNewLine);
const composer = new Composer(options);
let doc2 = null;
for (const _doc of composer.compose(parser2.parse(source2), true, source2.length)) {
if (!doc2)
doc2 = _doc;
else if (doc2.options.logLevel !== "silent") {
doc2.errors.push(new YAMLParseError(_doc.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
break;
}
}
if (prettyErrors && lineCounter) {
doc2.errors.forEach(prettifyError(source2, lineCounter));
doc2.warnings.forEach(prettifyError(source2, lineCounter));
}
return doc2;
}
function parse$8(src, reviver, options) {
let _reviver = void 0;
if (typeof reviver === "function") {
_reviver = reviver;
} else if (options === void 0 && reviver && typeof reviver === "object") {
options = reviver;
}
const doc2 = parseDocument(src, options);
if (!doc2)
return null;
doc2.warnings.forEach((warning) => warn$1(doc2.options.logLevel, warning));
if (doc2.errors.length > 0) {
if (doc2.options.logLevel !== "silent")
throw doc2.errors[0];
else
doc2.errors = [];
}
return doc2.toJS(Object.assign({ reviver: _reviver }, options));
}
const json$2 = {
/** Parse and throw if the return value is not an object */
parse: (val) => {
const jsonObject = JSON.parse(val);
if (typeof jsonObject !== "object")
throw Error("Invalid JSON object");
return jsonObject;
},
/** Parse and return a fallback on failure */
parseSafe(val, fallback) {
try {
return json$2.parse(val);
} catch (err) {
return typeof fallback === "function" ? fallback(err) : fallback;
}
},
stringify: (val) => JSON.stringify(val)
};
const isJsonString = (value) => {
if (typeof value !== "string")
return false;
return !!json$2.parseSafe(value, false);
};
function formatJsonOrYamlString(value) {
const trimmed = value.trim();
if (trimmed[0] !== "{" && trimmed[0] !== "[")
return value;
try {
return JSON.stringify(JSON.parse(value), null, 2);
} catch {
return value;
}
}
const prettyPrintJson = (value) => {
if (typeof value === "string") {
if (isJsonString(value)) {
return JSON.stringify(JSON.parse(value), null, 2);
}
return value;
}
if (typeof value === "object") {
try {
return JSON.stringify(value, null, 2);
} catch {
return replaceCircularDependencies(value);
}
}
return (value == null ? void 0 : value.toString()) ?? "";
};
function replaceCircularDependencies(content2) {
const cache2 = /* @__PURE__ */ new Set();
return JSON.stringify(content2, (key2, value) => {
if (typeof value === "object" && value !== null) {
if (cache2.has(value)) {
return "[Circular]";
}
cache2.add(value);
}
return value;
}, 2);
}
const MAX_LEVELS_DEEP = 5;
const genericExampleValues = {
// 'date-time': '1970-01-01T00:00:00Z',
"date-time": (/* @__PURE__ */ new Date()).toISOString(),
// 'date': '1970-01-01',
"date": (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
"email": "[email protected]",
"hostname": "example.com",
// https://tools.ietf.org/html/rfc6531#section-3.3
"idn-email": "[email protected]",
// https://tools.ietf.org/html/rfc5890#section-2.3.2.3
"idn-hostname": "example.com",
"ipv4": "127.0.0.1",
"ipv6": "51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998",
"iri-reference": "/entitiy/1",
// https://tools.ietf.org/html/rfc3987
"iri": "https://example.com/entity/123",
"json-pointer": "/nested/objects",
"password": "super-secret",
"regex": "/[a-z]/",
// https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01
"relative-json-pointer": "1/nested/objects",
// full-time in https://tools.ietf.org/html/rfc3339#section-5.6
// 'time': '00:00:00Z',
"time": (/* @__PURE__ */ new Date()).toISOString().split("T")[1].split(".")[0],
// either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1
"uri-reference": "../folder",
"uri-template": "https://example.com/{id}",
"uri": "https://example.com",
"uuid": "123e4567-e89b-12d3-a456-426614174000"
};
function guessFromFormat(schema2, fallback = "") {
return genericExampleValues[schema2.format] ?? fallback;
}
const resultCache = /* @__PURE__ */ new WeakMap();
function cache$1(schema2, result) {
if (typeof result !== "object" || result === null) {
return result;
}
resultCache.set(schema2, result);
return result;
}
const getExampleFromSchema = (schema2, options, level = 0, parentSchema, name2) => {
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
if (resultCache.has(schema2)) {
return resultCache.get(schema2);
}
if (level === MAX_LEVELS_DEEP + 1) {
try {
JSON.stringify(schema2);
} catch {
return "[Circular Reference]";
}
}
const makeUpRandomData = !!(options == null ? void 0 : options.emptyString);
if ((options == null ? void 0 : options.mode) === "write" && schema2.readOnly || (options == null ? void 0 : options.mode) === "read" && schema2.writeOnly) {
return void 0;
}
if (schema2["x-variable"]) {
const value = (_a2 = options == null ? void 0 : options.variables) == null ? void 0 : _a2[schema2["x-variable"]];
if (value !== void 0) {
if (schema2.type === "number" || schema2.type === "integer") {
return parseInt(value, 10);
}
return cache$1(schema2, value);
}
}
if (Array.isArray(schema2.examples) && schema2.examples.length > 0) {
return cache$1(schema2, schema2.examples[0]);
}
if (schema2.example !== void 0) {
return cache$1(schema2, schema2.example);
}
if (schema2.default !== void 0) {
return cache$1(schema2, schema2.default);
}
if (Array.isArray(schema2.enum) && schema2.enum.length > 0) {
return cache$1(schema2, schema2.enum[0]);
}
const isObjectOrArray = schema2.type === "object" || schema2.type === "array" || !!((_c = (_b = schema2.allOf) == null ? void 0 : _b.at) == null ? void 0 : _c.call(_b, 0)) || !!((_e = (_d = schema2.anyOf) == null ? void 0 : _d.at) == null ? void 0 : _e.call(_d, 0)) || !!((_g = (_f = schema2.oneOf) == null ? void 0 : _f.at) == null ? void 0 : _g.call(_f, 0));
if (!isObjectOrArray && (options == null ? void 0 : options.omitEmptyAndOptionalProperties) === true) {
const isRequired = schema2.required === true || (parentSchema == null ? void 0 : parentSchema.required) === true || ((_h = parentSchema == null ? void 0 : parentSchema.required) == null ? void 0 : _h.includes(name2 ?? schema2.name));
if (!isRequired) {
return void 0;
}
}
if (schema2.type === "object" || schema2.properties !== void 0) {
const response = {};
if (schema2.properties !== void 0) {
for (const propertyName2 in schema2.properties) {
if (Object.prototype.hasOwnProperty.call(schema2.properties, propertyName2)) {
const property = schema2.properties[propertyName2];
const propertyXmlTagName = (options == null ? void 0 : options.xml) ? (_i = property.xml) == null ? void 0 : _i.name : void 0;
response[propertyXmlTagName ?? propertyName2] = getExampleFromSchema(property, options, level + 1, schema2, propertyName2);
if (typeof response[propertyXmlTagName ?? propertyName2] === "undefined") {
delete response[propertyXmlTagName ?? propertyName2];
}
}
}
}
if (schema2.additionalProperties !== void 0) {
const anyTypeIsValid = (
// true
schema2.additionalProperties === true || // or an empty object {}
typeof schema2.additionalProperties === "object" && !Object.keys(schema2.additionalProperties).length
);
if (anyTypeIsValid) {
response["ANY_ADDITIONAL_PROPERTY"] = "anything";
} else if (schema2.additionalProperties !== false) {
response["ANY_ADDITIONAL_PROPERTY"] = getExampleFromSchema(schema2.additionalProperties, options, level + 1);
}
}
if (schema2.anyOf !== void 0) {
Object.assign(response, getExampleFromSchema(schema2.anyOf[0], options, level + 1));
} else if (schema2.oneOf !== void 0) {
Object.assign(response, getExampleFromSchema(schema2.oneOf[0], options, level + 1));
} else if (schema2.allOf !== void 0) {
Object.assign(response, ...schema2.allOf.map((item) => getExampleFromSchema(item, options, level + 1, schema2)).filter((item) => item !== void 0));
}
return cache$1(schema2, response);
}
if (schema2.type === "array" || schema2.items !== void 0) {
const itemsXmlTagName = (_k = (_j = schema2 == null ? void 0 : schema2.items) == null ? void 0 : _j.xml) == null ? void 0 : _k.name;
const wrapItems = !!((options == null ? void 0 : options.xml) && ((_l = schema2.xml) == null ? void 0 : _l.wrapped) && itemsXmlTagName);
if (schema2.example !== void 0) {
return cache$1(schema2, wrapItems ? { [itemsXmlTagName]: schema2.example } : schema2.example);
}
if (schema2.items) {
const rules = ["anyOf", "oneOf", "allOf"];
for (const rule of rules) {
if (!schema2.items[rule]) {
continue;
}
const schemas2 = ["anyOf", "oneOf"].includes(rule) ? (
// Use the first item only
schema2.items[rule].slice(0, 1)
) : (
// Use all items
schema2.items[rule]
);
const exampleFromRule = schemas2.map((item) => getExampleFromSchema(item, options, level + 1, schema2)).filter((item) => item !== void 0);
return cache$1(schema2, wrapItems ? [{ [itemsXmlTagName]: exampleFromRule }] : exampleFromRule);
}
}
if ((_m = schema2.items) == null ? void 0 : _m.type) {
const exampleFromSchema = getExampleFromSchema(schema2.items, options, level + 1);
return wrapItems ? [{ [itemsXmlTagName]: exampleFromSchema }] : [exampleFromSchema];
}
return [];
}
const exampleValues = {
string: makeUpRandomData ? guessFromFormat(schema2, options == null ? void 0 : options.emptyString) : "",
boolean: true,
integer: schema2.min ?? 1,
number: schema2.min ?? 1,
array: []
};
if (schema2.type !== void 0 && exampleValues[schema2.type] !== void 0) {
return cache$1(schema2, exampleValues[schema2.type]);
}
const discriminateSchema = schema2.oneOf || schema2.anyOf;
if (Array.isArray(discriminateSchema) && discriminateSchema.length > 0) {
const firstOneOfItem = discriminateSchema[0];
return getExampleFromSchema(firstOneOfItem, options, level + 1);
}
if (Array.isArray(schema2.allOf)) {
let example = null;
schema2.allOf.forEach((allOfItem) => {
const newExample = getExampleFromSchema(allOfItem, options, level + 1);
example = typeof newExample === "object" && typeof example === "object" ? {
...example ?? {},
...newExample
} : Array.isArray(newExample) && Array.isArray(example) ? [...example ?? {}, ...newExample] : newExample;
});
return cache$1(schema2, example);
}
if (Array.isArray(schema2.type)) {
if (schema2.type.includes("null")) {
return null;
}
const exampleValue = exampleValues[schema2.type[0]];
if (exampleValue !== void 0) {
return cache$1(schema2, exampleValue);
}
}
return null;
};
function getParametersFromOperation(operation, where, requiredOnly = true) {
var _a2;
const parameters = [
...operation.pathParameters || [],
...((_a2 = operation.information) == null ? void 0 : _a2.parameters) || []
];
const params = parameters.filter((parameter) => parameter.in === where).filter((parameter) => requiredOnly && parameter.required || !requiredOnly).map((parameter) => ({
name: parameter.name,
description: parameter.description ?? null,
value: parameter.example ? parameter.example : parameter.schema ? getExampleFromSchema(parameter.schema, { mode: "write" }) : "",
required: parameter.required ?? false,
enabled: parameter.required ?? false
}));
return params.sort((a2, b2) => {
if (a2.required && !b2.required)
return -1;
if (!a2.required && b2.required)
return 1;
return 0;
});
}
function getParamsFromObject(obj, prefix = "") {
return Object.entries(obj).flatMap(([key2, value]) => {
const newKey = prefix ? `${prefix}[${key2}]` : key2;
if (typeof value === "object" && value !== null) {
return getParamsFromObject(value, newKey);
}
return [{ name: newKey, value }];
});
}
const mimeTypes = [
"application/json",
"application/octet-stream",
"application/x-www-form-urlencoded",
"application/xml",
"multipart/form-data",
"text/plain"
];
function getRequestBodyFromOperation(operation, selectedExampleKey) {
var _a2, _b, _c, _d;
const originalContent = (_b = (_a2 = operation.information) == null ? void 0 : _a2.requestBody) == null ? void 0 : _b.content;
const content2 = normalizeMimeTypeObject(originalContent);
const mimeType2 = mimeTypes.find((currentMimeType) => !!(content2 == null ? void 0 : content2[currentMimeType]));
const examples = (_c = content2 == null ? void 0 : content2["application/json"]) == null ? void 0 : _c.examples;
const selectedExample = (_d = examples ?? {}) == null ? void 0 : _d[Object.keys(examples ?? {})[0]];
if (selectedExample) {
return {
body: {
mimeType: "application/json",
text: prettyPrintJson(selectedExample == null ? void 0 : selectedExample.value)
}
};
}
const bodyParameters = getParametersFromOperation(operation, "body", false);
if (bodyParameters.length > 0) {
return {
body: {
mimeType: "application/json",
text: prettyPrintJson(bodyParameters[0].value)
}
};
}
const formDataParameters = getParametersFromOperation(operation, "formData", false);
if (formDataParameters.length > 0) {
return {
body: {
mimeType: "application/x-www-form-urlencoded",
params: formDataParameters.map((parameter) => ({
name: parameter.name,
/**
* TODO: This value MUST be a string
* Figure out why this is not always a string
*
* JSON.stringify is a TEMPORARY fix
*/
value: typeof parameter.value === "string" ? parameter.value : JSON.stringify(parameter.value)
}))
}
};
}
if (!mimeType2) {
return null;
}
const requestBodyObject = content2 == null ? void 0 : content2[mimeType2];
const headers = [
{
name: "Content-Type",
value: mimeType2
}
];
const example = (requestBodyObject == null ? void 0 : requestBodyObject.example) ? requestBodyObject == null ? void 0 : requestBodyObject.example : void 0;
if (mimeType2 === "application/json") {
const exampleFromSchema = (requestBodyObject == null ? void 0 : requestBodyObject.schema) ? getExampleFromSchema(requestBodyObject == null ? void 0 : requestBodyObject.schema, {
mode: "write",
omitEmptyAndOptionalProperties: true
}) : null;
const body2 = example ?? exampleFromSchema;
return {
headers,
body: {
mimeType: mimeType2,
text: typeof body2 === "string" ? body2 : JSON.stringify(body2, null, 2)
}
};
}
if (mimeType2 === "application/xml") {
const exampleFromSchema = (requestBodyObject == null ? void 0 : requestBodyObject.schema) ? getExampleFromSchema(requestBodyObject == null ? void 0 : requestBodyObject.schema, {
xml: true,
mode: "write",
omitEmptyAndOptionalProperties: true
}) : null;
return {
headers,
body: {
mimeType: mimeType2,
text: example ?? json2xml(exampleFromSchema, " ")
}
};
}
if (mimeType2 === "application/octet-stream") {
return {
headers,
body: {
mimeType: mimeType2,
text: "BINARY"
}
};
}
if (mimeType2 === "text/plain") {
const exampleFromSchema = (requestBodyObject == null ? void 0 : requestBodyObject.schema) ? getExampleFromSchema(requestBodyObject == null ? void 0 : requestBodyObject.schema, {
xml: true,
mode: "write",
omitEmptyAndOptionalProperties: true
}) : null;
return {
headers,
body: {
mimeType: mimeType2,
text: example ?? exampleFromSchema ?? ""
}
};
}
if (mimeType2 === "multipart/form-data" || mimeType2 === "application/x-www-form-urlencoded") {
const exampleFromSchema = (requestBodyObject == null ? void 0 : requestBodyObject.schema) ? getExampleFromSchema(requestBodyObject == null ? void 0 : requestBodyObject.schema, {
xml: true,
mode: "write",
omitEmptyAndOptionalProperties: true
}) : null;
return {
headers,
body: {
mimeType: mimeType2,
params: getParamsFromObject(example ?? exampleFromSchema ?? {})
}
};
}
return null;
}
const requestExampleParametersSchema = z$8.object({
key: z$8.string().default(""),
value: z$8.coerce.string().default(""),
enabled: z$8.boolean().default(true),
file: z$8.any().optional(),
description: z$8.string().optional(),
/** Params are linked to parents such as path params and global headers/cookies */
refUid: nanoidSchema.optional(),
required: z$8.boolean().optional(),
enum: z$8.array(z$8.string()).optional(),
type: z$8.string().optional(),
format: z$8.string().optional(),
minimum: z$8.number().optional(),
maximum: z$8.number().optional(),
default: z$8.any().optional(),
nullable: z$8.boolean().optional()
});
const exampleRequestBodyEncoding = [
"json",
"text",
"html",
"javascript",
"xml",
"yaml",
"edn"
];
const exampleRequestBodySchema = z$8.object({
raw: z$8.object({
encoding: z$8.enum(exampleRequestBodyEncoding).default("json"),
value: z$8.string().default("")
}).optional(),
formData: z$8.object({
encoding: z$8.union([z$8.literal("form-data"), z$8.literal("urlencoded")]).default("form-data"),
value: requestExampleParametersSchema.array().default([])
}).optional(),
binary: z$8.instanceof(Blob).optional(),
activeBody: z$8.union([z$8.literal("raw"), z$8.literal("formData"), z$8.literal("binary")]).default("raw")
});
const requestExampleSchema = z$8.object({
type: z$8.literal("requestExample").optional().default("requestExample"),
uid: nanoidSchema,
requestUid: nanoidSchema,
name: z$8.string().optional().default("Name"),
body: exampleRequestBodySchema.optional().default({}),
parameters: z$8.object({
path: requestExampleParametersSchema.array().default([]),
query: requestExampleParametersSchema.array().default([]),
headers: requestExampleParametersSchema.array().default([]),
cookies: requestExampleParametersSchema.array().default([])
}).optional().default({}),
serverVariables: z$8.record(z$8.string(), z$8.array(z$8.string())).optional()
});
function createParamInstance(param) {
var _a2;
const schema2 = param.schema;
const value = String((schema2 == null ? void 0 : schema2.default) ?? ((_a2 = schema2 == null ? void 0 : schema2.examples) == null ? void 0 : _a2[0]) ?? "");
const example = schemaModel({
...schema2,
key: param.name,
value,
description: param.description,
required: param.required,
/** Initialized all required properties to enabled */
enabled: !!param.required
}, requestExampleParametersSchema, false);
if (!example) {
console.warn(`Example at ${param.name} is invalid.`);
return requestExampleParametersSchema.parse({});
} else
return example;
}
function createExampleFromRequest(request, name2, server) {
var _a2, _b, _c, _d, _e;
const parameters = {
path: [],
query: [],
cookie: [],
header: []
};
(_a2 = request.parameters) == null ? void 0 : _a2.forEach((p2) => parameters[p2.in].push(createParamInstance(p2)));
const body2 = {
activeBody: "raw",
raw: {
encoding: "json",
value: ""
}
};
if (request.requestBody) {
const requestBody = getRequestBodyFromOperation({
path: request.path,
information: {
requestBody: request.requestBody
}
});
if (((_b = requestBody == null ? void 0 : requestBody.body) == null ? void 0 : _b.mimeType) === "application/json") {
body2.activeBody = "raw";
body2.raw = {
encoding: "json",
value: requestBody.body.text ?? JSON.stringify({})
};
}
if (((_c = requestBody == null ? void 0 : requestBody.body) == null ? void 0 : _c.mimeType) === "application/xml") {
body2.activeBody = "raw";
body2.raw = {
encoding: "xml",
value: requestBody.body.text ?? ""
};
}
if (((_d = requestBody == null ? void 0 : requestBody.body) == null ? void 0 : _d.mimeType) === "application/octet-stream") {
body2.activeBody = "binary";
body2.binary = void 0;
}
if (((_e = requestBody == null ? void 0 : requestBody.body) == null ? void 0 : _e.mimeType) === "application/x-www-form-urlencoded") {
body2.activeBody = "formData";
body2.formData = void 0;
}
}
const serverVariables = {};
const example = schemaModel({
requestUid: request.uid,
parameters,
name: name2,
body: body2,
serverVariables
}, requestExampleSchema, false);
if (!example) {
console.warn(`Example at ${request.uid} is invalid.`);
return requestExampleSchema.parse({});
} else
return example;
}
const F$3 = [
"alternate",
"default",
"moon",
"purple",
"solarized",
"bluePlanet",
"deepSpace",
"saturn",
"kepler",
"mars",
"none"
], M$4 = {
default: "Default",
alternate: "Alternate",
moon: "Moon",
purple: "Purple",
solarized: "Solarized",
bluePlanet: "Blue Planet",
saturn: "Saturn",
kepler: "Kepler-11e",
mars: "Mars",
deepSpace: "Deep Space",
none: ""
};
const HOTKEY_EVENT_NAMES = [
"closeModal",
"navigateSearchResultsDown",
"selectSearchResult",
"navigateSearchResultsUp",
"openCommandPalette",
"createNew",
"toggleSidebar",
"addTopNav",
"closeTopNav",
"navigateTopNavLeft",
"navigateTopNavRight",
"focusAddressBar",
"jumpToTab",
"jumpToLastTab",
"focusRequestSearch"
];
const KEYDOWN_KEYS = [
"Space",
"Backspace",
"Tab",
"Enter",
"Escape",
"ArrowDown",
"ArrowLeft",
"ArrowRight",
"ArrowUp",
"End",
"Home",
"PageDown",
"PageUp",
"Delete",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"*",
"+",
"-",
".",
"/",
"F1",
"F2",
"F3",
"F4",
"F5",
"F6",
"F7",
"F8",
"F9",
"F10",
"F11",
"F12",
";",
"=",
",",
"-",
".",
"/",
"`",
"[",
"\\",
"]",
""
];
const modifier = z$8.enum(["Meta", "Control", "Shift", "Alt", "default"]).optional().default("default");
const modifiers$1 = z$8.array(modifier).optional().default(["default"]);
const hotKeys = z$8.record(z$8.enum(KEYDOWN_KEYS), z$8.object({
modifiers: modifiers$1.optional(),
event: z$8.enum(HOTKEY_EVENT_NAMES)
}));
const hotKeyConfigSchema = z$8.object({
modifiers: modifiers$1,
hotKeys: hotKeys.optional()
}).optional();
const workspaceSchema = z$8.object({
uid: nanoidSchema,
name: z$8.string().default("Default Workspace"),
/** Workspace description */
description: z$8.string().default("Basic Scalar Workspace"),
/** Controls read only mode for most entitites, but not things like params */
isReadOnly: z$8.boolean().default(false),
/** List of all collection uids in a given workspace */
collections: z$8.array(z$8.string()).default([]),
/** List of all environment uids in a given workspace */
environments: z$8.array(z$8.string()).default([]),
/** Customize hotkeys */
hotKeyConfig: hotKeyConfigSchema,
/** Active Environment ID to use for requests */
activeEnvironmentId: z$8.string().optional().default("default"),
/** List of all cookie uids in a given workspace */
cookies: z$8.array(z$8.string()).default([]),
/** Workspace level proxy for all requests to be sent through */
proxyUrl: z$8.string().optional(),
/** Workspace level theme, we might move this to user level later */
themeId: z$8.enum(F$3).optional().default("default")
});
const createHash = (input) => {
let chr = 0;
let hash2 = 0;
let i2 = 0;
if (!(input == null ? void 0 : input.length))
return hash2;
for (i2 = 0; i2 < input.length; i2++) {
chr = input.charCodeAt(i2);
hash2 = (hash2 << 5) - hash2 + chr;
hash2 |= 0;
}
return hash2;
};
function redirectToProxy(proxy, url) {
if (!shouldUseProxy(proxy, url)) {
return url ?? "";
}
const newUrl = new URL(url);
newUrl.href = proxy;
newUrl.searchParams.append("scalar_url", url);
return newUrl.toString();
}
const isRelativePath = (url) => !/^https?:\/\//.test(url);
function shouldUseProxy(proxy, url) {
if (!proxy || !url)
return false;
if (isRelativePath(url))
return false;
if (isRequestToLocalhost(url))
return false;
return true;
}
function isRequestToLocalhost(url) {
const { hostname } = new URL(url);
const listOfLocalUrls = ["localhost", "127.0.0.1", "[::1]"];
return listOfLocalUrls.includes(hostname);
}
const OLD_PROXY_URL = "https://api.scalar.com/request-proxy";
const NEW_PROXY_URL = "https://proxy.scalar.com";
async function fetchSpecFromUrl(url, proxy, beautify = true) {
if (proxy === OLD_PROXY_URL) {
proxy = NEW_PROXY_URL;
}
const response = await fetch(proxy ? redirectToProxy(proxy, url) : url);
if (response.status !== 200) {
console.error(`[fetchSpecFromUrl] Failed to fetch the specification at ${url} (Status: ${response.status})`);
if (!proxy) {
console.warn(`[fetchSpecFromUrl] Tried to fetch the specification (url: ${url}) without a proxy. Are the CORS headers configured to allow cross-domain requests? https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS`);
}
throw new Error(`Failed to fetch the specification (Status: ${response.status})`);
}
if (beautify)
return formatJsonOrYamlString(await response.text());
else
return await response.text();
}
const REQUEST_METHODS = {
get: {
short: "GET",
color: "text-blue",
backgroundColor: "bg-blue"
},
post: {
short: "POST",
color: "text-green",
backgroundColor: "bg-green"
},
put: {
short: "PUT",
color: "text-orange",
backgroundColor: "bg-orange"
},
patch: {
short: "PATCH",
color: "text-yellow",
backgroundColor: "bg-yellow"
},
delete: {
short: "DEL",
color: "text-red",
backgroundColor: "bg-red"
},
options: {
short: "OPTS",
color: "text-purple",
backgroundColor: "bg-purple"
},
head: {
short: "HEAD",
color: "text-scalar-c-2",
backgroundColor: "bg-c-2"
},
connect: {
short: "CONN",
color: "text-c-2",
backgroundColor: "bg-c-2"
},
trace: {
short: "TRACE",
color: "text-c-2",
backgroundColor: "bg-c-2"
}
};
const BODY_METHODS = ["post", "put", "patch", "delete"];
const canMethodHaveBody = (method) => BODY_METHODS.includes(method);
const getHttpMethodInfo = (methodName) => {
const normalizedMethod = methodName.trim().toLowerCase();
return REQUEST_METHODS[normalizedMethod] ?? {
short: normalizedMethod,
color: "text-c-2",
backgroundColor: "bg-c-2"
};
};
const httpStatusCodes = {
100: {
name: "Continue",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100"
},
101: {
name: "Switching Protocols",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101"
},
102: {
name: "Processing",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/102"
},
103: {
name: "Early Hints",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103"
},
200: {
name: "OK",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200"
},
201: {
name: "Created",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201"
},
202: {
name: "Accepted",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202"
},
203: {
name: "Non-Authoritative Information",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/203"
},
204: {
name: "No Content",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204"
},
205: {
name: "Reset Content",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/205"
},
206: {
name: "Partial Content",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206"
},
207: {
name: "Multi-Status",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/207"
},
208: {
name: "Already Reported",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/208"
},
226: {
name: "IM Used",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/226"
},
300: {
name: "Multiple Choices",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300"
},
301: {
name: "Moved Permanently",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301"
},
302: {
name: "Found",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302"
},
303: {
name: "See Other",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303"
},
304: {
name: "Not Modified",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304"
},
305: {
name: "Use Proxy",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/305"
},
306: {
name: "(Unused)",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/306"
},
307: {
name: "Temporary Redirect",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307"
},
308: {
name: "Permanent Redirect",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308"
},
400: {
name: "Bad Request",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400"
},
401: {
name: "Unauthorized",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401"
},
402: {
name: "Payment Required",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402"
},
403: {
name: "Forbidden",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403"
},
404: {
name: "Not Found",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404"
},
405: {
name: "Method Not Allowed",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405"
},
406: {
name: "Not Acceptable",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406"
},
407: {
name: "Proxy Authentication Required",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407"
},
408: {
name: "Request Timeout",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408"
},
409: {
name: "Conflict",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409"
},
410: {
name: "Gone",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410"
},
411: {
name: "Length Required",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411"
},
412: {
name: "Precondition Failed",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412"
},
413: {
name: "Content Too Large",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413"
},
414: {
name: "URI Too Long",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414"
},
415: {
name: "Unsupported Media Type",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415"
},
416: {
name: "Range Not Satisfiable",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416"
},
417: {
name: "Expectation Failed",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/417"
},
418: {
name: "I'm a teapot",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/418"
},
421: {
name: "Misdirected Request",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/421"
},
422: {
name: "Unprocessable Content",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422"
},
423: {
name: "Locked",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/423"
},
424: {
name: "Failed Dependency",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/424"
},
425: {
name: "Too Early",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/425"
},
426: {
name: "Upgrade Required",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/426"
},
428: {
name: "Precondition Required",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428"
},
429: {
name: "Too Many Requests",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429"
},
431: {
name: "Request Header Fields Too Large",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/431"
},
451: {
name: "Unavailable For Legal Reasons",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451"
},
500: {
name: "Internal Server Error",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500"
},
501: {
name: "Not Implemented",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501"
},
502: {
name: "Bad Gateway",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502"
},
503: {
name: "Service Unavailable",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503"
},
504: {
name: "Gateway Timeout",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504"
},
505: {
name: "HTTP Version Not Supported",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/505"
},
506: {
name: "Variant Also Negotiates",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506"
},
507: {
name: "Insufficient Storage",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507"
},
508: {
name: "Loop Detected",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508"
},
510: {
name: "Not Extended",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510"
},
511: {
name: "Network Authentication Required",
url: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511"
}
};
const iterateTitle = (title2, checkDuplicates, separator = " #") => {
if (!checkDuplicates(title2))
return title2;
const split = title2.split(separator);
const newTitle = split.length > 1 ? `${split.slice(0, -1).join()}${separator}${Number(split.at(-1)) + 1}` : `${split.join()}${separator}2`;
return iterateTitle(newTitle, checkDuplicates, separator);
};
const LS_KEYS = {
COLLECTION: "collection",
COOKIE: "cookie",
ENVIRONMENT: "environment",
REQUEST: "request",
REQUEST_EXAMPLE: "requestExample",
SECURITY_SCHEME: "securityScheme",
SERVER: "server",
TAG: "tag",
WORKSPACE: "workspace"
};
function objectMerge(target, replacement) {
Object.keys(target).forEach((key2) => {
if (!Object.hasOwn(replacement, key2)) {
delete target[key2];
}
});
Object.assign(target, replacement);
return target;
}
const camelToTitleWords = (camelStr) => camelStr.replace(/([A-Z])/g, (match) => ` ${match}`).replace(/^./, (match) => match.toUpperCase()).trim();
const capitalize = (str) => str[0].toUpperCase() + str.slice(1);
const variableRegex = /{{((?:[^{}]|{[^{}]*})*)}}/g;
const pathRegex = new RegExp("(?<!{){([^{}]+)}(?!})", "g");
const DATA_VERSION = "2.1.0";
const DATA_VERSION_LS_LEY = "scalar_api_client_data_version";
const { parse: $parse, stringify: $stringify } = JSON;
const { keys } = Object;
const Primitive = String;
const primitive = "string";
const ignore = {};
const object = "object";
const noop$2 = (_2, value) => value;
const primitives = (value) => value instanceof Primitive ? Primitive(value) : value;
const Primitives = (_2, value) => typeof value === primitive ? new Primitive(value) : value;
const revive = (input, parsed, output, $2) => {
const lazy = [];
for (let ke2 = keys(output), { length } = ke2, y2 = 0; y2 < length; y2++) {
const k2 = ke2[y2];
const value = output[k2];
if (value instanceof Primitive) {
const tmp = input[value];
if (typeof tmp === object && !parsed.has(tmp)) {
parsed.add(tmp);
output[k2] = ignore;
lazy.push({ k: k2, a: [input, parsed, tmp, $2] });
} else
output[k2] = $2.call(output, k2, tmp);
} else if (output[k2] !== ignore)
output[k2] = $2.call(output, k2, value);
}
for (let { length } = lazy, i2 = 0; i2 < length; i2++) {
const { k: k2, a: a2 } = lazy[i2];
output[k2] = $2.call(output, k2, revive.apply(null, a2));
}
return output;
};
const set = (known, input, value) => {
const index2 = Primitive(input.push(value) - 1);
known.set(value, index2);
return index2;
};
const parse$7 = (text2, reviver) => {
const input = $parse(text2, Primitives).map(primitives);
const value = input[0];
const $2 = noop$2;
const tmp = typeof value === object && value ? revive(input, /* @__PURE__ */ new Set(), value, $2) : value;
return $2.call({ "": tmp }, "", tmp);
};
const stringify$2 = (value, replacer2, space2) => {
const $2 = noop$2;
const known = /* @__PURE__ */ new Map();
const input = [];
const output = [];
let i2 = +set(known, input, $2.call({ "": value }, "", value));
let firstRun = !i2;
while (i2 < input.length) {
firstRun = true;
output[i2] = $stringify(input[i2++], replace, space2);
}
return "[" + output.join(",") + "]";
function replace(key2, value2) {
if (firstRun) {
firstRun = !firstRun;
return value2;
}
const after = $2.call(this, key2, value2);
switch (typeof after) {
case object:
if (after === null) return after;
case primitive:
return known.get(after) || set(known, input, after);
}
return after;
}
};
const parseLocalStorage = (lsKey) => {
const item = localStorage.getItem(lsKey) || "[{}]";
const data = item[0] === "[" ? parse$7(item) : JSON.parse(item);
return data;
};
const getLocalStorageVersion = () => {
const collectionStr = localStorage.getItem("collection");
const dataVersion = localStorage.getItem(DATA_VERSION_LS_LEY);
if (!(collectionStr == null ? void 0 : collectionStr.length) || (collectionStr == null ? void 0 : collectionStr[0]) === "{")
return "0.0.0";
try {
const [collection] = Object.values(parse$7(collectionStr) ?? {});
if ((collection == null ? void 0 : collection.type) === "collection")
return "2.1.0";
if (dataVersion)
return dataVersion;
return "0.0.0";
} catch (e2) {
console.error(e2);
if (dataVersion)
return dataVersion;
return "0.0.0";
}
};
const semverLessThan = (left, right) => {
const parseSemver = (version2) => {
const [major, minor = 0, patch3 = 0] = version2.split(".").map((part) => parseInt(part, 10));
return { major, minor, patch: patch3 };
};
const { major: major1, minor: minor1, patch: patch1 } = parseSemver(left);
const { major: major2, minor: minor2, patch: patch2 } = parseSemver(right);
if (major1 < major2)
return true;
if (major1 > major2)
return false;
if (minor1 < minor2)
return true;
if (minor1 > minor2)
return false;
return patch1 < patch2;
};
const migrate_v_2_1_0 = (data) => {
console.info("Performing data migration v-0.0.0 to v-2.1.0");
const oldData = {
...data,
// @ts-expect-error Tags used to be called folders
folders: parseLocalStorage("folder")
};
const flattenChildren = (childUids) => childUids.reduce((prev, uid2) => {
var _a2;
const request = oldData.requests[uid2];
if (request) {
prev.requestUids.add(uid2);
(_a2 = request.securitySchemeUids) == null ? void 0 : _a2.forEach((s3) => prev.authUids.add(s3));
} else if (oldData.folders[uid2]) {
const { requestUids, tagUids, authUids } = flattenChildren(oldData.folders[uid2].childUids ?? []);
prev.tagUids.add(uid2);
requestUids.forEach((r2) => prev.requestUids.add(r2));
tagUids.forEach((t2) => prev.tagUids.add(t2));
authUids.forEach((a2) => prev.authUids.add(a2));
}
return prev;
}, {
requestUids: /* @__PURE__ */ new Set(),
tagUids: /* @__PURE__ */ new Set(),
authUids: /* @__PURE__ */ new Set()
});
const migrateAuth = (scheme) => {
if (scheme.type === "apiKey")
return { type: "apiKey", name: scheme.name, value: scheme.value ?? "" };
if (scheme.type === "http")
return {
type: "http",
username: scheme.value ?? "",
password: scheme.secondValue ?? "",
token: scheme.value ?? ""
};
if (scheme.type === "oauth2" && scheme.flow.type === "implicit")
return {
type: "oauth-implicit",
token: scheme.flow.token ?? ""
};
if (scheme.type === "oauth2" && scheme.flow.type === "password")
return {
type: "oauth-password",
token: scheme.flow.token ?? "",
username: scheme.flow.value ?? "",
password: scheme.flow.secondValue ?? "",
clientSecret: scheme.flow.clientSecret ?? ""
};
if (scheme.type === "oauth2" && scheme.flow.type === "clientCredentials")
return {
type: "oauth-clientCredentials",
token: scheme.flow.token ?? "",
clientSecret: scheme.flow.clientSecret ?? ""
};
if (scheme.type === "oauth2" && scheme.flow.type === "authorizationCode")
return {
type: "oauth-authorizationCode",
token: scheme.flow.token ?? "",
clientSecret: scheme.flow.clientSecret ?? ""
};
return {
type: "apiKey",
name: "",
value: ""
};
};
const requestSecurityDict = {};
const collections = Object.values(oldData.collections ?? {}).map((c2) => {
var _a2, _b, _c, _d, _e, _f, _g;
const { requestUids, tagUids, authUids } = flattenChildren(c2.childUids ?? []);
const securitySchemesSet = /* @__PURE__ */ new Set([
...authUids,
...Object.values(c2.securitySchemeDict ?? {})
]);
const securitySchemes2 = [...securitySchemesSet];
requestUids.forEach((r2) => requestSecurityDict[r2] = securitySchemes2);
const auth = securitySchemes2.reduce((prev, uid2) => {
const scheme = oldData.securitySchemes[uid2];
if (scheme.uid)
prev[uid2] = migrateAuth(scheme);
return prev;
}, {});
return {
"type": "collection",
"openapi": ((_a2 = c2.spec) == null ? void 0 : _a2.openapi) || "3.1.0",
"info": ((_b = c2.spec) == null ? void 0 : _b.info) || { title: "OpenAPI Spec", version: "0.0.1" },
"security": ((_c = c2.spec) == null ? void 0 : _c.security) || [],
"externalDocs": (_d = c2.spec) == null ? void 0 : _d.externalDocs,
"uid": c2.uid,
securitySchemes: securitySchemes2,
"selectedServerUid": c2.selectedServerUid || ((_f = (_e = c2.spec) == null ? void 0 : _e.serverUids) == null ? void 0 : _f[0]) || "",
"servers": ((_g = c2.spec) == null ? void 0 : _g.serverUids) || [],
"requests": [...requestUids],
"tags": [...tagUids],
auth,
"children": c2.childUids || [],
"x-scalar-icon": "interface-content-folder",
"watchForChanges": false,
"watchForChangesStatus": "IDLE"
};
});
const cookies = Object.values(oldData.cookies ?? {});
const environments = Object.values(oldData.environments ?? {}).map((e2) => ({
...e2,
value: e2.raw ?? ""
}));
const requests = Object.values(oldData.requests ?? {}).map((r2) => {
var _a2, _b, _c, _d, _e;
const parameters = [
...Object.values(((_a2 = r2.parameters) == null ? void 0 : _a2.path) ?? {}),
...Object.values(((_b = r2.parameters) == null ? void 0 : _b.query) ?? {}),
...Object.values(((_c = r2.parameters) == null ? void 0 : _c.headers) ?? {}),
...Object.values(((_d = r2.parameters) == null ? void 0 : _d.cookies) ?? {})
].filter((p2) => p2);
const selectedSecuritySchemeUids = (r2.selectedSecuritySchemeUids || []).filter((s3) => requestSecurityDict[r2.uid].includes(s3));
return {
...r2,
parameters,
type: "request",
method: ((_e = r2.method) == null ? void 0 : _e.toLowerCase()) ?? "get",
examples: r2.childUids || [],
selectedSecuritySchemeUids,
selectedServerUid: "",
servers: []
};
});
const requestExamples = Object.values(oldData.requestExamples ?? {}).map((e2) => ({
...e2,
type: "requestExample"
}));
const migrateFlow = (flow) => {
const base2 = {
refreshUrl: flow.refreshUrl || "",
selectedScopes: flow.selectedScopes || [],
scopes: flow.scopes || {}
};
if (flow.type === "implicit")
return {
...flow,
...base2,
"type": "implicit",
"x-scalar-redirect-uri": ("redirectUri" in flow ? flow.redirectUri : "") || ""
};
if (flow.type === "password")
return {
...flow,
...base2,
tokenUrl: flow.tokenUrl || ""
};
if (flow.type === "clientCredentials")
return {
...flow,
...base2,
tokenUrl: flow.tokenUrl || ""
};
return {
...flow,
...base2,
"x-scalar-redirect-uri": ("redirectUri" in flow ? flow.redirectUri : "") || "",
"authorizationUrl": flow.authorizationUrl || "",
"tokenUrl": flow.tokenUrl || ""
};
};
const getNameKey = (scheme) => {
switch (scheme == null ? void 0 : scheme.type) {
case "apiKey":
return `${capitalize(scheme.in)}`;
case "http": {
return `${capitalize(scheme.scheme)} Authentication`;
}
case "oauth2":
return camelToTitleWords(scheme.flow.type);
case "openIdConnect":
return `Open ID Connect`;
default:
return "None";
}
};
const securitySchemes = Object.values(oldData.securitySchemes ?? {}).map((s3) => s3.type === "oauth2" ? {
...s3,
"nameKey": getNameKey(s3),
"x-scalar-client-id": s3.clientId || "",
"flow": migrateFlow(s3.flow)
} : { ...s3, nameKey: getNameKey(s3) });
const servers = Object.values(oldData.servers ?? {}).map((s3) => ({
...s3,
variables: s3.variables ?? {}
}));
const tags2 = Object.values(oldData.folders ?? {}).map((f2) => ({
"type": "tag",
"uid": f2.uid,
"name": f2.name || "unknownTag",
"description": f2.description,
"children": f2.childUids || [],
"x-scalar-children": []
}));
const workspaces = Object.values(oldData.workspaces ?? {}).map((w2) => ({
...w2,
description: w2.description ?? "Basic Scalar Workspace",
cookies: w2.cookieUids || [],
collections: w2.collectionUids || [],
environments: w2.environmentUids || []
}));
return {
collections,
cookies,
environments,
requestExamples,
requests,
securitySchemes,
servers,
tags: tags2,
workspaces
};
};
const migrator = () => {
const dataVersion = getLocalStorageVersion();
console.info("Data version: " + dataVersion);
let data = {
collections: parseLocalStorage("collection"),
cookies: parseLocalStorage("cookie"),
environments: parseLocalStorage("environment"),
requestExamples: parseLocalStorage("requestExample"),
requests: parseLocalStorage("request"),
securitySchemes: parseLocalStorage("securityScheme"),
servers: parseLocalStorage("server"),
tags: parseLocalStorage("tag"),
workspaces: parseLocalStorage("workspace")
};
if (semverLessThan(dataVersion, "2.1.0"))
data = migrate_v_2_1_0(data);
else
data = {
collections: Object.values(data.collections),
cookies: Object.values(data.cookies),
environments: Object.values(data.environments),
requestExamples: Object.values(data.requestExamples),
requests: Object.values(data.requests),
securitySchemes: Object.values(data.securitySchemes),
servers: Object.values(data.servers),
tags: Object.values(data.tags),
workspaces: Object.values(data.workspaces)
};
return data;
};
const loadResources = (resources, schema2, add2) => resources.forEach((payload) => {
const resource = schemaModel(payload, schema2, false);
if (resource) add2(resource);
});
const loadAllResources = (mutators) => {
const {
collectionMutators,
cookieMutators,
environmentMutators,
tagMutators,
requestExampleMutators,
requestMutators,
serverMutators,
securitySchemeMutators,
workspaceMutators
} = mutators;
try {
const {
collections,
cookies,
environments,
requestExamples,
requests,
servers,
securitySchemes,
tags: tags2,
workspaces
} = migrator();
loadResources(collections, collectionSchema, collectionMutators.rawAdd);
loadResources(cookies, cookieSchema, cookieMutators.add);
loadResources(environments, environmentSchema, environmentMutators.add);
loadResources(
requestExamples,
requestExampleSchema,
requestExampleMutators.rawAdd
);
loadResources(requests, requestSchema, requestMutators.rawAdd);
loadResources(servers, serverSchema, serverMutators.rawAdd);
loadResources(
securitySchemes,
securitySchemeSchema,
securitySchemeMutators.rawAdd
);
loadResources(tags2, tagSchema, tagMutators.rawAdd);
loadResources(workspaces, workspaceSchema, workspaceMutators.rawAdd);
localStorage.setItem(DATA_VERSION_LS_LEY, DATA_VERSION);
} catch (e2) {
console.error(e2);
}
};
function getDotPathValue(path2, context) {
const pathKeys = path2.split(".");
const result = pathKeys.reduce(
(nested, currentKey) => nested == null ? void 0 : nested[currentKey],
context
);
return typeof result === "string" ? result : JSON.stringify(result);
}
function replaceTemplateVariables(templateString, context) {
const variableRegex2 = /{{\s*([^}\s]+?)\s*}}|{\s*([^}\s]+?)\s*}|:\b[\w.]+\b/g;
const matches = templateString.match(variableRegex2) ?? [];
let substitutedString = templateString;
matches.forEach((m2) => {
const key2 = m2.startsWith(":") ? m2.slice(1) : m2.replace(/[{}]/g, "").trim();
const value = getDotPathValue(key2, context);
if (value !== null && value !== void 0)
substitutedString = substitutedString.replaceAll(m2, value);
});
return substitutedString;
}
function flattenEnvVars(environment) {
function getNestedKeyValues(item, prefix) {
const keys2 = Object.keys(item);
const values2 = [];
keys2.forEach((k2) => {
const prefixedKey = prefix ? `${prefix}.${k2}` : k2;
if (typeof item[k2] === "object") {
values2.push(...getNestedKeyValues(item[k2], prefixedKey));
} else {
values2.push([prefixedKey, String(item[k2])]);
}
});
return values2;
}
return getNestedKeyValues(environment);
}
/*!
* vue-router v4.3.3
* (c) 2024 Eduardo San Martin Morote
* @license MIT
*/
const isBrowser = typeof document !== "undefined";
function isESModule(obj) {
return obj.__esModule || obj[Symbol.toStringTag] === "Module";
}
const assign$1 = Object.assign;
function applyToParams(fn, params) {
const newParams = {};
for (const key2 in params) {
const value = params[key2];
newParams[key2] = isArray$2(value) ? value.map(fn) : fn(value);
}
return newParams;
}
const noop$1 = () => {
};
const isArray$2 = Array.isArray;
const HASH_RE = /#/g;
const AMPERSAND_RE = /&/g;
const SLASH_RE = /\//g;
const EQUAL_RE = /=/g;
const IM_RE = /\?/g;
const PLUS_RE = /\+/g;
const ENC_BRACKET_OPEN_RE = /%5B/g;
const ENC_BRACKET_CLOSE_RE = /%5D/g;
const ENC_CARET_RE = /%5E/g;
const ENC_BACKTICK_RE = /%60/g;
const ENC_CURLY_OPEN_RE = /%7B/g;
const ENC_PIPE_RE = /%7C/g;
const ENC_CURLY_CLOSE_RE = /%7D/g;
const ENC_SPACE_RE = /%20/g;
function commonEncode(text2) {
return encodeURI("" + text2).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
}
function encodeHash(text2) {
return commonEncode(text2).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
}
function encodeQueryValue(text2) {
return commonEncode(text2).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
}
function encodeQueryKey(text2) {
return encodeQueryValue(text2).replace(EQUAL_RE, "%3D");
}
function encodePath(text2) {
return commonEncode(text2).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
}
function encodeParam(text2) {
return text2 == null ? "" : encodePath(text2).replace(SLASH_RE, "%2F");
}
function decode(text2) {
try {
return decodeURIComponent("" + text2);
} catch (err) {
}
return "" + text2;
}
const TRAILING_SLASH_RE = /\/$/;
const removeTrailingSlash = (path2) => path2.replace(TRAILING_SLASH_RE, "");
function parseURL(parseQuery2, location2, currentLocation = "/") {
let path2, query = {}, searchString = "", hash2 = "";
const hashPos = location2.indexOf("#");
let searchPos = location2.indexOf("?");
if (hashPos < searchPos && hashPos >= 0) {
searchPos = -1;
}
if (searchPos > -1) {
path2 = location2.slice(0, searchPos);
searchString = location2.slice(searchPos + 1, hashPos > -1 ? hashPos : location2.length);
query = parseQuery2(searchString);
}
if (hashPos > -1) {
path2 = path2 || location2.slice(0, hashPos);
hash2 = location2.slice(hashPos, location2.length);
}
path2 = resolveRelativePath(path2 != null ? path2 : location2, currentLocation);
return {
fullPath: path2 + (searchString && "?") + searchString + hash2,
path: path2,
query,
hash: decode(hash2)
};
}
function stringifyURL(stringifyQuery2, location2) {
const query = location2.query ? stringifyQuery2(location2.query) : "";
return location2.path + (query && "?") + query + (location2.hash || "");
}
function stripBase(pathname, base2) {
if (!base2 || !pathname.toLowerCase().startsWith(base2.toLowerCase()))
return pathname;
return pathname.slice(base2.length) || "/";
}
function isSameRouteLocation(stringifyQuery2, a2, b2) {
const aLastIndex = a2.matched.length - 1;
const bLastIndex = b2.matched.length - 1;
return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a2.matched[aLastIndex], b2.matched[bLastIndex]) && isSameRouteLocationParams(a2.params, b2.params) && stringifyQuery2(a2.query) === stringifyQuery2(b2.query) && a2.hash === b2.hash;
}
function isSameRouteRecord(a2, b2) {
return (a2.aliasOf || a2) === (b2.aliasOf || b2);
}
function isSameRouteLocationParams(a2, b2) {
if (Object.keys(a2).length !== Object.keys(b2).length)
return false;
for (const key2 in a2) {
if (!isSameRouteLocationParamsValue(a2[key2], b2[key2]))
return false;
}
return true;
}
function isSameRouteLocationParamsValue(a2, b2) {
return isArray$2(a2) ? isEquivalentArray(a2, b2) : isArray$2(b2) ? isEquivalentArray(b2, a2) : a2 === b2;
}
function isEquivalentArray(a2, b2) {
return isArray$2(b2) ? a2.length === b2.length && a2.every((value, i2) => value === b2[i2]) : a2.length === 1 && a2[0] === b2;
}
function resolveRelativePath(to2, from) {
if (to2.startsWith("/"))
return to2;
if (!to2)
return from;
const fromSegments = from.split("/");
const toSegments = to2.split("/");
const lastToSegment = toSegments[toSegments.length - 1];
if (lastToSegment === ".." || lastToSegment === ".") {
toSegments.push("");
}
let position2 = fromSegments.length - 1;
let toPosition;
let segment;
for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
segment = toSegments[toPosition];
if (segment === ".")
continue;
if (segment === "..") {
if (position2 > 1)
position2--;
} else
break;
}
return fromSegments.slice(0, position2).join("/") + "/" + toSegments.slice(toPosition).join("/");
}
var NavigationType;
(function(NavigationType2) {
NavigationType2["pop"] = "pop";
NavigationType2["push"] = "push";
})(NavigationType || (NavigationType = {}));
var NavigationDirection;
(function(NavigationDirection2) {
NavigationDirection2["back"] = "back";
NavigationDirection2["forward"] = "forward";
NavigationDirection2["unknown"] = "";
})(NavigationDirection || (NavigationDirection = {}));
const START = "";
function normalizeBase(base2) {
if (!base2) {
if (isBrowser) {
const baseEl = document.querySelector("base");
base2 = baseEl && baseEl.getAttribute("href") || "/";
base2 = base2.replace(/^\w+:\/\/[^\/]+/, "");
} else {
base2 = "/";
}
}
if (base2[0] !== "/" && base2[0] !== "#")
base2 = "/" + base2;
return removeTrailingSlash(base2);
}
const BEFORE_HASH_RE = /^[^#]+#/;
function createHref(base2, location2) {
return base2.replace(BEFORE_HASH_RE, "#") + location2;
}
function getElementPosition(el, offset2) {
const docRect = document.documentElement.getBoundingClientRect();
const elRect = el.getBoundingClientRect();
return {
behavior: offset2.behavior,
left: elRect.left - docRect.left - (offset2.left || 0),
top: elRect.top - docRect.top - (offset2.top || 0)
};
}
const computeScrollPosition = () => ({
left: window.scrollX,
top: window.scrollY
});
function scrollToPosition(position2) {
let scrollToOptions;
if ("el" in position2) {
const positionEl = position2.el;
const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
const el = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
if (!el) {
return;
}
scrollToOptions = getElementPosition(el, position2);
} else {
scrollToOptions = position2;
}
if ("scrollBehavior" in document.documentElement.style)
window.scrollTo(scrollToOptions);
else {
window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.scrollX, scrollToOptions.top != null ? scrollToOptions.top : window.scrollY);
}
}
function getScrollKey(path2, delta) {
const position2 = history.state ? history.state.position - delta : -1;
return position2 + path2;
}
const scrollPositions = /* @__PURE__ */ new Map();
function saveScrollPosition(key2, scrollPosition) {
scrollPositions.set(key2, scrollPosition);
}
function getSavedScrollPosition(key2) {
const scroll = scrollPositions.get(key2);
scrollPositions.delete(key2);
return scroll;
}
let createBaseLocation = () => location.protocol + "//" + location.host;
function createCurrentLocation(base2, location2) {
const { pathname, search: search2, hash: hash2 } = location2;
const hashPos = base2.indexOf("#");
if (hashPos > -1) {
let slicePos = hash2.includes(base2.slice(hashPos)) ? base2.slice(hashPos).length : 1;
let pathFromHash = hash2.slice(slicePos);
if (pathFromHash[0] !== "/")
pathFromHash = "/" + pathFromHash;
return stripBase(pathFromHash, "");
}
const path2 = stripBase(pathname, base2);
return path2 + search2 + hash2;
}
function useHistoryListeners(base2, historyState, currentLocation, replace) {
let listeners = [];
let teardowns = [];
let pauseState = null;
const popStateHandler = ({ state }) => {
const to2 = createCurrentLocation(base2, location);
const from = currentLocation.value;
const fromState = historyState.value;
let delta = 0;
if (state) {
currentLocation.value = to2;
historyState.value = state;
if (pauseState && pauseState === from) {
pauseState = null;
return;
}
delta = fromState ? state.position - fromState.position : 0;
} else {
replace(to2);
}
listeners.forEach((listener) => {
listener(currentLocation.value, from, {
delta,
type: NavigationType.pop,
direction: delta ? delta > 0 ? NavigationDirection.forward : NavigationDirection.back : NavigationDirection.unknown
});
});
};
function pauseListeners() {
pauseState = currentLocation.value;
}
function listen(callback) {
listeners.push(callback);
const teardown = () => {
const index2 = listeners.indexOf(callback);
if (index2 > -1)
listeners.splice(index2, 1);
};
teardowns.push(teardown);
return teardown;
}
function beforeUnloadListener() {
const { history: history2 } = window;
if (!history2.state)
return;
history2.replaceState(assign$1({}, history2.state, { scroll: computeScrollPosition() }), "");
}
function destroy() {
for (const teardown of teardowns)
teardown();
teardowns = [];
window.removeEventListener("popstate", popStateHandler);
window.removeEventListener("beforeunload", beforeUnloadListener);
}
window.addEventListener("popstate", popStateHandler);
window.addEventListener("beforeunload", beforeUnloadListener, {
passive: true
});
return {
pauseListeners,
listen,
destroy
};
}
function buildState(back, current, forward, replaced = false, computeScroll = false) {
return {
back,
current,
forward,
replaced,
position: window.history.length,
scroll: computeScroll ? computeScrollPosition() : null
};
}
function useHistoryStateNavigation(base2) {
const { history: history2, location: location2 } = window;
const currentLocation = {
value: createCurrentLocation(base2, location2)
};
const historyState = { value: history2.state };
if (!historyState.value) {
changeLocation(currentLocation.value, {
back: null,
current: currentLocation.value,
forward: null,
// the length is off by one, we need to decrease it
position: history2.length - 1,
replaced: true,
// don't add a scroll as the user may have an anchor, and we want
// scrollBehavior to be triggered without a saved position
scroll: null
}, true);
}
function changeLocation(to2, state, replace2) {
const hashIndex = base2.indexOf("#");
const url = hashIndex > -1 ? (location2.host && document.querySelector("base") ? base2 : base2.slice(hashIndex)) + to2 : createBaseLocation() + base2 + to2;
try {
history2[replace2 ? "replaceState" : "pushState"](state, "", url);
historyState.value = state;
} catch (err) {
{
console.error(err);
}
location2[replace2 ? "replace" : "assign"](url);
}
}
function replace(to2, data) {
const state = assign$1({}, history2.state, buildState(
historyState.value.back,
// keep back and forward entries but override current position
to2,
historyState.value.forward,
true
), data, { position: historyState.value.position });
changeLocation(to2, state, true);
currentLocation.value = to2;
}
function push(to2, data) {
const currentState = assign$1(
{},
// use current history state to gracefully handle a wrong call to
// history.replaceState
// https://github.com/vuejs/router/issues/366
historyState.value,
history2.state,
{
forward: to2,
scroll: computeScrollPosition()
}
);
changeLocation(currentState.current, currentState, true);
const state = assign$1({}, buildState(currentLocation.value, to2, null), { position: currentState.position + 1 }, data);
changeLocation(to2, state, false);
currentLocation.value = to2;
}
return {
location: currentLocation,
state: historyState,
push,
replace
};
}
function createWebHistory(base2) {
base2 = normalizeBase(base2);
const historyNavigation = useHistoryStateNavigation(base2);
const historyListeners = useHistoryListeners(base2, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
function go2(delta, triggerListeners = true) {
if (!triggerListeners)
historyListeners.pauseListeners();
history.go(delta);
}
const routerHistory = assign$1({
// it's overridden right after
location: "",
base: base2,
go: go2,
createHref: createHref.bind(null, base2)
}, historyNavigation, historyListeners);
Object.defineProperty(routerHistory, "location", {
enumerable: true,
get: () => historyNavigation.location.value
});
Object.defineProperty(routerHistory, "state", {
enumerable: true,
get: () => historyNavigation.state.value
});
return routerHistory;
}
function createMemoryHistory(base2 = "") {
let listeners = [];
let queue2 = [START];
let position2 = 0;
base2 = normalizeBase(base2);
function setLocation(location2) {
position2++;
if (position2 !== queue2.length) {
queue2.splice(position2);
}
queue2.push(location2);
}
function triggerListeners(to2, from, { direction, delta }) {
const info = {
direction,
delta,
type: NavigationType.pop
};
for (const callback of listeners) {
callback(to2, from, info);
}
}
const routerHistory = {
// rewritten by Object.defineProperty
location: START,
// TODO: should be kept in queue
state: {},
base: base2,
createHref: createHref.bind(null, base2),
replace(to2) {
queue2.splice(position2--, 1);
setLocation(to2);
},
push(to2, data) {
setLocation(to2);
},
listen(callback) {
listeners.push(callback);
return () => {
const index2 = listeners.indexOf(callback);
if (index2 > -1)
listeners.splice(index2, 1);
};
},
destroy() {
listeners = [];
queue2 = [START];
position2 = 0;
},
go(delta, shouldTrigger = true) {
const from = this.location;
const direction = (
// we are considering delta === 0 going forward, but in abstract mode
// using 0 for the delta doesn't make sense like it does in html5 where
// it reloads the page
delta < 0 ? NavigationDirection.back : NavigationDirection.forward
);
position2 = Math.max(0, Math.min(position2 + delta, queue2.length - 1));
if (shouldTrigger) {
triggerListeners(this.location, from, {
direction,
delta
});
}
}
};
Object.defineProperty(routerHistory, "location", {
enumerable: true,
get: () => queue2[position2]
});
return routerHistory;
}
function isRouteLocation(route) {
return typeof route === "string" || route && typeof route === "object";
}
function isRouteName(name2) {
return typeof name2 === "string" || typeof name2 === "symbol";
}
const START_LOCATION_NORMALIZED = {
path: "/",
name: void 0,
params: {},
query: {},
hash: "",
fullPath: "/",
matched: [],
meta: {},
redirectedFrom: void 0
};
const NavigationFailureSymbol = Symbol("");
var NavigationFailureType;
(function(NavigationFailureType2) {
NavigationFailureType2[NavigationFailureType2["aborted"] = 4] = "aborted";
NavigationFailureType2[NavigationFailureType2["cancelled"] = 8] = "cancelled";
NavigationFailureType2[NavigationFailureType2["duplicated"] = 16] = "duplicated";
})(NavigationFailureType || (NavigationFailureType = {}));
function createRouterError(type2, params) {
{
return assign$1(new Error(), {
type: type2,
[NavigationFailureSymbol]: true
}, params);
}
}
function isNavigationFailure(error2, type2) {
return error2 instanceof Error && NavigationFailureSymbol in error2 && (type2 == null || !!(error2.type & type2));
}
const BASE_PARAM_PATTERN = "[^/]+?";
const BASE_PATH_PARSER_OPTIONS = {
sensitive: false,
strict: false,
start: true,
end: true
};
const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
function tokensToParser(segments, extraOptions) {
const options = assign$1({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
const score2 = [];
let pattern = options.start ? "^" : "";
const keys2 = [];
for (const segment of segments) {
const segmentScores = segment.length ? [] : [
90
/* PathScore.Root */
];
if (options.strict && !segment.length)
pattern += "/";
for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
const token = segment[tokenIndex];
let subSegmentScore = 40 + (options.sensitive ? 0.25 : 0);
if (token.type === 0) {
if (!tokenIndex)
pattern += "/";
pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
subSegmentScore += 40;
} else if (token.type === 1) {
const { value, repeatable, optional: optional2, regexp } = token;
keys2.push({
name: value,
repeatable,
optional: optional2
});
const re22 = regexp ? regexp : BASE_PARAM_PATTERN;
if (re22 !== BASE_PARAM_PATTERN) {
subSegmentScore += 10;
try {
new RegExp(`(${re22})`);
} catch (err) {
throw new Error(`Invalid custom RegExp for param "${value}" (${re22}): ` + err.message);
}
}
let subPattern = repeatable ? `((?:${re22})(?:/(?:${re22}))*)` : `(${re22})`;
if (!tokenIndex)
subPattern = // avoid an optional / if there are more segments e.g. /:p?-static
// or /:p?-:p2
optional2 && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
if (optional2)
subPattern += "?";
pattern += subPattern;
subSegmentScore += 20;
if (optional2)
subSegmentScore += -8;
if (repeatable)
subSegmentScore += -20;
if (re22 === ".*")
subSegmentScore += -50;
}
segmentScores.push(subSegmentScore);
}
score2.push(segmentScores);
}
if (options.strict && options.end) {
const i2 = score2.length - 1;
score2[i2][score2[i2].length - 1] += 0.7000000000000001;
}
if (!options.strict)
pattern += "/?";
if (options.end)
pattern += "$";
else if (options.strict)
pattern += "(?:/|$)";
const re2 = new RegExp(pattern, options.sensitive ? "" : "i");
function parse3(path2) {
const match = path2.match(re2);
const params = {};
if (!match)
return null;
for (let i2 = 1; i2 < match.length; i2++) {
const value = match[i2] || "";
const key2 = keys2[i2 - 1];
params[key2.name] = value && key2.repeatable ? value.split("/") : value;
}
return params;
}
function stringify2(params) {
let path2 = "";
let avoidDuplicatedSlash = false;
for (const segment of segments) {
if (!avoidDuplicatedSlash || !path2.endsWith("/"))
path2 += "/";
avoidDuplicatedSlash = false;
for (const token of segment) {
if (token.type === 0) {
path2 += token.value;
} else if (token.type === 1) {
const { value, repeatable, optional: optional2 } = token;
const param = value in params ? params[value] : "";
if (isArray$2(param) && !repeatable) {
throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
}
const text2 = isArray$2(param) ? param.join("/") : param;
if (!text2) {
if (optional2) {
if (segment.length < 2) {
if (path2.endsWith("/"))
path2 = path2.slice(0, -1);
else
avoidDuplicatedSlash = true;
}
} else
throw new Error(`Missing required param "${value}"`);
}
path2 += text2;
}
}
}
return path2 || "/";
}
return {
re: re2,
score: score2,
keys: keys2,
parse: parse3,
stringify: stringify2
};
}
function compareScoreArray(a2, b2) {
let i2 = 0;
while (i2 < a2.length && i2 < b2.length) {
const diff2 = b2[i2] - a2[i2];
if (diff2)
return diff2;
i2++;
}
if (a2.length < b2.length) {
return a2.length === 1 && a2[0] === 40 + 40 ? -1 : 1;
} else if (a2.length > b2.length) {
return b2.length === 1 && b2[0] === 40 + 40 ? 1 : -1;
}
return 0;
}
function comparePathParserScore(a2, b2) {
let i2 = 0;
const aScore = a2.score;
const bScore = b2.score;
while (i2 < aScore.length && i2 < bScore.length) {
const comp = compareScoreArray(aScore[i2], bScore[i2]);
if (comp)
return comp;
i2++;
}
if (Math.abs(bScore.length - aScore.length) === 1) {
if (isLastScoreNegative(aScore))
return 1;
if (isLastScoreNegative(bScore))
return -1;
}
return bScore.length - aScore.length;
}
function isLastScoreNegative(score2) {
const last = score2[score2.length - 1];
return score2.length > 0 && last[last.length - 1] < 0;
}
const ROOT_TOKEN = {
type: 0,
value: ""
};
const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
function tokenizePath(path2) {
if (!path2)
return [[]];
if (path2 === "/")
return [[ROOT_TOKEN]];
if (!path2.startsWith("/")) {
throw new Error(`Invalid path "${path2}"`);
}
function crash(message) {
throw new Error(`ERR (${state})/"${buffer}": ${message}`);
}
let state = 0;
let previousState = state;
const tokens = [];
let segment;
function finalizeSegment() {
if (segment)
tokens.push(segment);
segment = [];
}
let i2 = 0;
let char;
let buffer = "";
let customRe = "";
function consumeBuffer() {
if (!buffer)
return;
if (state === 0) {
segment.push({
type: 0,
value: buffer
});
} else if (state === 1 || state === 2 || state === 3) {
if (segment.length > 1 && (char === "*" || char === "+"))
crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
segment.push({
type: 1,
value: buffer,
regexp: customRe,
repeatable: char === "*" || char === "+",
optional: char === "*" || char === "?"
});
} else {
crash("Invalid state to consume buffer");
}
buffer = "";
}
function addCharToBuffer() {
buffer += char;
}
while (i2 < path2.length) {
char = path2[i2++];
if (char === "\\" && state !== 2) {
previousState = state;
state = 4;
continue;
}
switch (state) {
case 0:
if (char === "/") {
if (buffer) {
consumeBuffer();
}
finalizeSegment();
} else if (char === ":") {
consumeBuffer();
state = 1;
} else {
addCharToBuffer();
}
break;
case 4:
addCharToBuffer();
state = previousState;
break;
case 1:
if (char === "(") {
state = 2;
} else if (VALID_PARAM_RE.test(char)) {
addCharToBuffer();
} else {
consumeBuffer();
state = 0;
if (char !== "*" && char !== "?" && char !== "+")
i2--;
}
break;
case 2:
if (char === ")") {
if (customRe[customRe.length - 1] == "\\")
customRe = customRe.slice(0, -1) + char;
else
state = 3;
} else {
customRe += char;
}
break;
case 3:
consumeBuffer();
state = 0;
if (char !== "*" && char !== "?" && char !== "+")
i2--;
customRe = "";
break;
default:
crash("Unknown state");
break;
}
}
if (state === 2)
crash(`Unfinished custom RegExp for param "${buffer}"`);
consumeBuffer();
finalizeSegment();
return tokens;
}
function createRouteRecordMatcher(record, parent, options) {
const parser2 = tokensToParser(tokenizePath(record.path), options);
const matcher = assign$1(parser2, {
record,
parent,
// these needs to be populated by the parent
children: [],
alias: []
});
if (parent) {
if (!matcher.record.aliasOf === !parent.record.aliasOf)
parent.children.push(matcher);
}
return matcher;
}
function createRouterMatcher(routes2, globalOptions) {
const matchers = [];
const matcherMap = /* @__PURE__ */ new Map();
globalOptions = mergeOptions({ strict: false, end: true, sensitive: false }, globalOptions);
function getRecordMatcher(name2) {
return matcherMap.get(name2);
}
function addRoute(record, parent, originalRecord) {
const isRootAdd = !originalRecord;
const mainNormalizedRecord = normalizeRouteRecord(record);
mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
const options = mergeOptions(globalOptions, record);
const normalizedRecords = [
mainNormalizedRecord
];
if ("alias" in record) {
const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
for (const alias of aliases) {
normalizedRecords.push(assign$1({}, mainNormalizedRecord, {
// this allows us to hold a copy of the `components` option
// so that async components cache is hold on the original record
components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
path: alias,
// we might be the child of an alias
aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
// the aliases are always of the same kind as the original since they
// are defined on the same record
}));
}
}
let matcher;
let originalMatcher;
for (const normalizedRecord of normalizedRecords) {
const { path: path2 } = normalizedRecord;
if (parent && path2[0] !== "/") {
const parentPath = parent.record.path;
const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
normalizedRecord.path = parent.record.path + (path2 && connectingSlash + path2);
}
matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
if (originalRecord) {
originalRecord.alias.push(matcher);
} else {
originalMatcher = originalMatcher || matcher;
if (originalMatcher !== matcher)
originalMatcher.alias.push(matcher);
if (isRootAdd && record.name && !isAliasRecord(matcher))
removeRoute(record.name);
}
if (isMatchable(matcher)) {
insertMatcher(matcher);
}
if (mainNormalizedRecord.children) {
const children = mainNormalizedRecord.children;
for (let i2 = 0; i2 < children.length; i2++) {
addRoute(children[i2], matcher, originalRecord && originalRecord.children[i2]);
}
}
originalRecord = originalRecord || matcher;
}
return originalMatcher ? () => {
removeRoute(originalMatcher);
} : noop$1;
}
function removeRoute(matcherRef) {
if (isRouteName(matcherRef)) {
const matcher = matcherMap.get(matcherRef);
if (matcher) {
matcherMap.delete(matcherRef);
matchers.splice(matchers.indexOf(matcher), 1);
matcher.children.forEach(removeRoute);
matcher.alias.forEach(removeRoute);
}
} else {
const index2 = matchers.indexOf(matcherRef);
if (index2 > -1) {
matchers.splice(index2, 1);
if (matcherRef.record.name)
matcherMap.delete(matcherRef.record.name);
matcherRef.children.forEach(removeRoute);
matcherRef.alias.forEach(removeRoute);
}
}
}
function getRoutes() {
return matchers;
}
function insertMatcher(matcher) {
const index2 = findInsertionIndex(matcher, matchers);
matchers.splice(index2, 0, matcher);
if (matcher.record.name && !isAliasRecord(matcher))
matcherMap.set(matcher.record.name, matcher);
}
function resolve2(location2, currentLocation) {
let matcher;
let params = {};
let path2;
let name2;
if ("name" in location2 && location2.name) {
matcher = matcherMap.get(location2.name);
if (!matcher)
throw createRouterError(1, {
location: location2
});
name2 = matcher.record.name;
params = assign$1(
// paramsFromLocation is a new object
paramsFromLocation(
currentLocation.params,
// only keep params that exist in the resolved location
// only keep optional params coming from a parent record
matcher.keys.filter((k2) => !k2.optional).concat(matcher.parent ? matcher.parent.keys.filter((k2) => k2.optional) : []).map((k2) => k2.name)
),
// discard any existing params in the current location that do not exist here
// #1497 this ensures better active/exact matching
location2.params && paramsFromLocation(location2.params, matcher.keys.map((k2) => k2.name))
);
path2 = matcher.stringify(params);
} else if (location2.path != null) {
path2 = location2.path;
matcher = matchers.find((m2) => m2.re.test(path2));
if (matcher) {
params = matcher.parse(path2);
name2 = matcher.record.name;
}
} else {
matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m2) => m2.re.test(currentLocation.path));
if (!matcher)
throw createRouterError(1, {
location: location2,
currentLocation
});
name2 = matcher.record.name;
params = assign$1({}, currentLocation.params, location2.params);
path2 = matcher.stringify(params);
}
const matched = [];
let parentMatcher = matcher;
while (parentMatcher) {
matched.unshift(parentMatcher.record);
parentMatcher = parentMatcher.parent;
}
return {
name: name2,
path: path2,
params,
matched,
meta: mergeMetaFields(matched)
};
}
routes2.forEach((route) => addRoute(route));
return { addRoute, resolve: resolve2, removeRoute, getRoutes, getRecordMatcher };
}
function paramsFromLocation(params, keys2) {
const newParams = {};
for (const key2 of keys2) {
if (key2 in params)
newParams[key2] = params[key2];
}
return newParams;
}
function normalizeRouteRecord(record) {
return {
path: record.path,
redirect: record.redirect,
name: record.name,
meta: record.meta || {},
aliasOf: void 0,
beforeEnter: record.beforeEnter,
props: normalizeRecordProps(record),
children: record.children || [],
instances: {},
leaveGuards: /* @__PURE__ */ new Set(),
updateGuards: /* @__PURE__ */ new Set(),
enterCallbacks: {},
components: "components" in record ? record.components || null : record.component && { default: record.component }
};
}
function normalizeRecordProps(record) {
const propsObject = {};
const props = record.props || false;
if ("component" in record) {
propsObject.default = props;
} else {
for (const name2 in record.components)
propsObject[name2] = typeof props === "object" ? props[name2] : props;
}
return propsObject;
}
function isAliasRecord(record) {
while (record) {
if (record.record.aliasOf)
return true;
record = record.parent;
}
return false;
}
function mergeMetaFields(matched) {
return matched.reduce((meta2, record) => assign$1(meta2, record.meta), {});
}
function mergeOptions(defaults2, partialOptions) {
const options = {};
for (const key2 in defaults2) {
options[key2] = key2 in partialOptions ? partialOptions[key2] : defaults2[key2];
}
return options;
}
function findInsertionIndex(matcher, matchers) {
let lower = 0;
let upper = matchers.length;
while (lower !== upper) {
const mid = lower + upper >> 1;
const sortOrder = comparePathParserScore(matcher, matchers[mid]);
if (sortOrder < 0) {
upper = mid;
} else {
lower = mid + 1;
}
}
const insertionAncestor = getInsertionAncestor(matcher);
if (insertionAncestor) {
upper = matchers.lastIndexOf(insertionAncestor, upper - 1);
}
return upper;
}
function getInsertionAncestor(matcher) {
let ancestor = matcher;
while (ancestor = ancestor.parent) {
if (isMatchable(ancestor) && comparePathParserScore(matcher, ancestor) === 0) {
return ancestor;
}
}
return;
}
function isMatchable({ record }) {
return !!(record.name || record.components && Object.keys(record.components).length || record.redirect);
}
function parseQuery$1(search2) {
const query = {};
if (search2 === "" || search2 === "?")
return query;
const hasLeadingIM = search2[0] === "?";
const searchParams = (hasLeadingIM ? search2.slice(1) : search2).split("&");
for (let i2 = 0; i2 < searchParams.length; ++i2) {
const searchParam = searchParams[i2].replace(PLUS_RE, " ");
const eqPos = searchParam.indexOf("=");
const key2 = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
if (key2 in query) {
let currentValue = query[key2];
if (!isArray$2(currentValue)) {
currentValue = query[key2] = [currentValue];
}
currentValue.push(value);
} else {
query[key2] = value;
}
}
return query;
}
function stringifyQuery(query) {
let search2 = "";
for (let key2 in query) {
const value = query[key2];
key2 = encodeQueryKey(key2);
if (value == null) {
if (value !== void 0) {
search2 += (search2.length ? "&" : "") + key2;
}
continue;
}
const values2 = isArray$2(value) ? value.map((v2) => v2 && encodeQueryValue(v2)) : [value && encodeQueryValue(value)];
values2.forEach((value2) => {
if (value2 !== void 0) {
search2 += (search2.length ? "&" : "") + key2;
if (value2 != null)
search2 += "=" + value2;
}
});
}
return search2;
}
function normalizeQuery(query) {
const normalizedQuery = {};
for (const key2 in query) {
const value = query[key2];
if (value !== void 0) {
normalizedQuery[key2] = isArray$2(value) ? value.map((v2) => v2 == null ? null : "" + v2) : value == null ? value : "" + value;
}
}
return normalizedQuery;
}
const matchedRouteKey = Symbol("");
const viewDepthKey = Symbol("");
const routerKey = Symbol("");
const routeLocationKey = Symbol("");
const routerViewLocationKey = Symbol("");
function useCallbacks() {
let handlers2 = [];
function add2(handler) {
handlers2.push(handler);
return () => {
const i2 = handlers2.indexOf(handler);
if (i2 > -1)
handlers2.splice(i2, 1);
};
}
function reset() {
handlers2 = [];
}
return {
add: add2,
list: () => handlers2.slice(),
reset
};
}
function guardToPromiseFn(guard, to2, from, record, name2, runWithContext = (fn) => fn()) {
const enterCallbackArray = record && // name is defined if record is because of the function overload
(record.enterCallbacks[name2] = record.enterCallbacks[name2] || []);
return () => new Promise((resolve2, reject) => {
const next = (valid2) => {
if (valid2 === false) {
reject(createRouterError(4, {
from,
to: to2
}));
} else if (valid2 instanceof Error) {
reject(valid2);
} else if (isRouteLocation(valid2)) {
reject(createRouterError(2, {
from: to2,
to: valid2
}));
} else {
if (enterCallbackArray && // since enterCallbackArray is truthy, both record and name also are
record.enterCallbacks[name2] === enterCallbackArray && typeof valid2 === "function") {
enterCallbackArray.push(valid2);
}
resolve2();
}
};
const guardReturn = runWithContext(() => guard.call(record && record.instances[name2], to2, from, next));
let guardCall = Promise.resolve(guardReturn);
if (guard.length < 3)
guardCall = guardCall.then(next);
guardCall.catch((err) => reject(err));
});
}
function extractComponentsGuards(matched, guardType, to2, from, runWithContext = (fn) => fn()) {
const guards = [];
for (const record of matched) {
for (const name2 in record.components) {
let rawComponent = record.components[name2];
if (guardType !== "beforeRouteEnter" && !record.instances[name2])
continue;
if (isRouteComponent(rawComponent)) {
const options = rawComponent.__vccOpts || rawComponent;
const guard = options[guardType];
guard && guards.push(guardToPromiseFn(guard, to2, from, record, name2, runWithContext));
} else {
let componentPromise = rawComponent();
guards.push(() => componentPromise.then((resolved) => {
if (!resolved)
return Promise.reject(new Error(`Couldn't resolve component "${name2}" at "${record.path}"`));
const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
record.components[name2] = resolvedComponent;
const options = resolvedComponent.__vccOpts || resolvedComponent;
const guard = options[guardType];
return guard && guardToPromiseFn(guard, to2, from, record, name2, runWithContext)();
}));
}
}
}
return guards;
}
function isRouteComponent(component) {
return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
}
function useLink(props) {
const router2 = inject(routerKey);
const currentRoute = inject(routeLocationKey);
const route = computed(() => {
const to2 = unref(props.to);
return router2.resolve(to2);
});
const activeRecordIndex = computed(() => {
const { matched } = route.value;
const { length } = matched;
const routeMatched = matched[length - 1];
const currentMatched = currentRoute.matched;
if (!routeMatched || !currentMatched.length)
return -1;
const index2 = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
if (index2 > -1)
return index2;
const parentRecordPath = getOriginalPath(matched[length - 2]);
return (
// we are dealing with nested routes
length > 1 && // if the parent and matched route have the same path, this link is
// referring to the empty child. Or we currently are on a different
// child of the same parent
getOriginalPath(routeMatched) === parentRecordPath && // avoid comparing the child with its parent
currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index2
);
});
const isActive = computed(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
const isExactActive = computed(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
function navigate(e2 = {}) {
if (guardEvent(e2)) {
return router2[unref(props.replace) ? "replace" : "push"](
unref(props.to)
// avoid uncaught errors are they are logged anyway
).catch(noop$1);
}
return Promise.resolve();
}
return {
route,
href: computed(() => route.value.href),
isActive,
isExactActive,
navigate
};
}
const RouterLinkImpl = /* @__PURE__ */ defineComponent({
name: "RouterLink",
compatConfig: { MODE: 3 },
props: {
to: {
type: [String, Object],
required: true
},
replace: Boolean,
activeClass: String,
// inactiveClass: String,
exactActiveClass: String,
custom: Boolean,
ariaCurrentValue: {
type: String,
default: "page"
}
},
useLink,
setup(props, { slots }) {
const link = reactive(useLink(props));
const { options } = inject(routerKey);
const elClass = computed(() => ({
[getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
// [getLinkClass(
// props.inactiveClass,
// options.linkInactiveClass,
// 'router-link-inactive'
// )]: !link.isExactActive,
[getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
}));
return () => {
const children = slots.default && slots.default(link);
return props.custom ? children : h$9("a", {
"aria-current": link.isExactActive ? props.ariaCurrentValue : null,
href: link.href,
// this would override user added attrs but Vue will still add
// the listener, so we end up triggering both
onClick: link.navigate,
class: elClass.value
}, children);
};
}
});
const RouterLink = RouterLinkImpl;
function guardEvent(e2) {
if (e2.metaKey || e2.altKey || e2.ctrlKey || e2.shiftKey)
return;
if (e2.defaultPrevented)
return;
if (e2.button !== void 0 && e2.button !== 0)
return;
if (e2.currentTarget && e2.currentTarget.getAttribute) {
const target = e2.currentTarget.getAttribute("target");
if (/\b_blank\b/i.test(target))
return;
}
if (e2.preventDefault)
e2.preventDefault();
return true;
}
function includesParams(outer, inner) {
for (const key2 in inner) {
const innerValue = inner[key2];
const outerValue = outer[key2];
if (typeof innerValue === "string") {
if (innerValue !== outerValue)
return false;
} else {
if (!isArray$2(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i2) => value !== outerValue[i2]))
return false;
}
}
return true;
}
function getOriginalPath(record) {
return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
}
const getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
const RouterViewImpl = /* @__PURE__ */ defineComponent({
name: "RouterView",
// #674 we manually inherit them
inheritAttrs: false,
props: {
name: {
type: String,
default: "default"
},
route: Object
},
// Better compat for @vue/compat users
// https://github.com/vuejs/router/issues/1315
compatConfig: { MODE: 3 },
setup(props, { attrs, slots }) {
const injectedRoute = inject(routerViewLocationKey);
const routeToDisplay = computed(() => props.route || injectedRoute.value);
const injectedDepth = inject(viewDepthKey, 0);
const depth = computed(() => {
let initialDepth = unref(injectedDepth);
const { matched } = routeToDisplay.value;
let matchedRoute;
while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) {
initialDepth++;
}
return initialDepth;
});
const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
provide(viewDepthKey, computed(() => depth.value + 1));
provide(matchedRouteKey, matchedRouteRef);
provide(routerViewLocationKey, routeToDisplay);
const viewRef = ref();
watch(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to2, name2], [oldInstance, from, oldName]) => {
if (to2) {
to2.instances[name2] = instance;
if (from && from !== to2 && instance && instance === oldInstance) {
if (!to2.leaveGuards.size) {
to2.leaveGuards = from.leaveGuards;
}
if (!to2.updateGuards.size) {
to2.updateGuards = from.updateGuards;
}
}
}
if (instance && to2 && // if there is no instance but to and from are the same this might be
// the first visit
(!from || !isSameRouteRecord(to2, from) || !oldInstance)) {
(to2.enterCallbacks[name2] || []).forEach((callback) => callback(instance));
}
}, { flush: "post" });
return () => {
const route = routeToDisplay.value;
const currentName = props.name;
const matchedRoute = matchedRouteRef.value;
const ViewComponent = matchedRoute && matchedRoute.components[currentName];
if (!ViewComponent) {
return normalizeSlot(slots.default, { Component: ViewComponent, route });
}
const routePropsOption = matchedRoute.props[currentName];
const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
const onVnodeUnmounted = (vnode) => {
if (vnode.component.isUnmounted) {
matchedRoute.instances[currentName] = null;
}
};
const component = h$9(ViewComponent, assign$1({}, routeProps, attrs, {
onVnodeUnmounted,
ref: viewRef
}));
return (
// pass the vnode to the slot as a prop.
// h and <component :is="..."> both accept vnodes
normalizeSlot(slots.default, { Component: component, route }) || component
);
};
}
});
function normalizeSlot(slot, data) {
if (!slot)
return null;
const slotContent = slot(data);
return slotContent.length === 1 ? slotContent[0] : slotContent;
}
const RouterView = RouterViewImpl;
function createRouter(options) {
const matcher = createRouterMatcher(options.routes, options);
const parseQuery$1$1 = options.parseQuery || parseQuery$1;
const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
const routerHistory = options.history;
const beforeGuards = useCallbacks();
const beforeResolveGuards = useCallbacks();
const afterGuards = useCallbacks();
const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
let pendingLocation = START_LOCATION_NORMALIZED;
if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) {
history.scrollRestoration = "manual";
}
const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
const encodeParams = applyToParams.bind(null, encodeParam);
const decodeParams = (
// @ts-expect-error: intentionally avoid the type check
applyToParams.bind(null, decode)
);
function addRoute(parentOrRoute, route) {
let parent;
let record;
if (isRouteName(parentOrRoute)) {
parent = matcher.getRecordMatcher(parentOrRoute);
record = route;
} else {
record = parentOrRoute;
}
return matcher.addRoute(record, parent);
}
function removeRoute(name2) {
const recordMatcher = matcher.getRecordMatcher(name2);
if (recordMatcher) {
matcher.removeRoute(recordMatcher);
}
}
function getRoutes() {
return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
}
function hasRoute(name2) {
return !!matcher.getRecordMatcher(name2);
}
function resolve2(rawLocation, currentLocation) {
currentLocation = assign$1({}, currentLocation || currentRoute.value);
if (typeof rawLocation === "string") {
const locationNormalized = parseURL(parseQuery$1$1, rawLocation, currentLocation.path);
const matchedRoute2 = matcher.resolve({ path: locationNormalized.path }, currentLocation);
const href2 = routerHistory.createHref(locationNormalized.fullPath);
return assign$1(locationNormalized, matchedRoute2, {
params: decodeParams(matchedRoute2.params),
hash: decode(locationNormalized.hash),
redirectedFrom: void 0,
href: href2
});
}
let matcherLocation;
if (rawLocation.path != null) {
matcherLocation = assign$1({}, rawLocation, {
path: parseURL(parseQuery$1$1, rawLocation.path, currentLocation.path).path
});
} else {
const targetParams = assign$1({}, rawLocation.params);
for (const key2 in targetParams) {
if (targetParams[key2] == null) {
delete targetParams[key2];
}
}
matcherLocation = assign$1({}, rawLocation, {
params: encodeParams(targetParams)
});
currentLocation.params = encodeParams(currentLocation.params);
}
const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
const hash2 = rawLocation.hash || "";
matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
const fullPath = stringifyURL(stringifyQuery$1, assign$1({}, rawLocation, {
hash: encodeHash(hash2),
path: matchedRoute.path
}));
const href = routerHistory.createHref(fullPath);
return assign$1({
fullPath,
// keep the hash encoded so fullPath is effectively path + encodedQuery +
// hash
hash: hash2,
query: (
// if the user is using a custom query lib like qs, we might have
// nested objects, so we keep the query as is, meaning it can contain
// numbers at `$route.query`, but at the point, the user will have to
// use their own type anyway.
// https://github.com/vuejs/router/issues/328#issuecomment-649481567
stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
)
}, matchedRoute, {
redirectedFrom: void 0,
href
});
}
function locationAsObject(to2) {
return typeof to2 === "string" ? parseURL(parseQuery$1$1, to2, currentRoute.value.path) : assign$1({}, to2);
}
function checkCanceledNavigation(to2, from) {
if (pendingLocation !== to2) {
return createRouterError(8, {
from,
to: to2
});
}
}
function push(to2) {
return pushWithRedirect(to2);
}
function replace(to2) {
return push(assign$1(locationAsObject(to2), { replace: true }));
}
function handleRedirectRecord(to2) {
const lastMatched = to2.matched[to2.matched.length - 1];
if (lastMatched && lastMatched.redirect) {
const { redirect } = lastMatched;
let newTargetLocation = typeof redirect === "function" ? redirect(to2) : redirect;
if (typeof newTargetLocation === "string") {
newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : (
// force empty params
{ path: newTargetLocation }
);
newTargetLocation.params = {};
}
return assign$1({
query: to2.query,
hash: to2.hash,
// avoid transferring params if the redirect has a path
params: newTargetLocation.path != null ? {} : to2.params
}, newTargetLocation);
}
}
function pushWithRedirect(to2, redirectedFrom) {
const targetLocation = pendingLocation = resolve2(to2);
const from = currentRoute.value;
const data = to2.state;
const force = to2.force;
const replace2 = to2.replace === true;
const shouldRedirect = handleRedirectRecord(targetLocation);
if (shouldRedirect)
return pushWithRedirect(
assign$1(locationAsObject(shouldRedirect), {
state: typeof shouldRedirect === "object" ? assign$1({}, data, shouldRedirect.state) : data,
force,
replace: replace2
}),
// keep original redirectedFrom if it exists
redirectedFrom || targetLocation
);
const toLocation = targetLocation;
toLocation.redirectedFrom = redirectedFrom;
let failure;
if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
failure = createRouterError(16, { to: toLocation, from });
handleScroll(
from,
from,
// this is a push, the only way for it to be triggered from a
// history.listen is with a redirect, which makes it become a push
true,
// This cannot be the first navigation because the initial location
// cannot be manually navigated to
false
);
}
return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error2) => isNavigationFailure(error2) ? (
// navigation redirects still mark the router as ready
isNavigationFailure(
error2,
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
) ? error2 : markAsReady(error2)
) : (
// reject any unknown error
triggerError(error2, toLocation, from)
)).then((failure2) => {
if (failure2) {
if (isNavigationFailure(
failure2,
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
)) {
return pushWithRedirect(
// keep options
assign$1({
// preserve an existing replacement but allow the redirect to override it
replace: replace2
}, locationAsObject(failure2.to), {
state: typeof failure2.to === "object" ? assign$1({}, data, failure2.to.state) : data,
force
}),
// preserve the original redirectedFrom if any
redirectedFrom || toLocation
);
}
} else {
failure2 = finalizeNavigation(toLocation, from, true, replace2, data);
}
triggerAfterEach(toLocation, from, failure2);
return failure2;
});
}
function checkCanceledNavigationAndReject(to2, from) {
const error2 = checkCanceledNavigation(to2, from);
return error2 ? Promise.reject(error2) : Promise.resolve();
}
function runWithContext(fn) {
const app = installedApps.values().next().value;
return app && typeof app.runWithContext === "function" ? app.runWithContext(fn) : fn();
}
function navigate(to2, from) {
let guards;
const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to2, from);
guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to2, from);
for (const record of leavingRecords) {
record.leaveGuards.forEach((guard) => {
guards.push(guardToPromiseFn(guard, to2, from));
});
}
const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to2, from);
guards.push(canceledNavigationCheck);
return runGuardQueue(guards).then(() => {
guards = [];
for (const guard of beforeGuards.list()) {
guards.push(guardToPromiseFn(guard, to2, from));
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to2, from);
for (const record of updatingRecords) {
record.updateGuards.forEach((guard) => {
guards.push(guardToPromiseFn(guard, to2, from));
});
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
guards = [];
for (const record of enteringRecords) {
if (record.beforeEnter) {
if (isArray$2(record.beforeEnter)) {
for (const beforeEnter of record.beforeEnter)
guards.push(guardToPromiseFn(beforeEnter, to2, from));
} else {
guards.push(guardToPromiseFn(record.beforeEnter, to2, from));
}
}
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
to2.matched.forEach((record) => record.enterCallbacks = {});
guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to2, from, runWithContext);
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
guards = [];
for (const guard of beforeResolveGuards.list()) {
guards.push(guardToPromiseFn(guard, to2, from));
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).catch((err) => isNavigationFailure(
err,
8
/* ErrorTypes.NAVIGATION_CANCELLED */
) ? err : Promise.reject(err));
}
function triggerAfterEach(to2, from, failure) {
afterGuards.list().forEach((guard) => runWithContext(() => guard(to2, from, failure)));
}
function finalizeNavigation(toLocation, from, isPush, replace2, data) {
const error2 = checkCanceledNavigation(toLocation, from);
if (error2)
return error2;
const isFirstNavigation = from === START_LOCATION_NORMALIZED;
const state = !isBrowser ? {} : history.state;
if (isPush) {
if (replace2 || isFirstNavigation)
routerHistory.replace(toLocation.fullPath, assign$1({
scroll: isFirstNavigation && state && state.scroll
}, data));
else
routerHistory.push(toLocation.fullPath, data);
}
currentRoute.value = toLocation;
handleScroll(toLocation, from, isPush, isFirstNavigation);
markAsReady();
}
let removeHistoryListener;
function setupListeners() {
if (removeHistoryListener)
return;
removeHistoryListener = routerHistory.listen((to2, _from, info) => {
if (!router2.listening)
return;
const toLocation = resolve2(to2);
const shouldRedirect = handleRedirectRecord(toLocation);
if (shouldRedirect) {
pushWithRedirect(assign$1(shouldRedirect, { replace: true }), toLocation).catch(noop$1);
return;
}
pendingLocation = toLocation;
const from = currentRoute.value;
if (isBrowser) {
saveScrollPosition(getScrollKey(from.fullPath, info.delta), computeScrollPosition());
}
navigate(toLocation, from).catch((error2) => {
if (isNavigationFailure(
error2,
4 | 8
/* ErrorTypes.NAVIGATION_CANCELLED */
)) {
return error2;
}
if (isNavigationFailure(
error2,
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
)) {
pushWithRedirect(
error2.to,
toLocation
// avoid an uncaught rejection, let push call triggerError
).then((failure) => {
if (isNavigationFailure(
failure,
4 | 16
/* ErrorTypes.NAVIGATION_DUPLICATED */
) && !info.delta && info.type === NavigationType.pop) {
routerHistory.go(-1, false);
}
}).catch(noop$1);
return Promise.reject();
}
if (info.delta) {
routerHistory.go(-info.delta, false);
}
return triggerError(error2, toLocation, from);
}).then((failure) => {
failure = failure || finalizeNavigation(
// after navigation, all matched components are resolved
toLocation,
from,
false
);
if (failure) {
if (info.delta && // a new navigation has been triggered, so we do not want to revert, that will change the current history
// entry while a different route is displayed
!isNavigationFailure(
failure,
8
/* ErrorTypes.NAVIGATION_CANCELLED */
)) {
routerHistory.go(-info.delta, false);
} else if (info.type === NavigationType.pop && isNavigationFailure(
failure,
4 | 16
/* ErrorTypes.NAVIGATION_DUPLICATED */
)) {
routerHistory.go(-1, false);
}
}
triggerAfterEach(toLocation, from, failure);
}).catch(noop$1);
});
}
let readyHandlers = useCallbacks();
let errorListeners = useCallbacks();
let ready;
function triggerError(error2, to2, from) {
markAsReady(error2);
const list = errorListeners.list();
if (list.length) {
list.forEach((handler) => handler(error2, to2, from));
} else {
console.error(error2);
}
return Promise.reject(error2);
}
function isReady() {
if (ready && currentRoute.value !== START_LOCATION_NORMALIZED)
return Promise.resolve();
return new Promise((resolve22, reject) => {
readyHandlers.add([resolve22, reject]);
});
}
function markAsReady(err) {
if (!ready) {
ready = !err;
setupListeners();
readyHandlers.list().forEach(([resolve22, reject]) => err ? reject(err) : resolve22());
readyHandlers.reset();
}
return err;
}
function handleScroll(to2, from, isPush, isFirstNavigation) {
const { scrollBehavior } = options;
if (!isBrowser || !scrollBehavior)
return Promise.resolve();
const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to2.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
return nextTick().then(() => scrollBehavior(to2, from, scrollPosition)).then((position2) => position2 && scrollToPosition(position2)).catch((err) => triggerError(err, to2, from));
}
const go2 = (delta) => routerHistory.go(delta);
let started;
const installedApps = /* @__PURE__ */ new Set();
const router2 = {
currentRoute,
listening: true,
addRoute,
removeRoute,
hasRoute,
getRoutes,
resolve: resolve2,
options,
push,
replace,
go: go2,
back: () => go2(-1),
forward: () => go2(1),
beforeEach: beforeGuards.add,
beforeResolve: beforeResolveGuards.add,
afterEach: afterGuards.add,
onError: errorListeners.add,
isReady,
install(app) {
const router22 = this;
app.component("RouterLink", RouterLink);
app.component("RouterView", RouterView);
app.config.globalProperties.$router = router22;
Object.defineProperty(app.config.globalProperties, "$route", {
enumerable: true,
get: () => unref(currentRoute)
});
if (isBrowser && // used for the initial navigation client side to avoid pushing
// multiple times when the router is used in multiple apps
!started && currentRoute.value === START_LOCATION_NORMALIZED) {
started = true;
push(routerHistory.location).catch((err) => {
});
}
const reactiveRoute = {};
for (const key2 in START_LOCATION_NORMALIZED) {
Object.defineProperty(reactiveRoute, key2, {
get: () => currentRoute.value[key2],
enumerable: true
});
}
app.provide(routerKey, router22);
app.provide(routeLocationKey, shallowReactive(reactiveRoute));
app.provide(routerViewLocationKey, currentRoute);
const unmountApp = app.unmount;
installedApps.add(app);
app.unmount = function() {
installedApps.delete(app);
if (installedApps.size < 1) {
pendingLocation = START_LOCATION_NORMALIZED;
removeHistoryListener && removeHistoryListener();
removeHistoryListener = null;
currentRoute.value = START_LOCATION_NORMALIZED;
started = false;
ready = false;
}
unmountApp();
};
}
};
function runGuardQueue(guards) {
return guards.reduce((promise, guard) => promise.then(() => runWithContext(guard)), Promise.resolve());
}
return router2;
}
function extractChangingRecords(to2, from) {
const leavingRecords = [];
const updatingRecords = [];
const enteringRecords = [];
const len = Math.max(from.matched.length, to2.matched.length);
for (let i2 = 0; i2 < len; i2++) {
const recordFrom = from.matched[i2];
if (recordFrom) {
if (to2.matched.find((record) => isSameRouteRecord(record, recordFrom)))
updatingRecords.push(recordFrom);
else
leavingRecords.push(recordFrom);
}
const recordTo = to2.matched[i2];
if (recordTo) {
if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) {
enteringRecords.push(recordTo);
}
}
}
return [leavingRecords, updatingRecords, enteringRecords];
}
function useRouter() {
return inject(routerKey);
}
function useRoute() {
return inject(routeLocationKey);
}
var PathId = /* @__PURE__ */ ((PathId2) => {
PathId2["Request"] = "request";
PathId2["Examples"] = "examples";
PathId2["Cookies"] = "cookies";
PathId2["Collection"] = "collection";
PathId2["Schema"] = "schema";
PathId2["Environment"] = "environment";
PathId2["Servers"] = "servers";
PathId2["Workspace"] = "workspace";
PathId2["Settings"] = "settings";
return PathId2;
})(PathId || {});
const requestRoutes = [
{
path: "",
redirect: (to2) => `${to2.fullPath.replace(/\/$/, "")}/request/default`
},
{
path: "request",
redirect: (to2) => `${to2.fullPath.replace(/\/$/, "")}/default`
},
{
name: "request",
path: `request/:${"request"}`,
component: () => Promise.resolve().then(() => Request$1)
},
{
name: "examples",
path: `request/:${"request"}/examples/:${"examples"}`,
component: () => Promise.resolve().then(() => Request$1)
}
];
const modalRoutes = [
{
path: "/",
redirect: "/workspace/default/request/default"
},
{
path: "/workspace",
redirect: "/workspace/default/request/default"
},
{
path: `/workspace/:${"workspace"}`,
children: requestRoutes
}
];
const routes = [
{
path: "/",
redirect: redirectToDefaultWorkspace
},
{
path: "/workspace",
redirect: redirectToDefaultWorkspace
},
{
path: `/workspace/:${"workspace"}`,
children: [
...requestRoutes,
// {
// path: 'collection',
// redirect: (to) =>
// `${to.fullPath.replace(/\/$/, '')}/default`,
// },
// {
// name: PathId.Collection,
// path: `collection/:${PathId.Collection}`,
// component: () => import('@/views/Collection/Collection.vue'),
// children: [
// // Nested collection request
// {
// path: `request/${PathId.Request}`,
// component: () => import('@/views/Request/Request.vue'),
// },
// ],
// },
/** Components will map to each section of the spec components object */
// {
// path: 'components',
// redirect: '/components/schemas/default',
// children: [
// {
// path: `schemas/:${PathId.Schema}`,
// component: () => import('@/views/Components/Schemas/Schemas.vue'),
// },
// ],
// },
{
path: "environment",
redirect: (to2) => `${to2.fullPath.replace(/\/$/, "")}/default`
},
{
name: "environment",
path: `environment/:${"environment"}`,
component: () => Promise.resolve().then(() => Environment)
},
{
path: "cookies",
redirect: (to2) => `${to2.fullPath.replace(/\/$/, "")}/default`
},
{
name: "cookies",
path: `cookies/:${"cookies"}`,
component: () => Promise.resolve().then(() => Cookies)
},
{
path: "servers",
redirect: (to2) => `${to2.fullPath.replace(/\/$/, "")}/default`
},
{
name: "servers",
path: `servers/:${"servers"}`,
component: () => Promise.resolve().then(() => Servers)
},
{
path: "settings",
redirect: (to2) => `${to2.fullPath.replace(/\/$/, "")}/general`
},
{
name: "settings",
path: `settings/:${"settings"}`,
component: () => Promise.resolve().then(() => Settings)
}
]
}
];
const router = createRouter({
history: createWebHistory(),
routes
});
const createModalRouter = () => createRouter({
history: createMemoryHistory(),
routes: modalRoutes
});
const WORKSPACE_KEY = "activeWorkspace";
function redirectToDefaultWorkspace() {
const workspace = localStorage.getItem(WORKSPACE_KEY) ?? "default";
return `/workspace/${workspace}/request/default`;
}
function fallbackMissingParams(key2, item) {
var _a2, _b;
if (router.currentRoute.value && // If the item is missing then we know the UID is no longer in use and redirect to the default
!item && ((_a2 = router.currentRoute.value) == null ? void 0 : _a2.params[key2]) && ((_b = router.currentRoute.value) == null ? void 0 : _b.params[key2]) !== "default" && // We only redirect if the key is missing for the matching route
router.currentRoute.value.path.includes(key2)) {
router.push({
params: {
...router.currentRoute.value.params,
[key2]: "default"
}
});
}
}
function setNestedValue(obj, path2, value) {
const keys2 = path2.split(".");
keys2.reduce((acc, current, idx) => {
if (idx === keys2.length - 1)
acc[current] = value;
return acc[current];
}, obj);
return obj;
}
function getNestedValue(obj, path2) {
const keys2 = path2.split(".");
return keys2.reduce((acc, current) => {
return acc[current];
}, obj);
}
class Mutation {
constructor(parentData, maxRecords = 5e3, debug = false) {
/** Object reference for the given data to be tracked */
__publicField(this, "parentData");
/** Maximum number of record to keep (how many times you can 'undo' a mutation) */
__publicField(this, "maxRecords");
/** List of all mutation records */
__publicField(this, "records", []);
/** List of side effect handlers to run whenever the data changes */
__publicField(this, "sideEffects", []);
/** Active mutation index. Allows rolling forward and backwards */
__publicField(this, "idx", 0);
/** Optional debug messages */
__publicField(this, "debug");
this.maxRecords = maxRecords;
this.parentData = parentData;
this.debug = debug;
}
/** Mutate without saving a record. Private function. */
_unsavedMutate(path2, value) {
setNestedValue(this.parentData, path2, value);
this.runSideEffects(path2);
}
/** Side effects must take ONLY an object of the specified type and act on it */
addSideEffect(triggers, effect, name2, immediate = true) {
this.sideEffects.push({ triggers, effect, name: name2 });
if (immediate) {
effect(this.parentData);
if (this.debug) {
console.info(`Running mutation side effect: ${name2}`, "debug");
}
}
}
/** Runs all side effects that match the path trigger */
runSideEffects(path2) {
this.sideEffects.forEach(({ effect, triggers, name: name2 }) => {
const triggerEffect = triggers.some((trigger2) => path2.includes(trigger2)) || path2.length < 1;
if (triggerEffect) {
effect(this.parentData);
if (this.debug) {
console.info(`Running mutation side effect: ${name2}`, "debug");
}
}
});
}
/** Mutate an object with the new property value and run side effects */
mutate(path2, value, previousValue = null) {
if (this.idx < this.records.length - 1)
this.records.splice(this.idx + 1);
const prev = getNestedValue(this.parentData, path2);
if (prev === value)
return;
setNestedValue(this.parentData, path2, value);
this.runSideEffects(path2);
this.records.push({
prev: previousValue ?? prev,
// Optional explicit previous value
value,
path: path2
});
this.idx = this.records.length - 1;
if (this.records.length > this.maxRecords)
this.records.shift();
if (this.debug) {
console.info(`Set object '${this.idx}' '${path2}' to ${value}`, "debug");
}
}
/** Undo the previous mutation */
undo() {
if (this.idx < 0 || this.records.length < 1)
return false;
if (this.debug)
console.info("Undoing Mutation", "debug");
const record = this.records[this.idx];
this.idx -= 1;
this._unsavedMutate(record.path, record.prev);
return true;
}
/** Roll forward to the next available mutation if its exists */
redo() {
if (this.idx > this.records.length - 2)
return false;
if (this.debug)
console.info("Redoing Mutation", "debug");
const record = this.records[this.idx + 1];
this.idx += 1;
this._unsavedMutate(record.path, record.value);
return true;
}
}
const LS_CONFIG = {
/** The debounce time in milliseconds for saving to localStorage per resource */
DEBOUNCE_MS: 328,
/** The max wait time in milliseconds for saving to localStorage per resource */
MAX_WAIT_MS: 1e3
};
function debounce(fn, wait, { maxWait } = {}) {
let timer = null;
let maxTimer = null;
return function(...args) {
if (timer)
clearTimeout(timer);
timer = setTimeout(() => {
maxTimer !== null ? clearTimeout(maxTimer) : null;
maxTimer = null;
fn.apply(this, args);
}, wait);
if (maxWait && !maxTimer)
maxTimer = setTimeout(() => {
timer !== null ? clearTimeout(timer) : null;
maxTimer = null;
fn.apply(this, args);
}, maxWait);
};
}
const MAX_MUTATION_RECORDS = 500;
function mutationFactory(entityMap, mutationMap, localStorageKey, maxNumberRecords = MAX_MUTATION_RECORDS) {
function getMutator(uid2) {
const mutator = mutationMap[uid2];
if (!mutator)
console.warn(`Missing ${entityMap[uid2] ? "mutator" : "object"} for uid: ${uid2}`);
return mutator ?? null;
}
const onChange = localStorageKey ? debounce(() => localStorage.setItem(localStorageKey, stringify$2(entityMap)), LS_CONFIG.DEBOUNCE_MS, { maxWait: LS_CONFIG.MAX_WAIT_MS }) : () => null;
const add2 = (item) => {
entityMap[item.uid] = item;
mutationMap[item.uid] = new Mutation(item, maxNumberRecords);
onChange();
};
return {
/** Adds a new item to the record of tracked items and creates a new mutation tracking instance */
add: add2,
delete: (uid2) => {
delete entityMap[uid2];
delete mutationMap[uid2];
onChange();
},
/** Destructive, overwrites a record to a new item and creates a new mutation tracking instance */
set: (item) => {
entityMap[item.uid] = item;
mutationMap[item.uid] = new Mutation(item, maxNumberRecords);
onChange();
},
/** Update a nested property and track the mutation */
edit: (uid2, path2, value) => {
const mutator = getMutator(uid2);
mutator == null ? void 0 : mutator.mutate(path2, value);
onChange();
},
/** Commit an untracked edit to the object (undo/redo will not work) */
untrackedEdit: (uid2, path2, value) => {
const mutator = getMutator(uid2);
mutator == null ? void 0 : mutator._unsavedMutate(path2, value);
onChange();
},
/** Undo the last mutation */
undo: (uid2) => {
const mutator = getMutator(uid2);
mutator == null ? void 0 : mutator.undo();
onChange();
},
/** Redo a mutation if available */
redo: (uid2) => {
const mutator = getMutator(uid2);
mutator == null ? void 0 : mutator.redo();
onChange();
}
};
}
function createStoreCollections(useLocalStorage) {
const collections = reactive({});
const collectionMutators = mutationFactory(
collections,
reactive({}),
useLocalStorage && LS_KEYS.COLLECTION
);
return {
collections,
collectionMutators
};
}
function extendedCollectionDataFactory({
requests,
requestMutators,
requestExamples,
requestExampleMutators,
workspaces,
workspaceMutators,
collections,
collectionMutators,
tagMutators
}) {
const addCollection = (payload, workspaceUid) => {
const collection = collectionSchema.parse(payload);
workspaceMutators.edit(workspaceUid, "collections", [
...workspaces[workspaceUid].collections,
collection.uid
]);
collectionMutators.add(collection);
return collection;
};
const deleteCollection = (collection, workspace) => {
var _a2, _b;
if (!workspace.uid) return;
if (((_b = (_a2 = collections[collection.uid]) == null ? void 0 : _a2.info) == null ? void 0 : _b.title) === "Drafts") {
console.warn("The drafts collection cannot be deleted");
return;
}
if (Object.values(collections).length === 1) {
console.warn("You must have at least one collection");
return;
}
collection.tags.forEach((uid2) => tagMutators.delete(uid2));
collection.requests.forEach((uid2) => {
const request = requests[uid2];
if (!request) return;
requestMutators.delete(uid2);
request.examples.forEach(
(e2) => requestExamples[e2] && requestExampleMutators.delete(e2)
);
});
workspaceMutators.edit(
workspace.uid,
"collections",
workspace.collections.filter((uid2) => uid2 !== collection.uid)
);
collectionMutators.delete(collection.uid);
};
return {
addCollection,
deleteCollection
};
}
function createStoreCookies(useLocalStorage) {
const cookies = reactive({});
const cookieMutators = mutationFactory(
cookies,
reactive({}),
useLocalStorage && LS_KEYS.COOKIE
);
cookieMutators.add(
cookieSchema.parse({
uid: "default",
name: "Cookie",
value: "",
domain: "",
path: "/",
secure: false,
httpOnly: false,
sameSite: "None"
})
);
return {
cookies,
cookieMutators
};
}
function createStoreEnvironments(useLocalStorage) {
const environments = reactive({});
const environmentMutators = mutationFactory(
environments,
reactive({}),
useLocalStorage && LS_KEYS.ENVIRONMENT
);
environmentMutators.add(
environmentSchema.parse({
uid: "default",
name: "Global Environment",
color: "blue",
raw: JSON.stringify({ exampleKey: "exampleValue" }, null, 2),
parsed: [],
isDefault: true
})
);
return {
environments,
environmentMutators
};
}
function extendedEnvironmentDataFactory({
environmentMutators
}) {
const deleteEnvironment = (uid2) => {
if (uid2 === "default") {
console.warn("Default environment cannot be deleted.");
return;
}
environmentMutators.delete(uid2);
};
return { deleteEnvironment };
}
function createEventBus() {
const listeners = /* @__PURE__ */ new Set();
function on(listener) {
listeners.add(listener);
const _off = () => off(listener);
return _off;
}
function once(listener) {
function _listener(...args) {
off(_listener);
listener(...args);
}
return on(_listener);
}
function off(listener) {
listeners.delete(listener);
}
function reset() {
listeners.clear();
}
function emit2(payload) {
listeners == null ? void 0 : listeners.forEach((v2) => v2(payload));
}
return {
on,
once,
off,
emit: emit2,
reset,
listeners: () => Array.from(listeners)
};
}
function createStoreEvents() {
return {
/**
* Event bus to execute requests, usually triggered by the send button in the address bar
* OR the keyboard shortcut
*/
executeRequest: createEventBus(),
/**
* Event bus to cancel requests, usually triggered by response loading overlay
*/
cancelRequest: createEventBus(),
/**
* Event bus to keep track of when a request is started, stopped, or aborted
*/
requestStatus: createEventBus(),
/**
* Event bus for controlling the Command Palette
*
* @param commandName - the command name you wish to execute, leave empty for the full palette
*/
commandPalette: createEventBus(),
/**
* Event bus for handling hot keys
*/
hotKeys: createEventBus()
};
}
function keysOf(obj) {
return obj ? Object.keys(obj).map((k2) => String(k2)) : [];
}
var title = "A JSON Schema for Swagger 2.0 API.";
var id$2 = "http://swagger.io/v2/schema.json#";
var $schema$2 = "http://json-schema.org/draft-04/schema#";
var type$2 = "object";
var required$2 = [
"swagger",
"info",
"paths"
];
var additionalProperties$1 = false;
var patternProperties$1 = {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
};
var properties$3 = {
swagger: {
type: "string",
"enum": [
"2.0"
],
description: "The Swagger version of this document."
},
info: {
$ref: "#/definitions/info"
},
host: {
type: "string",
pattern: "^[^{}/ :\\\\]+(?::\\d+)?$",
description: "The host (name or ip) of the API. Example: 'swagger.io'"
},
basePath: {
type: "string",
pattern: "^/",
description: "The base path to the API. Example: '/api'."
},
schemes: {
$ref: "#/definitions/schemesList"
},
consumes: {
description: "A list of MIME types accepted by the API.",
allOf: [
{
$ref: "#/definitions/mediaTypeList"
}
]
},
produces: {
description: "A list of MIME types the API can produce.",
allOf: [
{
$ref: "#/definitions/mediaTypeList"
}
]
},
paths: {
$ref: "#/definitions/paths"
},
definitions: {
$ref: "#/definitions/definitions"
},
parameters: {
$ref: "#/definitions/parameterDefinitions"
},
responses: {
$ref: "#/definitions/responseDefinitions"
},
security: {
$ref: "#/definitions/security"
},
securityDefinitions: {
$ref: "#/definitions/securityDefinitions"
},
tags: {
type: "array",
items: {
$ref: "#/definitions/tag"
},
uniqueItems: true
},
externalDocs: {
$ref: "#/definitions/externalDocs"
}
};
var definitions$1 = {
info: {
type: "object",
description: "General information about the API.",
required: [
"version",
"title"
],
additionalProperties: false,
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
properties: {
title: {
type: "string",
description: "A unique and precise title of the API."
},
version: {
type: "string",
description: "A semantic version number of the API."
},
description: {
type: "string",
description: "A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed."
},
termsOfService: {
type: "string",
description: "The terms of service for the API."
},
contact: {
$ref: "#/definitions/contact"
},
license: {
$ref: "#/definitions/license"
}
}
},
contact: {
type: "object",
description: "Contact information for the owners of the API.",
additionalProperties: false,
properties: {
name: {
type: "string",
description: "The identifying name of the contact person/organization."
},
url: {
type: "string",
description: "The URL pointing to the contact information.",
format: "uri"
},
email: {
type: "string",
description: "The email address of the contact person/organization.",
format: "email"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
license: {
type: "object",
required: [
"name"
],
additionalProperties: false,
properties: {
name: {
type: "string",
description: "The name of the license type. It's encouraged to use an OSI compatible license."
},
url: {
type: "string",
description: "The URL pointing to the license.",
format: "uri"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
paths: {
type: "object",
description: "Relative paths to the individual endpoints. They must be relative to the 'basePath'.",
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
},
"^/": {
$ref: "#/definitions/pathItem"
}
},
additionalProperties: false
},
definitions: {
type: "object",
additionalProperties: {
$ref: "#/definitions/schema"
},
description: "One or more JSON objects describing the schemas being consumed and produced by the API."
},
parameterDefinitions: {
type: "object",
additionalProperties: {
$ref: "#/definitions/parameter"
},
description: "One or more JSON representations for parameters"
},
responseDefinitions: {
type: "object",
additionalProperties: {
$ref: "#/definitions/response"
},
description: "One or more JSON representations for responses"
},
externalDocs: {
type: "object",
additionalProperties: false,
description: "information about external documentation",
required: [
"url"
],
properties: {
description: {
type: "string"
},
url: {
type: "string",
format: "uri"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
examples: {
type: "object",
additionalProperties: true
},
mimeType: {
type: "string",
description: "The MIME type of the HTTP message."
},
operation: {
type: "object",
required: [
"responses"
],
additionalProperties: false,
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
properties: {
tags: {
type: "array",
items: {
type: "string"
},
uniqueItems: true
},
summary: {
type: "string",
description: "A brief summary of the operation."
},
description: {
type: "string",
description: "A longer description of the operation, GitHub Flavored Markdown is allowed."
},
externalDocs: {
$ref: "#/definitions/externalDocs"
},
operationId: {
type: "string",
description: "A unique identifier of the operation."
},
produces: {
description: "A list of MIME types the API can produce.",
allOf: [
{
$ref: "#/definitions/mediaTypeList"
}
]
},
consumes: {
description: "A list of MIME types the API can consume.",
allOf: [
{
$ref: "#/definitions/mediaTypeList"
}
]
},
parameters: {
$ref: "#/definitions/parametersList"
},
responses: {
$ref: "#/definitions/responses"
},
schemes: {
$ref: "#/definitions/schemesList"
},
deprecated: {
type: "boolean",
"default": false
},
security: {
$ref: "#/definitions/security"
}
}
},
pathItem: {
type: "object",
additionalProperties: false,
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
properties: {
$ref: {
type: "string"
},
get: {
$ref: "#/definitions/operation"
},
put: {
$ref: "#/definitions/operation"
},
post: {
$ref: "#/definitions/operation"
},
"delete": {
$ref: "#/definitions/operation"
},
options: {
$ref: "#/definitions/operation"
},
head: {
$ref: "#/definitions/operation"
},
patch: {
$ref: "#/definitions/operation"
},
parameters: {
$ref: "#/definitions/parametersList"
}
}
},
responses: {
type: "object",
description: "Response objects names can either be any valid HTTP status code or 'default'.",
minProperties: 1,
additionalProperties: false,
patternProperties: {
"^([0-9]{3})$|^(default)$": {
$ref: "#/definitions/responseValue"
},
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
not: {
type: "object",
additionalProperties: false,
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
}
},
responseValue: {
oneOf: [
{
$ref: "#/definitions/response"
},
{
$ref: "#/definitions/jsonReference"
}
]
},
response: {
type: "object",
required: [
"description"
],
properties: {
description: {
type: "string"
},
schema: {
oneOf: [
{
$ref: "#/definitions/schema"
},
{
$ref: "#/definitions/fileSchema"
}
]
},
headers: {
$ref: "#/definitions/headers"
},
examples: {
$ref: "#/definitions/examples"
}
},
additionalProperties: false,
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
headers: {
type: "object",
additionalProperties: {
$ref: "#/definitions/header"
}
},
header: {
type: "object",
additionalProperties: false,
required: [
"type"
],
properties: {
type: {
type: "string",
"enum": [
"string",
"number",
"integer",
"boolean",
"array"
]
},
format: {
type: "string"
},
items: {
$ref: "#/definitions/primitivesItems"
},
collectionFormat: {
$ref: "#/definitions/collectionFormat"
},
"default": {
$ref: "#/definitions/default"
},
maximum: {
$ref: "#/definitions/maximum"
},
exclusiveMaximum: {
$ref: "#/definitions/exclusiveMaximum"
},
minimum: {
$ref: "#/definitions/minimum"
},
exclusiveMinimum: {
$ref: "#/definitions/exclusiveMinimum"
},
maxLength: {
$ref: "#/definitions/maxLength"
},
minLength: {
$ref: "#/definitions/minLength"
},
pattern: {
$ref: "#/definitions/pattern"
},
maxItems: {
$ref: "#/definitions/maxItems"
},
minItems: {
$ref: "#/definitions/minItems"
},
uniqueItems: {
$ref: "#/definitions/uniqueItems"
},
"enum": {
$ref: "#/definitions/enum"
},
multipleOf: {
$ref: "#/definitions/multipleOf"
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
vendorExtension: {
description: "Any property starting with x- is valid.",
additionalProperties: true,
additionalItems: true
},
bodyParameter: {
type: "object",
required: [
"name",
"in",
"schema"
],
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
properties: {
description: {
type: "string",
description: "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
},
name: {
type: "string",
description: "The name of the parameter."
},
"in": {
type: "string",
description: "Determines the location of the parameter.",
"enum": [
"body"
]
},
required: {
type: "boolean",
description: "Determines whether or not this parameter is required or optional.",
"default": false
},
schema: {
$ref: "#/definitions/schema"
}
},
additionalProperties: false
},
headerParameterSubSchema: {
additionalProperties: false,
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
properties: {
required: {
type: "boolean",
description: "Determines whether or not this parameter is required or optional.",
"default": false
},
"in": {
type: "string",
description: "Determines the location of the parameter.",
"enum": [
"header"
]
},
description: {
type: "string",
description: "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
},
name: {
type: "string",
description: "The name of the parameter."
},
type: {
type: "string",
"enum": [
"string",
"number",
"boolean",
"integer",
"array"
]
},
format: {
type: "string"
},
items: {
$ref: "#/definitions/primitivesItems"
},
collectionFormat: {
$ref: "#/definitions/collectionFormat"
},
"default": {
$ref: "#/definitions/default"
},
maximum: {
$ref: "#/definitions/maximum"
},
exclusiveMaximum: {
$ref: "#/definitions/exclusiveMaximum"
},
minimum: {
$ref: "#/definitions/minimum"
},
exclusiveMinimum: {
$ref: "#/definitions/exclusiveMinimum"
},
maxLength: {
$ref: "#/definitions/maxLength"
},
minLength: {
$ref: "#/definitions/minLength"
},
pattern: {
$ref: "#/definitions/pattern"
},
maxItems: {
$ref: "#/definitions/maxItems"
},
minItems: {
$ref: "#/definitions/minItems"
},
uniqueItems: {
$ref: "#/definitions/uniqueItems"
},
"enum": {
$ref: "#/definitions/enum"
},
multipleOf: {
$ref: "#/definitions/multipleOf"
}
}
},
queryParameterSubSchema: {
additionalProperties: false,
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
properties: {
required: {
type: "boolean",
description: "Determines whether or not this parameter is required or optional.",
"default": false
},
"in": {
type: "string",
description: "Determines the location of the parameter.",
"enum": [
"query"
]
},
description: {
type: "string",
description: "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
},
name: {
type: "string",
description: "The name of the parameter."
},
allowEmptyValue: {
type: "boolean",
"default": false,
description: "allows sending a parameter by name only or with an empty value."
},
type: {
type: "string",
"enum": [
"string",
"number",
"boolean",
"integer",
"array"
]
},
format: {
type: "string"
},
items: {
$ref: "#/definitions/primitivesItems"
},
collectionFormat: {
$ref: "#/definitions/collectionFormatWithMulti"
},
"default": {
$ref: "#/definitions/default"
},
maximum: {
$ref: "#/definitions/maximum"
},
exclusiveMaximum: {
$ref: "#/definitions/exclusiveMaximum"
},
minimum: {
$ref: "#/definitions/minimum"
},
exclusiveMinimum: {
$ref: "#/definitions/exclusiveMinimum"
},
maxLength: {
$ref: "#/definitions/maxLength"
},
minLength: {
$ref: "#/definitions/minLength"
},
pattern: {
$ref: "#/definitions/pattern"
},
maxItems: {
$ref: "#/definitions/maxItems"
},
minItems: {
$ref: "#/definitions/minItems"
},
uniqueItems: {
$ref: "#/definitions/uniqueItems"
},
"enum": {
$ref: "#/definitions/enum"
},
multipleOf: {
$ref: "#/definitions/multipleOf"
}
}
},
formDataParameterSubSchema: {
additionalProperties: false,
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
properties: {
required: {
type: "boolean",
description: "Determines whether or not this parameter is required or optional.",
"default": false
},
"in": {
type: "string",
description: "Determines the location of the parameter.",
"enum": [
"formData"
]
},
description: {
type: "string",
description: "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
},
name: {
type: "string",
description: "The name of the parameter."
},
allowEmptyValue: {
type: "boolean",
"default": false,
description: "allows sending a parameter by name only or with an empty value."
},
type: {
type: "string",
"enum": [
"string",
"number",
"boolean",
"integer",
"array",
"file"
]
},
format: {
type: "string"
},
items: {
$ref: "#/definitions/primitivesItems"
},
collectionFormat: {
$ref: "#/definitions/collectionFormatWithMulti"
},
"default": {
$ref: "#/definitions/default"
},
maximum: {
$ref: "#/definitions/maximum"
},
exclusiveMaximum: {
$ref: "#/definitions/exclusiveMaximum"
},
minimum: {
$ref: "#/definitions/minimum"
},
exclusiveMinimum: {
$ref: "#/definitions/exclusiveMinimum"
},
maxLength: {
$ref: "#/definitions/maxLength"
},
minLength: {
$ref: "#/definitions/minLength"
},
pattern: {
$ref: "#/definitions/pattern"
},
maxItems: {
$ref: "#/definitions/maxItems"
},
minItems: {
$ref: "#/definitions/minItems"
},
uniqueItems: {
$ref: "#/definitions/uniqueItems"
},
"enum": {
$ref: "#/definitions/enum"
},
multipleOf: {
$ref: "#/definitions/multipleOf"
}
}
},
pathParameterSubSchema: {
additionalProperties: false,
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
required: [
"required"
],
properties: {
required: {
type: "boolean",
"enum": [
true
],
description: "Determines whether or not this parameter is required or optional."
},
"in": {
type: "string",
description: "Determines the location of the parameter.",
"enum": [
"path"
]
},
description: {
type: "string",
description: "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
},
name: {
type: "string",
description: "The name of the parameter."
},
type: {
type: "string",
"enum": [
"string",
"number",
"boolean",
"integer",
"array"
]
},
format: {
type: "string"
},
items: {
$ref: "#/definitions/primitivesItems"
},
collectionFormat: {
$ref: "#/definitions/collectionFormat"
},
"default": {
$ref: "#/definitions/default"
},
maximum: {
$ref: "#/definitions/maximum"
},
exclusiveMaximum: {
$ref: "#/definitions/exclusiveMaximum"
},
minimum: {
$ref: "#/definitions/minimum"
},
exclusiveMinimum: {
$ref: "#/definitions/exclusiveMinimum"
},
maxLength: {
$ref: "#/definitions/maxLength"
},
minLength: {
$ref: "#/definitions/minLength"
},
pattern: {
$ref: "#/definitions/pattern"
},
maxItems: {
$ref: "#/definitions/maxItems"
},
minItems: {
$ref: "#/definitions/minItems"
},
uniqueItems: {
$ref: "#/definitions/uniqueItems"
},
"enum": {
$ref: "#/definitions/enum"
},
multipleOf: {
$ref: "#/definitions/multipleOf"
}
}
},
nonBodyParameter: {
type: "object",
required: [
"name",
"in",
"type"
],
oneOf: [
{
$ref: "#/definitions/headerParameterSubSchema"
},
{
$ref: "#/definitions/formDataParameterSubSchema"
},
{
$ref: "#/definitions/queryParameterSubSchema"
},
{
$ref: "#/definitions/pathParameterSubSchema"
}
]
},
parameter: {
oneOf: [
{
$ref: "#/definitions/bodyParameter"
},
{
$ref: "#/definitions/nonBodyParameter"
}
]
},
schema: {
type: "object",
description: "A deterministic version of a JSON Schema object.",
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
properties: {
$ref: {
type: "string"
},
format: {
type: "string"
},
title: {
$ref: "http://json-schema.org/draft-04/schema#/properties/title"
},
description: {
$ref: "http://json-schema.org/draft-04/schema#/properties/description"
},
"default": {
$ref: "http://json-schema.org/draft-04/schema#/properties/default"
},
multipleOf: {
$ref: "http://json-schema.org/draft-04/schema#/properties/multipleOf"
},
maximum: {
$ref: "http://json-schema.org/draft-04/schema#/properties/maximum"
},
exclusiveMaximum: {
$ref: "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
},
minimum: {
$ref: "http://json-schema.org/draft-04/schema#/properties/minimum"
},
exclusiveMinimum: {
$ref: "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
},
maxLength: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
},
minLength: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
},
pattern: {
$ref: "http://json-schema.org/draft-04/schema#/properties/pattern"
},
maxItems: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
},
minItems: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
},
uniqueItems: {
$ref: "http://json-schema.org/draft-04/schema#/properties/uniqueItems"
},
maxProperties: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
},
minProperties: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
},
required: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/stringArray"
},
"enum": {
$ref: "http://json-schema.org/draft-04/schema#/properties/enum"
},
additionalProperties: {
anyOf: [
{
$ref: "#/definitions/schema"
},
{
type: "boolean"
}
],
"default": {}
},
type: {
$ref: "http://json-schema.org/draft-04/schema#/properties/type"
},
items: {
anyOf: [
{
$ref: "#/definitions/schema"
},
{
type: "array",
minItems: 1,
items: {
$ref: "#/definitions/schema"
}
}
],
"default": {}
},
allOf: {
type: "array",
minItems: 1,
items: {
$ref: "#/definitions/schema"
}
},
properties: {
type: "object",
additionalProperties: {
$ref: "#/definitions/schema"
},
"default": {}
},
discriminator: {
type: "string"
},
readOnly: {
type: "boolean",
"default": false
},
xml: {
$ref: "#/definitions/xml"
},
externalDocs: {
$ref: "#/definitions/externalDocs"
},
example: {}
},
additionalProperties: false
},
fileSchema: {
type: "object",
description: "A deterministic version of a JSON Schema object.",
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
},
required: [
"type"
],
properties: {
format: {
type: "string"
},
title: {
$ref: "http://json-schema.org/draft-04/schema#/properties/title"
},
description: {
$ref: "http://json-schema.org/draft-04/schema#/properties/description"
},
"default": {
$ref: "http://json-schema.org/draft-04/schema#/properties/default"
},
required: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/stringArray"
},
type: {
type: "string",
"enum": [
"file"
]
},
readOnly: {
type: "boolean",
"default": false
},
externalDocs: {
$ref: "#/definitions/externalDocs"
},
example: {}
},
additionalProperties: false
},
primitivesItems: {
type: "object",
additionalProperties: false,
properties: {
type: {
type: "string",
"enum": [
"string",
"number",
"integer",
"boolean",
"array"
]
},
format: {
type: "string"
},
items: {
$ref: "#/definitions/primitivesItems"
},
collectionFormat: {
$ref: "#/definitions/collectionFormat"
},
"default": {
$ref: "#/definitions/default"
},
maximum: {
$ref: "#/definitions/maximum"
},
exclusiveMaximum: {
$ref: "#/definitions/exclusiveMaximum"
},
minimum: {
$ref: "#/definitions/minimum"
},
exclusiveMinimum: {
$ref: "#/definitions/exclusiveMinimum"
},
maxLength: {
$ref: "#/definitions/maxLength"
},
minLength: {
$ref: "#/definitions/minLength"
},
pattern: {
$ref: "#/definitions/pattern"
},
maxItems: {
$ref: "#/definitions/maxItems"
},
minItems: {
$ref: "#/definitions/minItems"
},
uniqueItems: {
$ref: "#/definitions/uniqueItems"
},
"enum": {
$ref: "#/definitions/enum"
},
multipleOf: {
$ref: "#/definitions/multipleOf"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
security: {
type: "array",
items: {
$ref: "#/definitions/securityRequirement"
},
uniqueItems: true
},
securityRequirement: {
type: "object",
additionalProperties: {
type: "array",
items: {
type: "string"
},
uniqueItems: true
}
},
xml: {
type: "object",
additionalProperties: false,
properties: {
name: {
type: "string"
},
namespace: {
type: "string"
},
prefix: {
type: "string"
},
attribute: {
type: "boolean",
"default": false
},
wrapped: {
type: "boolean",
"default": false
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
tag: {
type: "object",
additionalProperties: false,
required: [
"name"
],
properties: {
name: {
type: "string"
},
description: {
type: "string"
},
externalDocs: {
$ref: "#/definitions/externalDocs"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
securityDefinitions: {
type: "object",
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/basicAuthenticationSecurity"
},
{
$ref: "#/definitions/apiKeySecurity"
},
{
$ref: "#/definitions/oauth2ImplicitSecurity"
},
{
$ref: "#/definitions/oauth2PasswordSecurity"
},
{
$ref: "#/definitions/oauth2ApplicationSecurity"
},
{
$ref: "#/definitions/oauth2AccessCodeSecurity"
}
]
}
},
basicAuthenticationSecurity: {
type: "object",
additionalProperties: false,
required: [
"type"
],
properties: {
type: {
type: "string",
"enum": [
"basic"
]
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
apiKeySecurity: {
type: "object",
additionalProperties: false,
required: [
"type",
"name",
"in"
],
properties: {
type: {
type: "string",
"enum": [
"apiKey"
]
},
name: {
type: "string"
},
"in": {
type: "string",
"enum": [
"header",
"query"
]
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
oauth2ImplicitSecurity: {
type: "object",
additionalProperties: false,
required: [
"type",
"flow",
"authorizationUrl"
],
properties: {
type: {
type: "string",
"enum": [
"oauth2"
]
},
flow: {
type: "string",
"enum": [
"implicit"
]
},
scopes: {
$ref: "#/definitions/oauth2Scopes"
},
authorizationUrl: {
type: "string",
format: "uri"
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
oauth2PasswordSecurity: {
type: "object",
additionalProperties: false,
required: [
"type",
"flow",
"tokenUrl"
],
properties: {
type: {
type: "string",
"enum": [
"oauth2"
]
},
flow: {
type: "string",
"enum": [
"password"
]
},
scopes: {
$ref: "#/definitions/oauth2Scopes"
},
tokenUrl: {
type: "string",
format: "uri"
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
oauth2ApplicationSecurity: {
type: "object",
additionalProperties: false,
required: [
"type",
"flow",
"tokenUrl"
],
properties: {
type: {
type: "string",
"enum": [
"oauth2"
]
},
flow: {
type: "string",
"enum": [
"application"
]
},
scopes: {
$ref: "#/definitions/oauth2Scopes"
},
tokenUrl: {
type: "string",
format: "uri"
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
oauth2AccessCodeSecurity: {
type: "object",
additionalProperties: false,
required: [
"type",
"flow",
"authorizationUrl",
"tokenUrl"
],
properties: {
type: {
type: "string",
"enum": [
"oauth2"
]
},
flow: {
type: "string",
"enum": [
"accessCode"
]
},
scopes: {
$ref: "#/definitions/oauth2Scopes"
},
authorizationUrl: {
type: "string",
format: "uri"
},
tokenUrl: {
type: "string",
format: "uri"
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {
$ref: "#/definitions/vendorExtension"
}
}
},
oauth2Scopes: {
type: "object",
additionalProperties: {
type: "string"
}
},
mediaTypeList: {
type: "array",
items: {
$ref: "#/definitions/mimeType"
},
uniqueItems: true
},
parametersList: {
type: "array",
description: "The parameters needed to send a valid API call.",
additionalItems: false,
items: {
oneOf: [
{
$ref: "#/definitions/parameter"
},
{
$ref: "#/definitions/jsonReference"
}
]
},
uniqueItems: true
},
schemesList: {
type: "array",
description: "The transfer protocol of the API.",
items: {
type: "string",
"enum": [
"http",
"https",
"ws",
"wss"
]
},
uniqueItems: true
},
collectionFormat: {
type: "string",
"enum": [
"csv",
"ssv",
"tsv",
"pipes"
],
"default": "csv"
},
collectionFormatWithMulti: {
type: "string",
"enum": [
"csv",
"ssv",
"tsv",
"pipes",
"multi"
],
"default": "csv"
},
title: {
$ref: "http://json-schema.org/draft-04/schema#/properties/title"
},
description: {
$ref: "http://json-schema.org/draft-04/schema#/properties/description"
},
"default": {
$ref: "http://json-schema.org/draft-04/schema#/properties/default"
},
multipleOf: {
$ref: "http://json-schema.org/draft-04/schema#/properties/multipleOf"
},
maximum: {
$ref: "http://json-schema.org/draft-04/schema#/properties/maximum"
},
exclusiveMaximum: {
$ref: "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
},
minimum: {
$ref: "http://json-schema.org/draft-04/schema#/properties/minimum"
},
exclusiveMinimum: {
$ref: "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
},
maxLength: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
},
minLength: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
},
pattern: {
$ref: "http://json-schema.org/draft-04/schema#/properties/pattern"
},
maxItems: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
},
minItems: {
$ref: "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
},
uniqueItems: {
$ref: "http://json-schema.org/draft-04/schema#/properties/uniqueItems"
},
"enum": {
$ref: "http://json-schema.org/draft-04/schema#/properties/enum"
},
jsonReference: {
type: "object",
required: [
"$ref"
],
additionalProperties: false,
properties: {
$ref: {
type: "string"
}
}
}
};
var Swagger20 = {
title,
id: id$2,
$schema: $schema$2,
type: type$2,
required: required$2,
additionalProperties: additionalProperties$1,
patternProperties: patternProperties$1,
properties: properties$3,
definitions: definitions$1
};
var id$1 = "https://spec.openapis.org/oas/3.0/schema/2021-09-28";
var $schema$1 = "http://json-schema.org/draft-04/schema#";
var description$1 = "The description of OpenAPI v3.0.x documents, as defined by https://spec.openapis.org/oas/v3.0.3";
var type$1 = "object";
var required$1 = [
"openapi",
"info",
"paths"
];
var properties$2 = {
openapi: {
type: "string",
pattern: "^3\\.0\\.\\d(-.+)?$"
},
info: {
$ref: "#/definitions/Info"
},
externalDocs: {
$ref: "#/definitions/ExternalDocumentation"
},
servers: {
type: "array",
items: {
$ref: "#/definitions/Server"
}
},
security: {
type: "array",
items: {
$ref: "#/definitions/SecurityRequirement"
}
},
tags: {
type: "array",
items: {
$ref: "#/definitions/Tag"
},
uniqueItems: true
},
paths: {
$ref: "#/definitions/Paths"
},
components: {
$ref: "#/definitions/Components"
}
};
var patternProperties = {
"^x-": {}
};
var additionalProperties = false;
var definitions = {
Reference: {
type: "object",
required: [
"$ref"
],
patternProperties: {
"^\\$ref$": {
type: "string",
format: "uri-reference"
}
}
},
Info: {
type: "object",
required: [
"title",
"version"
],
properties: {
title: {
type: "string"
},
description: {
type: "string"
},
termsOfService: {
type: "string",
format: "uri-reference"
},
contact: {
$ref: "#/definitions/Contact"
},
license: {
$ref: "#/definitions/License"
},
version: {
type: "string"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
Contact: {
type: "object",
properties: {
name: {
type: "string"
},
url: {
type: "string",
format: "uri-reference"
},
email: {
type: "string",
format: "email"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
License: {
type: "object",
required: [
"name"
],
properties: {
name: {
type: "string"
},
url: {
type: "string",
format: "uri-reference"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
Server: {
type: "object",
required: [
"url"
],
properties: {
url: {
type: "string"
},
description: {
type: "string"
},
variables: {
type: "object",
additionalProperties: {
$ref: "#/definitions/ServerVariable"
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
ServerVariable: {
type: "object",
required: [
"default"
],
properties: {
"enum": {
type: "array",
items: {
type: "string"
}
},
"default": {
type: "string"
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
Components: {
type: "object",
properties: {
schemas: {
type: "object",
patternProperties: {
"^[a-zA-Z0-9\\.\\-_]+$": {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
}
}
},
responses: {
type: "object",
patternProperties: {
"^[a-zA-Z0-9\\.\\-_]+$": {
oneOf: [
{
$ref: "#/definitions/Reference"
},
{
$ref: "#/definitions/Response"
}
]
}
}
},
parameters: {
type: "object",
patternProperties: {
"^[a-zA-Z0-9\\.\\-_]+$": {
oneOf: [
{
$ref: "#/definitions/Reference"
},
{
$ref: "#/definitions/Parameter"
}
]
}
}
},
examples: {
type: "object",
patternProperties: {
"^[a-zA-Z0-9\\.\\-_]+$": {
oneOf: [
{
$ref: "#/definitions/Reference"
},
{
$ref: "#/definitions/Example"
}
]
}
}
},
requestBodies: {
type: "object",
patternProperties: {
"^[a-zA-Z0-9\\.\\-_]+$": {
oneOf: [
{
$ref: "#/definitions/Reference"
},
{
$ref: "#/definitions/RequestBody"
}
]
}
}
},
headers: {
type: "object",
patternProperties: {
"^[a-zA-Z0-9\\.\\-_]+$": {
oneOf: [
{
$ref: "#/definitions/Reference"
},
{
$ref: "#/definitions/Header"
}
]
}
}
},
securitySchemes: {
type: "object",
patternProperties: {
"^[a-zA-Z0-9\\.\\-_]+$": {
oneOf: [
{
$ref: "#/definitions/Reference"
},
{
$ref: "#/definitions/SecurityScheme"
}
]
}
}
},
links: {
type: "object",
patternProperties: {
"^[a-zA-Z0-9\\.\\-_]+$": {
oneOf: [
{
$ref: "#/definitions/Reference"
},
{
$ref: "#/definitions/Link"
}
]
}
}
},
callbacks: {
type: "object",
patternProperties: {
"^[a-zA-Z0-9\\.\\-_]+$": {
oneOf: [
{
$ref: "#/definitions/Reference"
},
{
$ref: "#/definitions/Callback"
}
]
}
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
Schema: {
type: "object",
properties: {
title: {
type: "string"
},
multipleOf: {
type: "number",
minimum: 0,
exclusiveMinimum: true
},
maximum: {
type: "number"
},
exclusiveMaximum: {
type: "boolean",
"default": false
},
minimum: {
type: "number"
},
exclusiveMinimum: {
type: "boolean",
"default": false
},
maxLength: {
type: "integer",
minimum: 0
},
minLength: {
type: "integer",
minimum: 0,
"default": 0
},
pattern: {
type: "string",
format: "regex"
},
maxItems: {
type: "integer",
minimum: 0
},
minItems: {
type: "integer",
minimum: 0,
"default": 0
},
uniqueItems: {
type: "boolean",
"default": false
},
maxProperties: {
type: "integer",
minimum: 0
},
minProperties: {
type: "integer",
minimum: 0,
"default": 0
},
required: {
type: "array",
items: {
type: "string"
},
minItems: 1,
uniqueItems: true
},
"enum": {
type: "array",
items: {},
minItems: 1,
uniqueItems: false
},
type: {
type: "string",
"enum": [
"array",
"boolean",
"integer",
"number",
"object",
"string"
]
},
not: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
},
allOf: {
type: "array",
items: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
}
},
oneOf: {
type: "array",
items: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
}
},
anyOf: {
type: "array",
items: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
}
},
items: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
},
properties: {
type: "object",
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
}
},
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
},
{
type: "boolean"
}
],
"default": true
},
description: {
type: "string"
},
format: {
type: "string"
},
"default": {},
nullable: {
type: "boolean",
"default": false
},
discriminator: {
$ref: "#/definitions/Discriminator"
},
readOnly: {
type: "boolean",
"default": false
},
writeOnly: {
type: "boolean",
"default": false
},
example: {},
externalDocs: {
$ref: "#/definitions/ExternalDocumentation"
},
deprecated: {
type: "boolean",
"default": false
},
xml: {
$ref: "#/definitions/XML"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
Discriminator: {
type: "object",
required: [
"propertyName"
],
properties: {
propertyName: {
type: "string"
},
mapping: {
type: "object",
additionalProperties: {
type: "string"
}
}
}
},
XML: {
type: "object",
properties: {
name: {
type: "string"
},
namespace: {
type: "string",
format: "uri"
},
prefix: {
type: "string"
},
attribute: {
type: "boolean",
"default": false
},
wrapped: {
type: "boolean",
"default": false
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
Response: {
type: "object",
required: [
"description"
],
properties: {
description: {
type: "string"
},
headers: {
type: "object",
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/Header"
},
{
$ref: "#/definitions/Reference"
}
]
}
},
content: {
type: "object",
additionalProperties: {
$ref: "#/definitions/MediaType"
}
},
links: {
type: "object",
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/Link"
},
{
$ref: "#/definitions/Reference"
}
]
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
MediaType: {
type: "object",
properties: {
schema: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
},
example: {},
examples: {
type: "object",
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/Example"
},
{
$ref: "#/definitions/Reference"
}
]
}
},
encoding: {
type: "object",
additionalProperties: {
$ref: "#/definitions/Encoding"
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/ExampleXORExamples"
}
]
},
Example: {
type: "object",
properties: {
summary: {
type: "string"
},
description: {
type: "string"
},
value: {},
externalValue: {
type: "string",
format: "uri-reference"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
Header: {
type: "object",
properties: {
description: {
type: "string"
},
required: {
type: "boolean",
"default": false
},
deprecated: {
type: "boolean",
"default": false
},
allowEmptyValue: {
type: "boolean",
"default": false
},
style: {
type: "string",
"enum": [
"simple"
],
"default": "simple"
},
explode: {
type: "boolean"
},
allowReserved: {
type: "boolean",
"default": false
},
schema: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
},
content: {
type: "object",
additionalProperties: {
$ref: "#/definitions/MediaType"
},
minProperties: 1,
maxProperties: 1
},
example: {},
examples: {
type: "object",
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/Example"
},
{
$ref: "#/definitions/Reference"
}
]
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/ExampleXORExamples"
},
{
$ref: "#/definitions/SchemaXORContent"
}
]
},
Paths: {
type: "object",
patternProperties: {
"^\\/": {
$ref: "#/definitions/PathItem"
},
"^x-": {}
},
additionalProperties: false
},
PathItem: {
type: "object",
properties: {
$ref: {
type: "string"
},
summary: {
type: "string"
},
description: {
type: "string"
},
servers: {
type: "array",
items: {
$ref: "#/definitions/Server"
}
},
parameters: {
type: "array",
items: {
oneOf: [
{
$ref: "#/definitions/Parameter"
},
{
$ref: "#/definitions/Reference"
}
]
},
uniqueItems: true
}
},
patternProperties: {
"^(get|put|post|delete|options|head|patch|trace)$": {
$ref: "#/definitions/Operation"
},
"^x-": {}
},
additionalProperties: false
},
Operation: {
type: "object",
required: [
"responses"
],
properties: {
tags: {
type: "array",
items: {
type: "string"
}
},
summary: {
type: "string"
},
description: {
type: "string"
},
externalDocs: {
$ref: "#/definitions/ExternalDocumentation"
},
operationId: {
type: "string"
},
parameters: {
type: "array",
items: {
oneOf: [
{
$ref: "#/definitions/Parameter"
},
{
$ref: "#/definitions/Reference"
}
]
},
uniqueItems: true
},
requestBody: {
oneOf: [
{
$ref: "#/definitions/RequestBody"
},
{
$ref: "#/definitions/Reference"
}
]
},
responses: {
$ref: "#/definitions/Responses"
},
callbacks: {
type: "object",
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/Callback"
},
{
$ref: "#/definitions/Reference"
}
]
}
},
deprecated: {
type: "boolean",
"default": false
},
security: {
type: "array",
items: {
$ref: "#/definitions/SecurityRequirement"
}
},
servers: {
type: "array",
items: {
$ref: "#/definitions/Server"
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
Responses: {
type: "object",
properties: {
"default": {
oneOf: [
{
$ref: "#/definitions/Response"
},
{
$ref: "#/definitions/Reference"
}
]
}
},
patternProperties: {
"^[1-5](?:\\d{2}|XX)$": {
oneOf: [
{
$ref: "#/definitions/Response"
},
{
$ref: "#/definitions/Reference"
}
]
},
"^x-": {}
},
minProperties: 1,
additionalProperties: false
},
SecurityRequirement: {
type: "object",
additionalProperties: {
type: "array",
items: {
type: "string"
}
}
},
Tag: {
type: "object",
required: [
"name"
],
properties: {
name: {
type: "string"
},
description: {
type: "string"
},
externalDocs: {
$ref: "#/definitions/ExternalDocumentation"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
ExternalDocumentation: {
type: "object",
required: [
"url"
],
properties: {
description: {
type: "string"
},
url: {
type: "string",
format: "uri-reference"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
ExampleXORExamples: {
description: "Example and examples are mutually exclusive",
not: {
required: [
"example",
"examples"
]
}
},
SchemaXORContent: {
description: "Schema and content are mutually exclusive, at least one is required",
not: {
required: [
"schema",
"content"
]
},
oneOf: [
{
required: [
"schema"
]
},
{
required: [
"content"
],
description: "Some properties are not allowed if content is present",
allOf: [
{
not: {
required: [
"style"
]
}
},
{
not: {
required: [
"explode"
]
}
},
{
not: {
required: [
"allowReserved"
]
}
},
{
not: {
required: [
"example"
]
}
},
{
not: {
required: [
"examples"
]
}
}
]
}
]
},
Parameter: {
type: "object",
properties: {
name: {
type: "string"
},
"in": {
type: "string"
},
description: {
type: "string"
},
required: {
type: "boolean",
"default": false
},
deprecated: {
type: "boolean",
"default": false
},
allowEmptyValue: {
type: "boolean",
"default": false
},
style: {
type: "string"
},
explode: {
type: "boolean"
},
allowReserved: {
type: "boolean",
"default": false
},
schema: {
oneOf: [
{
$ref: "#/definitions/Schema"
},
{
$ref: "#/definitions/Reference"
}
]
},
content: {
type: "object",
additionalProperties: {
$ref: "#/definitions/MediaType"
},
minProperties: 1,
maxProperties: 1
},
example: {},
examples: {
type: "object",
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/Example"
},
{
$ref: "#/definitions/Reference"
}
]
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false,
required: [
"name",
"in"
],
allOf: [
{
$ref: "#/definitions/ExampleXORExamples"
},
{
$ref: "#/definitions/SchemaXORContent"
},
{
$ref: "#/definitions/ParameterLocation"
}
]
},
ParameterLocation: {
description: "Parameter location",
oneOf: [
{
description: "Parameter in path",
required: [
"required"
],
properties: {
"in": {
"enum": [
"path"
]
},
style: {
"enum": [
"matrix",
"label",
"simple"
],
"default": "simple"
},
required: {
"enum": [
true
]
}
}
},
{
description: "Parameter in query",
properties: {
"in": {
"enum": [
"query"
]
},
style: {
"enum": [
"form",
"spaceDelimited",
"pipeDelimited",
"deepObject"
],
"default": "form"
}
}
},
{
description: "Parameter in header",
properties: {
"in": {
"enum": [
"header"
]
},
style: {
"enum": [
"simple"
],
"default": "simple"
}
}
},
{
description: "Parameter in cookie",
properties: {
"in": {
"enum": [
"cookie"
]
},
style: {
"enum": [
"form"
],
"default": "form"
}
}
}
]
},
RequestBody: {
type: "object",
required: [
"content"
],
properties: {
description: {
type: "string"
},
content: {
type: "object",
additionalProperties: {
$ref: "#/definitions/MediaType"
}
},
required: {
type: "boolean",
"default": false
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
SecurityScheme: {
oneOf: [
{
$ref: "#/definitions/APIKeySecurityScheme"
},
{
$ref: "#/definitions/HTTPSecurityScheme"
},
{
$ref: "#/definitions/OAuth2SecurityScheme"
},
{
$ref: "#/definitions/OpenIdConnectSecurityScheme"
}
]
},
APIKeySecurityScheme: {
type: "object",
required: [
"type",
"name",
"in"
],
properties: {
type: {
type: "string",
"enum": [
"apiKey"
]
},
name: {
type: "string"
},
"in": {
type: "string",
"enum": [
"header",
"query",
"cookie"
]
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
HTTPSecurityScheme: {
type: "object",
required: [
"scheme",
"type"
],
properties: {
scheme: {
type: "string"
},
bearerFormat: {
type: "string"
},
description: {
type: "string"
},
type: {
type: "string",
"enum": [
"http"
]
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false,
oneOf: [
{
description: "Bearer",
properties: {
scheme: {
type: "string",
pattern: "^[Bb][Ee][Aa][Rr][Ee][Rr]$"
}
}
},
{
description: "Non Bearer",
not: {
required: [
"bearerFormat"
]
},
properties: {
scheme: {
not: {
type: "string",
pattern: "^[Bb][Ee][Aa][Rr][Ee][Rr]$"
}
}
}
}
]
},
OAuth2SecurityScheme: {
type: "object",
required: [
"type",
"flows"
],
properties: {
type: {
type: "string",
"enum": [
"oauth2"
]
},
flows: {
$ref: "#/definitions/OAuthFlows"
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
OpenIdConnectSecurityScheme: {
type: "object",
required: [
"type",
"openIdConnectUrl"
],
properties: {
type: {
type: "string",
"enum": [
"openIdConnect"
]
},
openIdConnectUrl: {
type: "string",
format: "uri-reference"
},
description: {
type: "string"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
OAuthFlows: {
type: "object",
properties: {
implicit: {
$ref: "#/definitions/ImplicitOAuthFlow"
},
password: {
$ref: "#/definitions/PasswordOAuthFlow"
},
clientCredentials: {
$ref: "#/definitions/ClientCredentialsFlow"
},
authorizationCode: {
$ref: "#/definitions/AuthorizationCodeOAuthFlow"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
ImplicitOAuthFlow: {
type: "object",
required: [
"authorizationUrl",
"scopes"
],
properties: {
authorizationUrl: {
type: "string",
format: "uri-reference"
},
refreshUrl: {
type: "string",
format: "uri-reference"
},
scopes: {
type: "object",
additionalProperties: {
type: "string"
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
PasswordOAuthFlow: {
type: "object",
required: [
"tokenUrl",
"scopes"
],
properties: {
tokenUrl: {
type: "string",
format: "uri-reference"
},
refreshUrl: {
type: "string",
format: "uri-reference"
},
scopes: {
type: "object",
additionalProperties: {
type: "string"
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
ClientCredentialsFlow: {
type: "object",
required: [
"tokenUrl",
"scopes"
],
properties: {
tokenUrl: {
type: "string",
format: "uri-reference"
},
refreshUrl: {
type: "string",
format: "uri-reference"
},
scopes: {
type: "object",
additionalProperties: {
type: "string"
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
AuthorizationCodeOAuthFlow: {
type: "object",
required: [
"authorizationUrl",
"tokenUrl",
"scopes"
],
properties: {
authorizationUrl: {
type: "string",
format: "uri-reference"
},
tokenUrl: {
type: "string",
format: "uri-reference"
},
refreshUrl: {
type: "string",
format: "uri-reference"
},
scopes: {
type: "object",
additionalProperties: {
type: "string"
}
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false
},
Link: {
type: "object",
properties: {
operationId: {
type: "string"
},
operationRef: {
type: "string",
format: "uri-reference"
},
parameters: {
type: "object",
additionalProperties: {}
},
requestBody: {},
description: {
type: "string"
},
server: {
$ref: "#/definitions/Server"
}
},
patternProperties: {
"^x-": {}
},
additionalProperties: false,
not: {
description: "Operation Id and Operation Ref are mutually exclusive",
required: [
"operationId",
"operationRef"
]
}
},
Callback: {
type: "object",
additionalProperties: {
$ref: "#/definitions/PathItem"
},
patternProperties: {
"^x-": {}
}
},
Encoding: {
type: "object",
properties: {
contentType: {
type: "string"
},
headers: {
type: "object",
additionalProperties: {
oneOf: [
{
$ref: "#/definitions/Header"
},
{
$ref: "#/definitions/Reference"
}
]
}
},
style: {
type: "string",
"enum": [
"form",
"spaceDelimited",
"pipeDelimited",
"deepObject"
]
},
explode: {
type: "boolean"
},
allowReserved: {
type: "boolean",
"default": false
}
},
additionalProperties: false
}
};
var OpenApi30 = {
id: id$1,
$schema: $schema$1,
description: description$1,
type: type$1,
required: required$1,
properties: properties$2,
patternProperties,
additionalProperties,
definitions
};
var $id = "https://spec.openapis.org/oas/3.1/schema/2022-10-07";
var $schema = "https://json-schema.org/draft/2020-12/schema";
var description = "The description of OpenAPI v3.1.x documents without schema validation, as defined by https://spec.openapis.org/oas/v3.1.0";
var type = "object";
var properties$1 = {
openapi: {
type: "string",
pattern: "^3\\.1\\.\\d+(-.+)?$"
},
info: {
$ref: "#/$defs/info"
},
jsonSchemaDialect: {
type: "string",
format: "uri",
"default": "https://spec.openapis.org/oas/3.1/dialect/base"
},
servers: {
type: "array",
items: {
$ref: "#/$defs/server"
},
"default": [
{
url: "/"
}
]
},
paths: {
$ref: "#/$defs/paths"
},
webhooks: {
type: "object",
additionalProperties: {
$ref: "#/$defs/path-item-or-reference"
}
},
components: {
$ref: "#/$defs/components"
},
security: {
type: "array",
items: {
$ref: "#/$defs/security-requirement"
}
},
tags: {
type: "array",
items: {
$ref: "#/$defs/tag"
}
},
externalDocs: {
$ref: "#/$defs/external-documentation"
}
};
var required = [
"openapi",
"info"
];
var anyOf = [
{
required: [
"paths"
]
},
{
required: [
"components"
]
},
{
required: [
"webhooks"
]
}
];
var $ref = "#/$defs/specification-extensions";
var unevaluatedProperties = false;
var $defs = {
info: {
$comment: "https://spec.openapis.org/oas/v3.1.0#info-object",
type: "object",
properties: {
title: {
type: "string"
},
summary: {
type: "string"
},
description: {
type: "string"
},
termsOfService: {
type: "string",
format: "uri"
},
contact: {
$ref: "#/$defs/contact"
},
license: {
$ref: "#/$defs/license"
},
version: {
type: "string"
}
},
required: [
"title",
"version"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
contact: {
$comment: "https://spec.openapis.org/oas/v3.1.0#contact-object",
type: "object",
properties: {
name: {
type: "string"
},
url: {
type: "string",
format: "uri"
},
email: {
type: "string",
format: "email"
}
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
license: {
$comment: "https://spec.openapis.org/oas/v3.1.0#license-object",
type: "object",
properties: {
name: {
type: "string"
},
identifier: {
type: "string"
},
url: {
type: "string",
format: "uri"
}
},
required: [
"name"
],
dependentSchemas: {
identifier: {
not: {
required: [
"url"
]
}
}
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
server: {
$comment: "https://spec.openapis.org/oas/v3.1.0#server-object",
type: "object",
properties: {
url: {
type: "string"
},
description: {
type: "string"
},
variables: {
type: "object",
additionalProperties: {
$ref: "#/$defs/server-variable"
}
}
},
required: [
"url"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"server-variable": {
$comment: "https://spec.openapis.org/oas/v3.1.0#server-variable-object",
type: "object",
properties: {
"enum": {
type: "array",
items: {
type: "string"
},
minItems: 1
},
"default": {
type: "string"
},
description: {
type: "string"
}
},
required: [
"default"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
components: {
$comment: "https://spec.openapis.org/oas/v3.1.0#components-object",
type: "object",
properties: {
schemas: {
type: "object",
additionalProperties: {
$ref: "#/$defs/schema"
}
},
responses: {
type: "object",
additionalProperties: {
$ref: "#/$defs/response-or-reference"
}
},
parameters: {
type: "object",
additionalProperties: {
$ref: "#/$defs/parameter-or-reference"
}
},
examples: {
type: "object",
additionalProperties: {
$ref: "#/$defs/example-or-reference"
}
},
requestBodies: {
type: "object",
additionalProperties: {
$ref: "#/$defs/request-body-or-reference"
}
},
headers: {
type: "object",
additionalProperties: {
$ref: "#/$defs/header-or-reference"
}
},
securitySchemes: {
type: "object",
additionalProperties: {
$ref: "#/$defs/security-scheme-or-reference"
}
},
links: {
type: "object",
additionalProperties: {
$ref: "#/$defs/link-or-reference"
}
},
callbacks: {
type: "object",
additionalProperties: {
$ref: "#/$defs/callbacks-or-reference"
}
},
pathItems: {
type: "object",
additionalProperties: {
$ref: "#/$defs/path-item-or-reference"
}
}
},
patternProperties: {
"^(schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems)$": {
$comment: "Enumerating all of the property names in the regex above is necessary for unevaluatedProperties to work as expected",
propertyNames: {
pattern: "^[a-zA-Z0-9._-]+$"
}
}
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
paths: {
$comment: "https://spec.openapis.org/oas/v3.1.0#paths-object",
type: "object",
patternProperties: {
"^/": {
$ref: "#/$defs/path-item"
}
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"path-item": {
$comment: "https://spec.openapis.org/oas/v3.1.0#path-item-object",
type: "object",
properties: {
summary: {
type: "string"
},
description: {
type: "string"
},
servers: {
type: "array",
items: {
$ref: "#/$defs/server"
}
},
parameters: {
type: "array",
items: {
$ref: "#/$defs/parameter-or-reference"
}
},
get: {
$ref: "#/$defs/operation"
},
put: {
$ref: "#/$defs/operation"
},
post: {
$ref: "#/$defs/operation"
},
"delete": {
$ref: "#/$defs/operation"
},
options: {
$ref: "#/$defs/operation"
},
head: {
$ref: "#/$defs/operation"
},
patch: {
$ref: "#/$defs/operation"
},
trace: {
$ref: "#/$defs/operation"
}
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"path-item-or-reference": {
"if": {
type: "object",
required: [
"$ref"
]
},
then: {
$ref: "#/$defs/reference"
},
"else": {
$ref: "#/$defs/path-item"
}
},
operation: {
$comment: "https://spec.openapis.org/oas/v3.1.0#operation-object",
type: "object",
properties: {
tags: {
type: "array",
items: {
type: "string"
}
},
summary: {
type: "string"
},
description: {
type: "string"
},
externalDocs: {
$ref: "#/$defs/external-documentation"
},
operationId: {
type: "string"
},
parameters: {
type: "array",
items: {
$ref: "#/$defs/parameter-or-reference"
}
},
requestBody: {
$ref: "#/$defs/request-body-or-reference"
},
responses: {
$ref: "#/$defs/responses"
},
callbacks: {
type: "object",
additionalProperties: {
$ref: "#/$defs/callbacks-or-reference"
}
},
deprecated: {
"default": false,
type: "boolean"
},
security: {
type: "array",
items: {
$ref: "#/$defs/security-requirement"
}
},
servers: {
type: "array",
items: {
$ref: "#/$defs/server"
}
}
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"external-documentation": {
$comment: "https://spec.openapis.org/oas/v3.1.0#external-documentation-object",
type: "object",
properties: {
description: {
type: "string"
},
url: {
type: "string",
format: "uri"
}
},
required: [
"url"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
parameter: {
$comment: "https://spec.openapis.org/oas/v3.1.0#parameter-object",
type: "object",
properties: {
name: {
type: "string"
},
"in": {
"enum": [
"query",
"header",
"path",
"cookie"
]
},
description: {
type: "string"
},
required: {
"default": false,
type: "boolean"
},
deprecated: {
"default": false,
type: "boolean"
},
schema: {
$ref: "#/$defs/schema"
},
content: {
$ref: "#/$defs/content",
minProperties: 1,
maxProperties: 1
}
},
required: [
"name",
"in"
],
oneOf: [
{
required: [
"schema"
]
},
{
required: [
"content"
]
}
],
"if": {
properties: {
"in": {
"const": "query"
}
},
required: [
"in"
]
},
then: {
properties: {
allowEmptyValue: {
"default": false,
type: "boolean"
}
}
},
dependentSchemas: {
schema: {
properties: {
style: {
type: "string"
},
explode: {
type: "boolean"
}
},
allOf: [
{
$ref: "#/$defs/examples"
},
{
$ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-path"
},
{
$ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header"
},
{
$ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query"
},
{
$ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie"
},
{
$ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-form"
}
],
$defs: {
"styles-for-path": {
"if": {
properties: {
"in": {
"const": "path"
}
},
required: [
"in"
]
},
then: {
properties: {
name: {
pattern: "[^/#?]+$"
},
style: {
"default": "simple",
"enum": [
"matrix",
"label",
"simple"
]
},
required: {
"const": true
}
},
required: [
"required"
]
}
},
"styles-for-header": {
"if": {
properties: {
"in": {
"const": "header"
}
},
required: [
"in"
]
},
then: {
properties: {
style: {
"default": "simple",
"const": "simple"
}
}
}
},
"styles-for-query": {
"if": {
properties: {
"in": {
"const": "query"
}
},
required: [
"in"
]
},
then: {
properties: {
style: {
"default": "form",
"enum": [
"form",
"spaceDelimited",
"pipeDelimited",
"deepObject"
]
},
allowReserved: {
"default": false,
type: "boolean"
}
}
}
},
"styles-for-cookie": {
"if": {
properties: {
"in": {
"const": "cookie"
}
},
required: [
"in"
]
},
then: {
properties: {
style: {
"default": "form",
"const": "form"
}
}
}
},
"styles-for-form": {
"if": {
properties: {
style: {
"const": "form"
}
},
required: [
"style"
]
},
then: {
properties: {
explode: {
"default": true
}
}
},
"else": {
properties: {
explode: {
"default": false
}
}
}
}
}
}
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"parameter-or-reference": {
"if": {
type: "object",
required: [
"$ref"
]
},
then: {
$ref: "#/$defs/reference"
},
"else": {
$ref: "#/$defs/parameter"
}
},
"request-body": {
$comment: "https://spec.openapis.org/oas/v3.1.0#request-body-object",
type: "object",
properties: {
description: {
type: "string"
},
content: {
$ref: "#/$defs/content"
},
required: {
"default": false,
type: "boolean"
}
},
required: [
"content"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"request-body-or-reference": {
"if": {
type: "object",
required: [
"$ref"
]
},
then: {
$ref: "#/$defs/reference"
},
"else": {
$ref: "#/$defs/request-body"
}
},
content: {
$comment: "https://spec.openapis.org/oas/v3.1.0#fixed-fields-10",
type: "object",
additionalProperties: {
$ref: "#/$defs/media-type"
},
propertyNames: {
format: "media-range"
}
},
"media-type": {
$comment: "https://spec.openapis.org/oas/v3.1.0#media-type-object",
type: "object",
properties: {
schema: {
$ref: "#/$defs/schema"
},
encoding: {
type: "object",
additionalProperties: {
$ref: "#/$defs/encoding"
}
}
},
allOf: [
{
$ref: "#/$defs/specification-extensions"
},
{
$ref: "#/$defs/examples"
}
],
unevaluatedProperties: false
},
encoding: {
$comment: "https://spec.openapis.org/oas/v3.1.0#encoding-object",
type: "object",
properties: {
contentType: {
type: "string",
format: "media-range"
},
headers: {
type: "object",
additionalProperties: {
$ref: "#/$defs/header-or-reference"
}
},
style: {
"default": "form",
"enum": [
"form",
"spaceDelimited",
"pipeDelimited",
"deepObject"
]
},
explode: {
type: "boolean"
},
allowReserved: {
"default": false,
type: "boolean"
}
},
allOf: [
{
$ref: "#/$defs/specification-extensions"
},
{
$ref: "#/$defs/encoding/$defs/explode-default"
}
],
unevaluatedProperties: false,
$defs: {
"explode-default": {
"if": {
properties: {
style: {
"const": "form"
}
},
required: [
"style"
]
},
then: {
properties: {
explode: {
"default": true
}
}
},
"else": {
properties: {
explode: {
"default": false
}
}
}
}
}
},
responses: {
$comment: "https://spec.openapis.org/oas/v3.1.0#responses-object",
type: "object",
properties: {
"default": {
$ref: "#/$defs/response-or-reference"
}
},
patternProperties: {
"^[1-5](?:[0-9]{2}|XX)$": {
$ref: "#/$defs/response-or-reference"
}
},
minProperties: 1,
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
response: {
$comment: "https://spec.openapis.org/oas/v3.1.0#response-object",
type: "object",
properties: {
description: {
type: "string"
},
headers: {
type: "object",
additionalProperties: {
$ref: "#/$defs/header-or-reference"
}
},
content: {
$ref: "#/$defs/content"
},
links: {
type: "object",
additionalProperties: {
$ref: "#/$defs/link-or-reference"
}
}
},
required: [
"description"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"response-or-reference": {
"if": {
type: "object",
required: [
"$ref"
]
},
then: {
$ref: "#/$defs/reference"
},
"else": {
$ref: "#/$defs/response"
}
},
callbacks: {
$comment: "https://spec.openapis.org/oas/v3.1.0#callback-object",
type: "object",
$ref: "#/$defs/specification-extensions",
additionalProperties: {
$ref: "#/$defs/path-item-or-reference"
}
},
"callbacks-or-reference": {
"if": {
type: "object",
required: [
"$ref"
]
},
then: {
$ref: "#/$defs/reference"
},
"else": {
$ref: "#/$defs/callbacks"
}
},
example: {
$comment: "https://spec.openapis.org/oas/v3.1.0#example-object",
type: "object",
properties: {
summary: {
type: "string"
},
description: {
type: "string"
},
value: true,
externalValue: {
type: "string",
format: "uri"
}
},
not: {
required: [
"value",
"externalValue"
]
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"example-or-reference": {
"if": {
type: "object",
required: [
"$ref"
]
},
then: {
$ref: "#/$defs/reference"
},
"else": {
$ref: "#/$defs/example"
}
},
link: {
$comment: "https://spec.openapis.org/oas/v3.1.0#link-object",
type: "object",
properties: {
operationRef: {
type: "string",
format: "uri-reference"
},
operationId: {
type: "string"
},
parameters: {
$ref: "#/$defs/map-of-strings"
},
requestBody: true,
description: {
type: "string"
},
body: {
$ref: "#/$defs/server"
}
},
oneOf: [
{
required: [
"operationRef"
]
},
{
required: [
"operationId"
]
}
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"link-or-reference": {
"if": {
type: "object",
required: [
"$ref"
]
},
then: {
$ref: "#/$defs/reference"
},
"else": {
$ref: "#/$defs/link"
}
},
header: {
$comment: "https://spec.openapis.org/oas/v3.1.0#header-object",
type: "object",
properties: {
description: {
type: "string"
},
required: {
"default": false,
type: "boolean"
},
deprecated: {
"default": false,
type: "boolean"
},
schema: {
$ref: "#/$defs/schema"
},
content: {
$ref: "#/$defs/content",
minProperties: 1,
maxProperties: 1
}
},
oneOf: [
{
required: [
"schema"
]
},
{
required: [
"content"
]
}
],
dependentSchemas: {
schema: {
properties: {
style: {
"default": "simple",
"const": "simple"
},
explode: {
"default": false,
type: "boolean"
}
},
$ref: "#/$defs/examples"
}
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"header-or-reference": {
"if": {
type: "object",
required: [
"$ref"
]
},
then: {
$ref: "#/$defs/reference"
},
"else": {
$ref: "#/$defs/header"
}
},
tag: {
$comment: "https://spec.openapis.org/oas/v3.1.0#tag-object",
type: "object",
properties: {
name: {
type: "string"
},
description: {
type: "string"
},
externalDocs: {
$ref: "#/$defs/external-documentation"
}
},
required: [
"name"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
reference: {
$comment: "https://spec.openapis.org/oas/v3.1.0#reference-object",
type: "object",
properties: {
$ref: {
type: "string",
format: "uri-reference"
},
summary: {
type: "string"
},
description: {
type: "string"
}
},
unevaluatedProperties: false
},
schema: {
$comment: "https://spec.openapis.org/oas/v3.1.0#schema-object",
$dynamicAnchor: "meta",
type: [
"object",
"boolean"
]
},
"security-scheme": {
$comment: "https://spec.openapis.org/oas/v3.1.0#security-scheme-object",
type: "object",
properties: {
type: {
"enum": [
"apiKey",
"http",
"mutualTLS",
"oauth2",
"openIdConnect"
]
},
description: {
type: "string"
}
},
required: [
"type"
],
allOf: [
{
$ref: "#/$defs/specification-extensions"
},
{
$ref: "#/$defs/security-scheme/$defs/type-apikey"
},
{
$ref: "#/$defs/security-scheme/$defs/type-http"
},
{
$ref: "#/$defs/security-scheme/$defs/type-http-bearer"
},
{
$ref: "#/$defs/security-scheme/$defs/type-oauth2"
},
{
$ref: "#/$defs/security-scheme/$defs/type-oidc"
}
],
unevaluatedProperties: false,
$defs: {
"type-apikey": {
"if": {
properties: {
type: {
"const": "apiKey"
}
},
required: [
"type"
]
},
then: {
properties: {
name: {
type: "string"
},
"in": {
"enum": [
"query",
"header",
"cookie"
]
}
},
required: [
"name",
"in"
]
}
},
"type-http": {
"if": {
properties: {
type: {
"const": "http"
}
},
required: [
"type"
]
},
then: {
properties: {
scheme: {
type: "string"
}
},
required: [
"scheme"
]
}
},
"type-http-bearer": {
"if": {
properties: {
type: {
"const": "http"
},
scheme: {
type: "string",
pattern: "^[Bb][Ee][Aa][Rr][Ee][Rr]$"
}
},
required: [
"type",
"scheme"
]
},
then: {
properties: {
bearerFormat: {
type: "string"
}
}
}
},
"type-oauth2": {
"if": {
properties: {
type: {
"const": "oauth2"
}
},
required: [
"type"
]
},
then: {
properties: {
flows: {
$ref: "#/$defs/oauth-flows"
}
},
required: [
"flows"
]
}
},
"type-oidc": {
"if": {
properties: {
type: {
"const": "openIdConnect"
}
},
required: [
"type"
]
},
then: {
properties: {
openIdConnectUrl: {
type: "string",
format: "uri"
}
},
required: [
"openIdConnectUrl"
]
}
}
}
},
"security-scheme-or-reference": {
"if": {
type: "object",
required: [
"$ref"
]
},
then: {
$ref: "#/$defs/reference"
},
"else": {
$ref: "#/$defs/security-scheme"
}
},
"oauth-flows": {
type: "object",
properties: {
implicit: {
$ref: "#/$defs/oauth-flows/$defs/implicit"
},
password: {
$ref: "#/$defs/oauth-flows/$defs/password"
},
clientCredentials: {
$ref: "#/$defs/oauth-flows/$defs/client-credentials"
},
authorizationCode: {
$ref: "#/$defs/oauth-flows/$defs/authorization-code"
}
},
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false,
$defs: {
implicit: {
type: "object",
properties: {
authorizationUrl: {
type: "string",
format: "uri"
},
refreshUrl: {
type: "string",
format: "uri"
},
scopes: {
$ref: "#/$defs/map-of-strings"
}
},
required: [
"authorizationUrl",
"scopes"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
password: {
type: "object",
properties: {
tokenUrl: {
type: "string",
format: "uri"
},
refreshUrl: {
type: "string",
format: "uri"
},
scopes: {
$ref: "#/$defs/map-of-strings"
}
},
required: [
"tokenUrl",
"scopes"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"client-credentials": {
type: "object",
properties: {
tokenUrl: {
type: "string",
format: "uri"
},
refreshUrl: {
type: "string",
format: "uri"
},
scopes: {
$ref: "#/$defs/map-of-strings"
}
},
required: [
"tokenUrl",
"scopes"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
},
"authorization-code": {
type: "object",
properties: {
authorizationUrl: {
type: "string",
format: "uri"
},
tokenUrl: {
type: "string",
format: "uri"
},
refreshUrl: {
type: "string",
format: "uri"
},
scopes: {
$ref: "#/$defs/map-of-strings"
}
},
required: [
"authorizationUrl",
"tokenUrl",
"scopes"
],
$ref: "#/$defs/specification-extensions",
unevaluatedProperties: false
}
}
},
"security-requirement": {
$comment: "https://spec.openapis.org/oas/v3.1.0#security-requirement-object",
type: "object",
additionalProperties: {
type: "array",
items: {
type: "string"
}
}
},
"specification-extensions": {
$comment: "https://spec.openapis.org/oas/v3.1.0#specification-extensions",
patternProperties: {
"^x-": true
}
},
examples: {
properties: {
example: true,
examples: {
type: "object",
additionalProperties: {
$ref: "#/$defs/example-or-reference"
}
}
}
},
"map-of-strings": {
type: "object",
additionalProperties: {
type: "string"
}
}
};
var OpenApi31 = {
$id,
$schema,
description,
type,
properties: properties$1,
required,
anyOf,
$ref,
unevaluatedProperties,
$defs
};
const OpenApiSpecifications = {
"2.0": Swagger20,
"3.0": OpenApi30,
"3.1": OpenApi31
};
const OpenApiVersions = Object.keys(OpenApiSpecifications);
const ERRORS$1 = {
EMPTY_OR_INVALID: "Can’t find JSON, YAML or filename in data",
// URI_MUST_BE_STRING: 'uri parameter or $id attribute must be a string',
OPENAPI_VERSION_NOT_SUPPORTED: "Can’t find supported Swagger/OpenAPI version in specification, version must be a string.",
INVALID_REFERENCE: "Can’t resolve reference: %s",
EXTERNAL_REFERENCE_NOT_FOUND: "Can’t resolve external reference: %s",
FILE_DOES_NOT_EXIST: "File does not exist: %s",
NO_CONTENT: "No content found"
};
function getDefaultExportFromCjs(x2) {
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
}
function details(specification) {
for (const version2 of new Set(OpenApiVersions)) {
const specificationType = version2 === "2.0" ? "swagger" : "openapi";
const value = specification[specificationType];
if (typeof value === "string" && value.startsWith(version2)) {
return {
version: version2,
specificationType,
specificationVersion: value
};
}
}
return {
version: void 0,
specificationType: void 0,
specificationVersion: void 0
};
}
function getEntrypoint(filesystem) {
return filesystem == null ? void 0 : filesystem.find((file) => file.isEntrypoint);
}
function unescapeJsonPointer(uri) {
return decodeURI(uri.replace(/~1/g, "/").replace(/~0/g, "~"));
}
function getSegmentsFromPath(path2) {
return (
// /paths/~1test
path2.split("/").slice(1).map(unescapeJsonPointer)
);
}
function traverse(specification, transform, path2 = []) {
const result = {};
for (const [key2, value] of Object.entries(specification)) {
const currentPath = [...path2, key2];
if (Array.isArray(value)) {
result[key2] = value.map((item, index2) => {
if (typeof item === "object" && item !== null) {
return traverse(item, transform, [...currentPath, index2.toString()]);
}
return item;
});
} else if (typeof value === "object" && value !== null) {
result[key2] = traverse(value, transform, currentPath);
} else {
result[key2] = value;
}
}
return transform(result, path2);
}
function getListOfReferences(specification) {
const references = [];
if (!specification || typeof specification !== "object") {
return references;
}
traverse(specification, (value) => {
if (value.$ref && typeof value.$ref === "string" && !value.$ref.startsWith("#")) {
references.push(value.$ref.split("#")[0]);
}
return value;
});
return [...new Set(references)];
}
function isFilesystem(value) {
return typeof value !== "undefined" && Array.isArray(value) && value.length > 0 && value.some((file) => file.isEntrypoint === true);
}
function normalize$2(specification) {
if (isFilesystem(specification)) {
return specification;
}
if (typeof specification === "string") {
try {
return JSON.parse(specification);
} catch (error2) {
return parse$8(specification, {
maxAliasCount: 1e4
});
}
}
return specification;
}
function makeFilesystem(value, overwrites = {}) {
if (isFilesystem(value)) {
return value;
}
const specification = normalize$2(value);
return [
{
isEntrypoint: true,
specification,
filename: null,
dir: "./",
references: getListOfReferences(specification),
...overwrites
}
];
}
function resolveReferences(input, options, file, errors2) {
if (errors2 === void 0) {
errors2 = [];
}
const clonedInput = structuredClone(input);
const filesystem = makeFilesystem(clonedInput);
const entrypoint = getEntrypoint(filesystem);
resolve2((file == null ? void 0 : file.specification) ?? entrypoint.specification, filesystem, file ?? entrypoint);
resolve2((file == null ? void 0 : file.specification) ?? entrypoint.specification, filesystem, file ?? entrypoint);
errors2 = errors2.filter((error2, index2, self2) => index2 === self2.findIndex((t2) => t2.message === error2.message && t2.code === error2.code));
return {
valid: errors2.length === 0,
errors: errors2,
schema: (file ?? getEntrypoint(filesystem)).specification
};
function resolve2(schema2, resolveFilesystem, resolveFile) {
let result;
Object.entries(schema2 ?? {}).forEach(([_2, value]) => {
if (schema2.$ref !== void 0) {
const target = resolveUri(schema2.$ref, options, resolveFile, resolveFilesystem, errors2);
if (target === void 0) {
return void 0;
}
delete schema2.$ref;
if (typeof target === "object") {
Object.keys(target).forEach((key2) => {
if (schema2[key2] === void 0) {
schema2[key2] = target[key2];
}
});
}
}
if (typeof value === "object" && !isCircular(value)) {
result = resolve2(value, resolveFilesystem, resolveFile);
}
});
return {
errors: (result == null ? void 0 : result.errors) ?? []
};
}
}
function isCircular(schema2) {
try {
JSON.stringify(schema2);
return false;
} catch (error2) {
return true;
}
}
function resolveUri(uri, options, file, filesystem, errors2) {
if (typeof uri !== "string") {
errors2.push({
code: "INVALID_REFERENCE",
message: ERRORS$1.INVALID_REFERENCE.replace("%s", uri)
});
return;
}
const [prefix, path2] = uri.split("#", 2);
const isDifferentFile = prefix !== file.filename;
if (prefix && isDifferentFile) {
const externalReference = filesystem.find((entry) => {
return entry.filename === prefix;
});
if (!externalReference) {
errors2.push({
code: "EXTERNAL_REFERENCE_NOT_FOUND",
message: ERRORS$1.EXTERNAL_REFERENCE_NOT_FOUND.replace("%s", prefix)
});
return;
}
const result = resolveReferences(filesystem, options, externalReference, errors2);
if (path2 === void 0) {
return result.schema;
}
return resolveUri(`#${path2}`, options, externalReference, filesystem, errors2);
}
const segments = getSegmentsFromPath(path2);
try {
return segments.reduce((acc, key2) => {
return acc[key2];
}, file.specification);
} catch (error2) {
errors2.push({
code: "INVALID_REFERENCE",
message: ERRORS$1.INVALID_REFERENCE.replace("%s", uri)
});
}
}
async function dereference(value, options) {
const filesystem = makeFilesystem(value);
const entrypoint = getEntrypoint(filesystem);
const result = resolveReferences(filesystem, options);
return {
specification: entrypoint.specification,
errors: result.errors,
schema: result.schema,
...details(entrypoint.specification)
};
}
async function load(value, options) {
var _a2, _b;
const errors2 = [];
let content2;
{
content2 = normalize$2(value);
}
if (content2 === void 0) {
errors2.push({
code: "NO_CONTENT",
message: ERRORS$1.NO_CONTENT
});
return {
specification: null,
filesystem: [],
errors: errors2
};
}
let filesystem = makeFilesystem(content2, {
filename: null
});
const newEntry = getEntrypoint(filesystem);
const listOfReferences = newEntry.references ?? getListOfReferences(content2);
if (listOfReferences.length === 0) {
return {
specification: (_a2 = getEntrypoint(filesystem)) == null ? void 0 : _a2.specification,
filesystem,
errors: errors2
};
}
for (const reference of listOfReferences) {
{
continue;
}
}
return {
specification: (_b = getEntrypoint(filesystem)) == null ? void 0 : _b.specification,
filesystem,
errors: errors2
};
}
function upgradeFromThreeToThreeOne(originalSpecification) {
var _a2;
let specification = originalSpecification;
if ((_a2 = specification.openapi) == null ? void 0 : _a2.startsWith("3.0")) {
specification.openapi = "3.1.0";
} else {
return specification;
}
specification = traverse(specification, (schema2) => {
if (schema2.type !== "undefined" && schema2.nullable === true) {
schema2.type = ["null", schema2.type];
delete schema2.nullable;
}
return schema2;
});
specification = traverse(specification, (schema2) => {
if (schema2.exclusiveMinimum === true) {
schema2.exclusiveMinimum = schema2.minimum;
delete schema2.minimum;
} else if (schema2.exclusiveMinimum === false) {
delete schema2.exclusiveMinimum;
}
if (schema2.exclusiveMaximum === true) {
schema2.exclusiveMaximum = schema2.maximum;
delete schema2.maximum;
} else if (schema2.exclusiveMaximum === false) {
delete schema2.exclusiveMaximum;
}
return schema2;
});
specification = traverse(specification, (schema2, path2) => {
if (schema2.example !== void 0) {
if (isSchemaPath(path2)) {
schema2.examples = [schema2.example];
} else {
schema2.examples = {
default: schema2.example
};
}
delete schema2.example;
}
return schema2;
});
specification = traverse(specification, (schema2) => {
if (schema2.type === "object" && schema2.properties !== void 0) {
const entries2 = Object.entries(schema2.properties);
for (const [_2, value] of entries2) {
if (typeof value === "object" && value.type === "string" && value.format === "binary") {
value.contentEncoding = "application/octet-stream";
delete value.format;
}
}
}
return schema2;
});
specification = traverse(specification, (schema2) => {
if (schema2.type === "string" && schema2.format === "binary") {
return void 0;
}
return schema2;
});
specification = traverse(specification, (schema2) => {
if (schema2.type === "string" && schema2.format === "base64") {
return {
type: "string",
contentEncoding: "base64"
};
}
return schema2;
});
return specification;
}
function isSchemaPath(path2) {
const schemaLocations = [
["components", "schemas"],
"properties",
"items",
"allOf",
"anyOf",
"oneOf",
"not",
"additionalProperties"
];
return schemaLocations.some((location2) => {
if (Array.isArray(location2)) {
return location2.every((segment, index2) => path2[index2] === segment);
}
return path2.includes(location2);
}) || path2.includes("schema") || path2.some((segment) => segment.endsWith("Schema"));
}
function upgradeFromTwoToThree(specification) {
var _a2, _b, _c;
if ((_a2 = specification.swagger) == null ? void 0 : _a2.startsWith("2.0")) {
specification.openapi = "3.0.3";
delete specification.swagger;
} else {
return specification;
}
console.warn(`[upgradeFromTwoToThree] The upgrade from Swagger 2.0 to OpenAPI 3.0 documents is experimental and lacks features.`);
if (specification.host) {
const schemes = ((_b = specification.schemes) == null ? void 0 : _b.length) ? specification.schemes : ["http"];
specification.servers = schemes.map((scheme) => ({
url: `${scheme}://${specification.host}${specification.basePath ?? ""}`
}));
delete specification.basePath;
delete specification.schemes;
delete specification.host;
}
if (specification.definitions) {
if (typeof specification.components !== "object") {
specification.components = {};
}
specification.components.schemas = specification.definitions;
delete specification.definitions;
specification = traverse(specification, (schema2) => {
var _a3;
if ((_a3 = schema2.$ref) == null ? void 0 : _a3.startsWith("#/definitions/")) {
schema2.$ref = schema2.$ref.replace(/^#\/definitions\//, "#/components/schemas/");
}
return schema2;
});
}
if (specification.paths) {
for (const path2 in specification.paths) {
if (Object.hasOwn(specification.paths, path2)) {
const pathItem = specification.paths[path2];
for (const method in pathItem) {
if (Object.hasOwn(pathItem, method)) {
const operationItem = pathItem[method];
if (operationItem.parameters) {
const bodyParameter = structuredClone(operationItem.parameters.find((parameter) => parameter.in === "body") ?? {});
if (bodyParameter && Object.keys(bodyParameter).length) {
delete bodyParameter.name;
delete bodyParameter.in;
const consumes = specification.consumes ?? operationItem.consumes ?? ["application/json"];
if (typeof operationItem.requestBody !== "object") {
operationItem.requestBody = {};
}
if (typeof operationItem.requestBody.content !== "object") {
operationItem.requestBody.content = {};
}
const { schema: schema2, ...requestBody } = bodyParameter;
operationItem.requestBody = {
...operationItem.requestBody,
...requestBody
};
for (const type2 of consumes) {
operationItem.requestBody.content[type2] = {
schema: schema2
};
}
}
operationItem.parameters = operationItem.parameters.filter((parameter) => parameter.in !== "body");
delete operationItem.consumes;
const formDataParameters = operationItem.parameters.filter((parameter) => parameter.in === "formData");
if (formDataParameters.length > 0) {
if (typeof operationItem.requestBody !== "object") {
operationItem.requestBody = {};
}
if (typeof operationItem.requestBody.content !== "object") {
operationItem.requestBody.content = {};
}
operationItem.requestBody.content["application/x-www-form-urlencoded"] = {
schema: {
type: "object",
properties: {},
required: []
// Initialize required array
}
};
for (const param of formDataParameters) {
operationItem.requestBody.content["application/x-www-form-urlencoded"].schema.properties[param.name] = {
type: param.type,
description: param.description
};
if (param.required) {
operationItem.requestBody.content["application/x-www-form-urlencoded"].schema.required.push(param.name);
}
}
operationItem.parameters = operationItem.parameters.filter((parameter) => parameter.in !== "formData");
}
}
if (operationItem.responses) {
for (const response in operationItem.responses) {
if (Object.hasOwn(operationItem.responses, response)) {
const responseItem = operationItem.responses[response];
if (responseItem.schema) {
const produces = specification.produces ?? operationItem.produces ?? ["application/json"];
if (typeof responseItem.content !== "object") {
responseItem.content = {};
}
for (const type2 of produces) {
responseItem.content[type2] = {
schema: responseItem.schema
};
}
delete responseItem.schema;
}
}
}
}
delete operationItem.produces;
if (((_c = operationItem.parameters) == null ? void 0 : _c.length) === 0) {
delete operationItem.parameters;
}
}
}
}
}
}
if (specification.securityDefinitions) {
if (typeof specification.components !== "object") {
specification.components = {};
}
specification.components.securitySchemes = {};
for (const [key2, securityScheme] of Object.entries(specification.securityDefinitions)) {
if (typeof securityScheme === "object") {
if ("type" in securityScheme && securityScheme.type === "oauth2") {
const { flow, authorizationUrl: authorizationUrl2, tokenUrl: tokenUrl2, scopes } = securityScheme;
specification.components.securitySchemes[key2] = {
type: "oauth2",
flows: {
[flow]: {
...authorizationUrl2 && { authorizationUrl: authorizationUrl2 },
...tokenUrl2 && { tokenUrl: tokenUrl2 },
...scopes && { scopes }
}
}
};
} else {
specification.components.securitySchemes[key2] = securityScheme;
}
}
}
delete specification.securityDefinitions;
}
return specification;
}
function upgrade(value) {
const upgraders = [upgradeFromTwoToThree, upgradeFromThreeToThreeOne];
const result = upgraders.reduce((currentSpecification, upgrader) => upgrader(currentSpecification), getEntrypoint(makeFilesystem(value)).specification);
return {
specification: result,
// TODO: Make dynamic
version: "3.1"
};
}
const convertOauth2Flows = (security, nameKey) => {
if (security.type === "oauth2") {
const entries2 = Object.entries(security.flows ?? {});
if (entries2.length) {
const [[type2, flow]] = entries2;
return {
...security,
nameKey,
flow: {
...flow,
type: type2
}
};
}
}
return {
...security,
nameKey
};
};
const parseSchema = async (spec) => {
const { filesystem } = await load(spec);
const { specification } = upgrade(filesystem);
const { schema: schema2, errors: errors2 = [] } = await dereference(specification);
return { schema: schema2, errors: errors2 };
};
async function importSpecToWorkspace(spec, { documentUrl, watchForChanges, preferredSecurityScheme } = {}) {
var _a2, _b, _c, _d, _e;
const { schema: schema2, errors: errors2 } = await parseSchema(spec);
const importWarnings = [...errors2.map((e2) => e2.message)];
if (!schema2)
return { importWarnings, error: true };
const requests = [];
const servers = serverSchema.array().parse(((_a2 = schema2.servers) == null ? void 0 : _a2.map((s3) => s3 ?? [
{
url: typeof window !== "undefined" ? window.location.origin : "http://localhost",
description: "Replace with your API server"
}
])) ?? []);
const tagNames = /* @__PURE__ */ new Set();
const security = ((_b = schema2.components) == null ? void 0 : _b.securitySchemes) ?? (schema2 == null ? void 0 : schema2.securityDefinitions) ?? {};
const securitySchemes = (_d = (_c = Object.entries(security)).map) == null ? void 0 : _d.call(_c, ([nameKey, s3]) => {
const scheme = schemaModel(
// We must convert flows to a singular object, technically not spec compliant so we grab the first
s3.type === "oauth2" ? convertOauth2Flows(s3, nameKey) : {
...s3,
nameKey
},
securitySchemeSchema,
false
);
if (!scheme)
importWarnings.push(`Security scheme ${nameKey} is invalid.`);
return scheme;
}).filter((v2) => !!v2);
const securitySchemeMap = {};
securitySchemes.forEach((s3) => {
securitySchemeMap[s3.nameKey] = s3.uid;
});
keysOf(schema2.paths ?? {}).forEach((pathString) => {
var _a3;
const path2 = (_a3 = schema2 == null ? void 0 : schema2.paths) == null ? void 0 : _a3[pathString];
if (!path2)
return;
const pathServers = serverSchema.array().parse(path2.servers ?? []);
servers.push(...pathServers);
requestMethods.forEach((method) => {
var _a4;
const operation = path2[method];
if (operation && typeof operation === "object") {
const operationServers = serverSchema.array().parse(operation.servers ?? []);
servers.push(...operationServers);
(_a4 = operation.tags) == null ? void 0 : _a4.forEach((t2) => tagNames.add(t2));
const { security: operationSecurity, ...operationWithoutSecurity } = operation;
const securityRequirements = (operationSecurity ?? schema2.security ?? []).flatMap((s3) => {
const keys2 = Object.keys(s3);
if (keys2.length)
return keys2[0];
else
return [];
});
let selectedSecuritySchemeUids = [];
if (securityRequirements.length) {
const name2 = preferredSecurityScheme && securityRequirements.includes(preferredSecurityScheme ?? "") ? preferredSecurityScheme : securityRequirements[0];
const uid2 = securitySchemeMap[name2];
selectedSecuritySchemeUids = [uid2];
}
const requestPayload = {
...operationWithoutSecurity,
method,
path: pathString,
selectedSecuritySchemeUids,
// Merge path and operation level parameters
parameters: [
...(path2 == null ? void 0 : path2.parameters) ?? [],
...operation.parameters ?? []
],
servers: [...pathServers, ...operationServers].map((s3) => s3.uid)
};
if (operationSecurity == null ? void 0 : operationSecurity.length)
requestPayload.security = operationSecurity.map((s3) => {
const keys2 = Object.keys(s3);
if (keys2.length) {
const [key2] = Object.keys(s3);
return {
[key2]: s3[key2]
};
} else
return s3;
});
const request = schemaModel(requestPayload, requestSchema, false);
if (!request)
importWarnings.push(`${method} Request at ${path2} is invalid.`);
else
requests.push(request);
}
});
});
const tags2 = schemaModel((schema2 == null ? void 0 : schema2.tags) ?? [], tagSchema.array(), false) ?? [];
tags2.forEach((t2) => tagNames.delete(t2.name));
tagNames.forEach((name2) => tags2.push(tagSchema.parse({ name: name2 })));
const tagMap = {};
tags2.forEach((t2) => {
tagMap[t2.name] = t2;
});
const collectionChildren = new Set(tags2.map((t2) => t2.uid));
tags2.forEach((t2) => {
var _a3;
(_a3 = t2["x-scalar-children"]) == null ? void 0 : _a3.forEach((c2) => {
const nestedUid = tagMap[c2.tagName].uid;
t2.children.push(nestedUid);
collectionChildren.delete(nestedUid);
});
});
requests.forEach((r2) => {
if (r2.tags) {
r2.tags.forEach((t2) => {
tagMap[t2].children.push(r2.uid);
});
} else {
collectionChildren.add(r2.uid);
}
});
const examples = [];
requests.forEach((request) => {
const example = createExampleFromRequest(request, "Default Example");
examples.push(example);
request.examples.push(example.uid);
});
const auth = securitySchemes == null ? void 0 : securitySchemes.reduce((prev, s3) => {
const example = authExampleFromSchema(s3);
if (example)
prev[s3.uid] = example;
return prev;
}, {});
const collection = collectionSchema.parse({
...schema2,
watchForChanges,
documentUrl,
auth,
requests: requests.map((r2) => r2.uid),
servers: servers.map((s3) => s3.uid),
tags: tags2.map((t2) => t2.uid),
children: [...collectionChildren],
security: schema2.security ?? [{}],
selectedServerUid: (_e = servers == null ? void 0 : servers[0]) == null ? void 0 : _e.uid,
components: {
...schema2.components
},
securitySchemes: securitySchemes.map((s3) => s3.uid)
});
return {
error: false,
servers,
schema: schema2,
requests,
examples,
collection,
tags: tags2,
securitySchemes
};
}
const specDictionary = {};
function importSpecFileFactory({
requestMutators,
collectionMutators,
serverMutators,
tagMutators,
securitySchemeMutators,
requestExampleMutators,
workspaceMutators,
workspaces
}) {
const importSpecFile = async (_spec, workspaceUid, {
documentUrl,
watchForChanges = false,
overloadServers,
preferredSecurityScheme
} = {}) => {
var _a2;
const spec = toRaw(_spec);
if ((overloadServers == null ? void 0 : overloadServers.length) && typeof spec === "object")
spec.servers = overloadServers;
const workspaceEntities = await importSpecToWorkspace(spec, {
documentUrl,
preferredSecurityScheme,
watchForChanges
});
if (workspaceEntities.error) {
console.group("IMPORT ERRORS");
workspaceEntities.importWarnings.forEach((w2) => console.warn(w2));
console.groupEnd();
return void 0;
}
if (documentUrl && typeof spec === "string") {
specDictionary[documentUrl] = {
hash: createHash(spec),
schema: workspaceEntities.schema
};
}
workspaceEntities.examples.forEach((e2) => requestExampleMutators.add(e2));
workspaceEntities.requests.forEach((r2) => requestMutators.add(r2));
workspaceEntities.tags.forEach((t2) => tagMutators.add(t2));
workspaceEntities.servers.forEach((s3) => serverMutators.add(s3));
workspaceEntities.securitySchemes.forEach(
(s3) => securitySchemeMutators.add(s3)
);
collectionMutators.add(workspaceEntities.collection);
workspaceMutators.edit(workspaceUid, "collections", [
...((_a2 = workspaces[workspaceUid]) == null ? void 0 : _a2.collections) ?? [],
workspaceEntities.collection.uid
]);
return workspaceEntities.collection;
};
async function importSpecFromUrl(url, workspaceUid, {
proxy,
overloadServers,
watchForChanges = false,
preferredSecurityScheme
} = {}) {
try {
const spec = await fetchSpecFromUrl(url, proxy);
return [
null,
await importSpecFile(spec, workspaceUid, {
documentUrl: url,
overloadServers,
watchForChanges,
preferredSecurityScheme
})
];
} catch (error2) {
console.error("Failed to fetch spec from URL:", error2);
return [normalizeError(error2), null];
}
}
return {
importSpecFile,
importSpecFromUrl
};
}
function createStoreRequestExamples(useLocalStorage) {
const requestExamples = reactive({});
const requestExampleMutators = mutationFactory(
requestExamples,
reactive({}),
useLocalStorage && LS_KEYS.REQUEST_EXAMPLE
);
return {
requestExamples,
requestExampleMutators
};
}
function extendedExampleDataFactory({
requestExamples,
requestExampleMutators,
requestMutators,
requests
}) {
const addRequestExample = (request, _name) => {
const name2 = _name ?? iterateTitle(
(request.summary ?? "Example") + " #1",
(t2) => request.examples.some((uid2) => t2 === requestExamples[uid2].name)
);
const example = createExampleFromRequest(request, name2);
requestExampleMutators.add(example);
requestMutators.edit(request.uid, "examples", [
...request.examples,
example.uid
]);
return example;
};
const deleteRequestExample = (requestExample) => {
requestMutators.edit(
requestExample.requestUid,
"examples",
requests[requestExample.requestUid].examples.filter(
(uid2) => uid2 !== requestExample.uid
)
);
requestExampleMutators.delete(requestExample.uid);
};
return {
addRequestExample,
deleteRequestExample
};
}
function createStoreRequests(useLocalStorage) {
const requests = reactive({});
const requestMutators = mutationFactory(
requests,
reactive({}),
useLocalStorage && LS_KEYS.REQUEST
);
return {
requests,
requestMutators
};
}
function extendedRequestDataFactory({
requestExamples,
requestExampleMutators,
requestMutators,
collectionMutators,
collections,
tags: tags2,
tagMutators
}, addTag) {
const addRequest = (payload, collectionUid) => {
var _a2;
const request = schemaModel(payload, requestSchema, false);
if (!request) return console.error("INVALID REQUEST DATA", payload);
const collection = collections[collectionUid];
const example = createExampleFromRequest(
request,
iterateTitle(
(request.summary ?? "Example") + " #1",
(t2) => request.examples.some((uid2) => t2 === requestExamples[uid2].name)
)
);
request.examples.push(example.uid);
requestMutators.add(request);
requestExampleMutators.add(example);
collectionMutators.edit(collectionUid, "requests", [
...collection.requests,
request.uid
]);
if ((_a2 = request.tags) == null ? void 0 : _a2.length)
request.tags.forEach((tagName2) => {
const tagUid = collection.tags.find((uid2) => tags2[uid2].name === tagName2);
if (tagUid)
tagMutators.edit(tagUid, "children", [
...tags2[tagUid].children,
request.uid
]);
else addTag({ name: tagName2, children: [request.uid] }, collectionUid);
});
else
collectionMutators.edit(collectionUid, "children", [
...collection.children,
request.uid
]);
return request;
};
const deleteRequest = (request, collectionUid) => {
var _a2;
const collection = collections[collectionUid];
request.examples.forEach((uid2) => requestExampleMutators.delete(uid2));
collectionMutators.edit(
collectionUid,
"requests",
collection.requests.filter((r2) => r2 !== request.uid)
);
collectionMutators.edit(
collectionUid,
"children",
collection.children.filter((r2) => r2 !== request.uid)
);
(_a2 = request.tags) == null ? void 0 : _a2.forEach((tagName2) => {
const tagUid = collection.tags.find((uid2) => tags2[uid2].name === tagName2);
if (!tagUid) return;
tagMutators.edit(
tagUid,
"children",
tags2[tagUid].children.filter((r2) => r2 !== request.uid)
);
});
requestMutators.delete(request.uid);
};
return {
addRequest,
deleteRequest,
findRequestParents: findRequestParentsFactory({ collections, tags: tags2 })
};
}
function findRequestParentsFactory({
collections,
tags: tags2
}) {
function findRequestParentss(r2) {
const collection = Object.values(collections).find(
(c2) => {
var _a2;
retu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment