From da2fc60c8069ed32b4f2d934a2f3d5895571d63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pinho?= Date: Sat, 21 Mar 2026 20:56:00 +0000 Subject: [PATCH] Add pricing playground to documentation Add interactive pricing playground with build script, sidebar link that opens in new tab, and static assets. Include update-playground npm script to rebuild demo from pricing repo. --- docs/pricing/README.mdx | 2 +- docusaurus.config.js | 2 + package.json | 3 +- scripts/update-pricing-playground.sh | 29 ++ sidebars.js | 21 +- src/clientModules/playgroundNewTab.js | 20 + .../assets/index-DBk_NkYK.css | 1 + .../assets/index-DOCEUpWZ.js | 484 ++++++++++++++++++ static/pricing-playground/index.html | 14 + 9 files changed, 573 insertions(+), 3 deletions(-) create mode 100755 scripts/update-pricing-playground.sh create mode 100644 src/clientModules/playgroundNewTab.js create mode 100644 static/pricing-playground/assets/index-DBk_NkYK.css create mode 100644 static/pricing-playground/assets/index-DOCEUpWZ.js create mode 100644 static/pricing-playground/index.html diff --git a/docs/pricing/README.mdx b/docs/pricing/README.mdx index a59c9608..99502e46 100644 --- a/docs/pricing/README.mdx +++ b/docs/pricing/README.mdx @@ -3,7 +3,7 @@ title: Overview sidebar_position: 0 --- -[[API Docs](/api/pricing)] [[SDK](https://www.npmjs.com/package/@epilot/pricing-client)] +[[API Docs](/api/pricing)] [[SDK](https://www.npmjs.com/package/@epilot/pricing-client)] [[Pricing Demo Playground](/pricing-playground/index.html)] # Pricing diff --git a/docusaurus.config.js b/docusaurus.config.js index 02f0eb72..8c708c87 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -54,6 +54,8 @@ const DOCS_URL = process.env.DOCS_URL || 'https://docs.epilot.io'; ], ], + clientModules: [require.resolve('./src/clientModules/playgroundNewTab.js')], + plugins: [ function mermaidAliasPlugin() { return { diff --git a/package.json b/package.json index 3e7ae202..4695a652 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "update-entities": "cp ../entity-api/lambda/ApiHandlerFunction/src/schema/blueprints/snapshots/* static/schemas/", "update-events": "cp ../event-catalog-api/packages/core/src/builtin-events/__snapshots__/* static/events", "update-sdk": "./scripts/update-sdk-docs.sh", - "update-cli": "./scripts/update-cli-docs.sh" + "update-cli": "./scripts/update-cli-docs.sh", + "update-playground": "./scripts/update-pricing-playground.sh" }, "dependencies": { "@cmfcmf/docusaurus-search-local": "^0.10.0", diff --git a/scripts/update-pricing-playground.sh b/scripts/update-pricing-playground.sh new file mode 100755 index 00000000..3eeb5628 --- /dev/null +++ b/scripts/update-pricing-playground.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -euo pipefail + +# THIS SCRIPT ASSUMES you are within the codebase repo. + +# Rebuild the pricing demo and copy the output to the docs static folder. +# Usage: npm run update-playground (from the docs root) + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +DOCS_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +PRICING_DEMO="$DOCS_ROOT/../pricing/demo" +TARGET="$DOCS_ROOT/static/pricing-playground" + +if [ ! -d "$PRICING_DEMO" ]; then + echo "ERROR: pricing demo not found at $PRICING_DEMO" + exit 1 +fi + +echo "→ Installing pricing demo dependencies..." +(cd "$PRICING_DEMO" && npm install --no-audit --no-fund) + +echo "→ Building pricing demo..." +(cd "$PRICING_DEMO" && npx tsc -b && npx vite build) + +echo "→ Copying build output to $TARGET..." +rm -rf "$TARGET" +cp -r "$PRICING_DEMO/dist" "$TARGET" + +echo "✓ Pricing playground updated at static/pricing-playground/" diff --git a/sidebars.js b/sidebars.js index 7cc26dc3..6a416080 100644 --- a/sidebars.js +++ b/sidebars.js @@ -9,6 +9,10 @@ * Create as many sidebars as you want. */ +const DOCS_URL = process.env.DOCS_URL || 'https://docs.epilot.io'; + +const PLAYGROUND_URL = `${DOCS_URL}/pricing-playground/index.html`; + module.exports = { docsSidebar: [ 'intro', @@ -133,7 +137,22 @@ module.exports = { collapsible: true, collapsed: true, items: [ - { type: 'autogenerated', dirName: 'pricing' }, + 'pricing/README', + { + type: 'category', + label: 'Pricing Library', + items: [{ type: 'autogenerated', dirName: 'pricing/pricing-library' }], + }, + { + type: 'link', + label: 'Pricing Playground', + href: PLAYGROUND_URL, + }, + 'pricing/entities', + 'pricing/catalog', + 'pricing/orders', + 'pricing/ecommerce', + 'pricing/pricing-models', { type: 'autogenerated', dirName: 'deadlines' }, ], }, diff --git a/src/clientModules/playgroundNewTab.js b/src/clientModules/playgroundNewTab.js new file mode 100644 index 00000000..ea45e7c5 --- /dev/null +++ b/src/clientModules/playgroundNewTab.js @@ -0,0 +1,20 @@ +// Opens the Pricing Playground sidebar link in a new tab. +// Docusaurus sidebar `link` items don't support target="_blank" natively. + +if (typeof window !== 'undefined') { + const PLAYGROUND_PATH = '/pricing-playground/'; + + const observer = new MutationObserver(() => { + document.querySelectorAll('.menu__link[href*="' + PLAYGROUND_PATH + '"]').forEach((link) => { + if (!link.getAttribute('target')) { + link.setAttribute('target', '_blank'); + link.setAttribute('rel', 'noopener noreferrer'); + } + }); + }); + + observer.observe(document.documentElement, { + childList: true, + subtree: true, + }); +} diff --git a/static/pricing-playground/assets/index-DBk_NkYK.css b/static/pricing-playground/assets/index-DBk_NkYK.css new file mode 100644 index 00000000..8f5db964 --- /dev/null +++ b/static/pricing-playground/assets/index-DBk_NkYK.css @@ -0,0 +1 @@ +*,: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: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}html{scroll-behavior:smooth}.card{border-radius:.75rem;border-width:1px;--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem;--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 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)}.input-field{width:100%;border-radius:.5rem;border-width:1px;--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));padding:.5rem .75rem;font-size:.875rem;line-height:1.25rem;outline:2px solid transparent;outline-offset:2px;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.input-field:focus{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 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(2px + 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);--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity, 1))}.select-field{width:100%;border-radius:.5rem;border-width:1px;--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:.5rem .75rem;font-size:.875rem;line-height:1.25rem;outline:2px solid transparent;outline-offset:2px;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.select-field:focus{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 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(2px + 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);--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity, 1))}.btn-primary{border-radius:.5rem;--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1));padding:.5rem 1rem;font-size:.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1));transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.btn-primary:hover{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity, 1))}.btn-secondary{border-radius:.5rem;--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));padding:.5rem 1rem;font-size:.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1));transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.btn-secondary:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.result-label{font-size:.75rem;line-height:1rem;font-weight:500;text-transform:uppercase;letter-spacing:.05em;--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.badge-blue{display:inline-flex;align-items:center;border-radius:9999px;padding:.125rem .625rem;font-size:.75rem;line-height:1rem;font-weight:500;--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.badge-green{display:inline-flex;align-items:center;border-radius:9999px;padding:.125rem .625rem;font-size:.75rem;line-height:1rem;font-weight:500;--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.badge-amber{display:inline-flex;align-items:center;border-radius:9999px;padding:.125rem .625rem;font-size:.75rem;line-height:1rem;font-weight:500;--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.section-title{margin-bottom:.5rem;font-size:1.5rem;line-height:2rem;font-weight:700;--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.section-desc{margin-bottom:1.5rem;--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.fixed{position:fixed}.sticky{position:sticky}.top-0{top:0}.z-10{z-index:10}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-10{margin-bottom:2.5rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.mr-2{margin-right:.5rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-10{margin-top:2.5rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.inline-block{display:inline-block}.flex{display:flex}.table{display:table}.grid{display:grid}.h-10{height:2.5rem}.h-12{height:3rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-48{height:12rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-\[400px\]{max-height:400px}.w-0{width:0px}.w-10{width:2.5rem}.w-12{width:3rem}.w-16{width:4rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[180px\]{min-width:180px}.max-w-2xl{max-width:42rem}.max-w-6xl{max-width:72rem}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-\[2px\]{gap:2px}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-100>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(243 244 246 / var(--tw-divide-opacity, 1))}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.rounded-t-md{border-top-left-radius:.375rem;border-top-right-radius:.375rem}.rounded-t-sm{border-top-left-radius:.125rem;border-top-right-radius:.125rem}.border{border-width:1px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-r-2{border-right-width:2px}.border-t{border-top-width:1px}.border-none{border-style:none}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-current{border-color:currentColor}.border-cyan-200{--tw-border-opacity: 1;border-color:rgb(165 243 252 / var(--tw-border-opacity, 1))}.border-emerald-200{--tw-border-opacity: 1;border-color:rgb(167 243 208 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(249 250 251 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-indigo-200{--tw-border-opacity: 1;border-color:rgb(199 210 254 / var(--tw-border-opacity, 1))}.border-orange-200{--tw-border-opacity: 1;border-color:rgb(254 215 170 / var(--tw-border-opacity, 1))}.border-pink-200{--tw-border-opacity: 1;border-color:rgb(251 207 232 / var(--tw-border-opacity, 1))}.border-primary-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-primary-600{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.border-purple-200{--tw-border-opacity: 1;border-color:rgb(233 213 255 / var(--tw-border-opacity, 1))}.border-teal-200{--tw-border-opacity: 1;border-color:rgb(153 246 228 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.bg-amber-400{--tw-bg-opacity: 1;background-color:rgb(251 191 36 / var(--tw-bg-opacity, 1))}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-cyan-50{--tw-bg-opacity: 1;background-color:rgb(236 254 255 / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(236 253 245 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-gray-800{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-indigo-400{--tw-bg-opacity: 1;background-color:rgb(129 140 248 / var(--tw-bg-opacity, 1))}.bg-indigo-50{--tw-bg-opacity: 1;background-color:rgb(238 242 255 / var(--tw-bg-opacity, 1))}.bg-orange-200{--tw-bg-opacity: 1;background-color:rgb(254 215 170 / var(--tw-bg-opacity, 1))}.bg-orange-400{--tw-bg-opacity: 1;background-color:rgb(251 146 60 / var(--tw-bg-opacity, 1))}.bg-orange-50{--tw-bg-opacity: 1;background-color:rgb(255 247 237 / var(--tw-bg-opacity, 1))}.bg-pink-400{--tw-bg-opacity: 1;background-color:rgb(244 114 182 / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(253 242 248 / var(--tw-bg-opacity, 1))}.bg-primary-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-primary-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-primary-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-primary-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-purple-400{--tw-bg-opacity: 1;background-color:rgb(192 132 252 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-red-200{--tw-bg-opacity: 1;background-color:rgb(254 202 202 / var(--tw-bg-opacity, 1))}.bg-red-300{--tw-bg-opacity: 1;background-color:rgb(252 165 165 / var(--tw-bg-opacity, 1))}.bg-red-400{--tw-bg-opacity: 1;background-color:rgb(248 113 113 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-teal-50{--tw-bg-opacity: 1;background-color:rgb(240 253 250 / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:transparent}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\/80{background-color:#fffc}.bg-yellow-400{--tw-bg-opacity: 1;background-color:rgb(250 204 21 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pl-6{padding-left:1.5rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[10px\]{font-size:10px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-extrabold{font-weight:800}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.leading-relaxed{line-height:1.625}.leading-tight{line-height:1.25}.tracking-wider{letter-spacing:.05em}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(243 244 246 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-indigo-500{--tw-text-opacity: 1;color:rgb(99 102 241 / var(--tw-text-opacity, 1))}.text-indigo-600{--tw-text-opacity: 1;color:rgb(79 70 229 / var(--tw-text-opacity, 1))}.text-indigo-700{--tw-text-opacity: 1;color:rgb(67 56 202 / var(--tw-text-opacity, 1))}.text-indigo-800{--tw-text-opacity: 1;color:rgb(55 48 163 / var(--tw-text-opacity, 1))}.text-orange-300{--tw-text-opacity: 1;color:rgb(253 186 116 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-orange-800{--tw-text-opacity: 1;color:rgb(154 52 18 / var(--tw-text-opacity, 1))}.text-pink-400{--tw-text-opacity: 1;color:rgb(244 114 182 / var(--tw-text-opacity, 1))}.text-primary-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-primary-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-sky-300{--tw-text-opacity: 1;color:rgb(125 211 252 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-300{--tw-text-opacity: 1;color:rgb(253 224 71 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.line-through{text-decoration-line:line-through}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.accent-amber-500{accent-color:#f59e0b}.accent-indigo-500{accent-color:#6366f1}.accent-primary-600{accent-color:#2563eb}.accent-yellow-500{accent-color:#eab308}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-primary-200{--tw-shadow-color: #bfdbfe;--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.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)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-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)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.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}.transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\:bg-yellow-500:hover{--tw-bg-opacity: 1;background-color:rgb(234 179 8 / var(--tw-bg-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-md:hover{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.group:hover .group-hover\:text-primary-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}@media(min-width:1024px){.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}} diff --git a/static/pricing-playground/assets/index-DOCEUpWZ.js b/static/pricing-playground/assets/index-DOCEUpWZ.js new file mode 100644 index 00000000..76b30b29 --- /dev/null +++ b/static/pricing-playground/assets/index-DOCEUpWZ.js @@ -0,0 +1,484 @@ +(function(){const u=document.createElement("link").relList;if(u&&u.supports&&u.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))m(c);new MutationObserver(c=>{for(const h of c)if(h.type==="childList")for(const f of h.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&m(f)}).observe(document,{childList:!0,subtree:!0});function s(c){const h={};return c.integrity&&(h.integrity=c.integrity),c.referrerPolicy&&(h.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?h.credentials="include":c.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function m(c){if(c.ep)return;c.ep=!0;const h=s(c);fetch(c.href,h)}})();function Sc(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var ti={exports:{}},zr={},ni={exports:{}},fe={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var oc;function Ym(){if(oc)return fe;oc=1;var l=Symbol.for("react.element"),u=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),f=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),S=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),C=Symbol.iterator;function j(P){return P===null||typeof P!="object"?null:(P=C&&P[C]||P["@@iterator"],typeof P=="function"?P:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,A={};function T(P,O,ce){this.props=P,this.context=O,this.refs=A,this.updater=ce||v}T.prototype.isReactComponent={},T.prototype.setState=function(P,O){if(typeof P!="object"&&typeof P!="function"&&P!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,P,O,"setState")},T.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function U(){}U.prototype=T.prototype;function I(P,O,ce){this.props=P,this.context=O,this.refs=A,this.updater=ce||v}var _=I.prototype=new U;_.constructor=I,w(_,T.prototype),_.isPureReactComponent=!0;var $=Array.isArray,R=Object.prototype.hasOwnProperty,M={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function H(P,O,ce){var de,pe={},ge=null,ve=null;if(O!=null)for(de in O.ref!==void 0&&(ve=O.ref),O.key!==void 0&&(ge=""+O.key),O)R.call(O,de)&&!L.hasOwnProperty(de)&&(pe[de]=O[de]);var ae=arguments.length-2;if(ae===1)pe.children=ce;else if(1>>1,O=Y[P];if(0>>1;Pc(pe,Z))gec(ve,pe)?(Y[P]=ve,Y[ge]=Z,P=ge):(Y[P]=pe,Y[de]=Z,P=de);else if(gec(ve,Z))Y[P]=ve,Y[ge]=Z,P=ge;else break e}}return le}function c(Y,le){var Z=Y.sortIndex-le.sortIndex;return Z!==0?Z:Y.id-le.id}if(typeof performance=="object"&&typeof performance.now=="function"){var h=performance;l.unstable_now=function(){return h.now()}}else{var f=Date,x=f.now();l.unstable_now=function(){return f.now()-x}}var p=[],S=[],y=1,C=null,j=3,v=!1,w=!1,A=!1,T=typeof setTimeout=="function"?setTimeout:null,U=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(Y){for(var le=s(S);le!==null;){if(le.callback===null)m(S);else if(le.startTime<=Y)m(S),le.sortIndex=le.expirationTime,u(p,le);else break;le=s(S)}}function $(Y){if(A=!1,_(Y),!w)if(s(p)!==null)w=!0,De(R);else{var le=s(S);le!==null&&ke($,le.startTime-Y)}}function R(Y,le){w=!1,A&&(A=!1,U(H),H=-1),v=!0;var Z=j;try{for(_(le),C=s(p);C!==null&&(!(C.expirationTime>le)||Y&&!_e());){var P=C.callback;if(typeof P=="function"){C.callback=null,j=C.priorityLevel;var O=P(C.expirationTime<=le);le=l.unstable_now(),typeof O=="function"?C.callback=O:C===s(p)&&m(p),_(le)}else m(p);C=s(p)}if(C!==null)var ce=!0;else{var de=s(S);de!==null&&ke($,de.startTime-le),ce=!1}return ce}finally{C=null,j=Z,v=!1}}var M=!1,L=null,H=-1,te=5,Q=-1;function _e(){return!(l.unstable_now()-QY||125P?(Y.sortIndex=Z,u(S,Y),s(p)===null&&Y===s(S)&&(A?(U(H),H=-1):A=!0,ke($,Z-P))):(Y.sortIndex=O,u(p,Y),w||v||(w=!0,De(R))),Y},l.unstable_shouldYield=_e,l.unstable_wrapCallback=function(Y){var le=j;return function(){var Z=j;j=le;try{return Y.apply(this,arguments)}finally{j=Z}}}})(li)),li}var dc;function tf(){return dc||(dc=1,ai.exports=ef()),ai.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var mc;function nf(){if(mc)return it;mc=1;var l=fi(),u=tf();function s(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,S=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,y={},C={};function j(e){return p.call(C,e)?!0:p.call(y,e)?!1:S.test(e)?C[e]=!0:(y[e]=!0,!1)}function v(e,t,n,a){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return a?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function w(e,t,n,a){if(t===null||typeof t>"u"||v(e,t,n,a))return!0;if(a)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function A(e,t,n,a,o,i,d){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=a,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=d}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){T[e]=new A(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];T[t]=new A(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){T[e]=new A(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){T[e]=new A(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){T[e]=new A(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){T[e]=new A(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){T[e]=new A(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){T[e]=new A(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){T[e]=new A(e,5,!1,e.toLowerCase(),null,!1,!1)});var U=/[\-:]([a-z])/g;function I(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(U,I);T[t]=new A(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(U,I);T[t]=new A(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(U,I);T[t]=new A(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){T[e]=new A(e,1,!1,e.toLowerCase(),null,!1,!1)}),T.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){T[e]=new A(e,1,!1,e.toLowerCase(),null,!0,!0)});function _(e,t,n,a){var o=T.hasOwnProperty(t)?T[t]:null;(o!==null?o.type!==0:a||!(2g||o[d]!==i[g]){var N=` +`+o[d].replace(" at new "," at ");return e.displayName&&N.includes("")&&(N=N.replace("",e.displayName)),N}while(1<=d&&0<=g);break}}}finally{ce=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?O(e):""}function pe(e){switch(e.tag){case 5:return O(e.type);case 16:return O("Lazy");case 13:return O("Suspense");case 19:return O("SuspenseList");case 0:case 2:case 15:return e=de(e.type,!1),e;case 11:return e=de(e.type.render,!1),e;case 1:return e=de(e.type,!0),e;default:return""}}function ge(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case L:return"Fragment";case M:return"Portal";case te:return"Profiler";case H:return"StrictMode";case Te:return"Suspense";case Ie:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _e:return(e.displayName||"Context")+".Consumer";case Q:return(e._context.displayName||"Context")+".Provider";case xe:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Je:return t=e.displayName||null,t!==null?t:ge(e.type)||"Memo";case De:t=e._payload,e=e._init;try{return ge(e(t))}catch{}}return null}function ve(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ge(t);case 8:return t===H?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function ae(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function me(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ee(e){var t=me(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),a=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(d){a=""+d,i.call(this,d)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return a},setValue:function(d){a=""+d},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function St(e){e._valueTracker||(e._valueTracker=Ee(e))}function cn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),a="";return e&&(a=me(e)?e.checked?"true":"false":e.value),e=a,e!==n?(t.setValue(e),!0):!1}function dn(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Sn(e,t){var n=t.checked;return Z({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function An(e,t){var n=t.defaultValue==null?"":t.defaultValue,a=t.checked!=null?t.checked:t.defaultChecked;n=ae(t.value!=null?t.value:n),e._wrapperState={initialChecked:a,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ft(e,t){t=t.checked,t!=null&&_(e,"checked",t,!1)}function mn(e,t){Ft(e,t);var n=ae(t.value),a=t.type;if(n!=null)a==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(a==="submit"||a==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ul(e,t.type,n):t.hasOwnProperty("defaultValue")&&ul(e,t.type,ae(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Wt(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var a=t.type;if(!(a!=="submit"&&a!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ul(e,t,n){(t!=="number"||dn(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var tr=Array.isArray;function Pn(e,t,n,a){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=Gr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function nr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var rr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ed=["Webkit","ms","Moz","O"];Object.keys(rr).forEach(function(e){ed.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),rr[t]=rr[e]})});function ji(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||rr.hasOwnProperty(e)&&rr[e]?(""+t).trim():t+"px"}function Ni(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var a=n.indexOf("--")===0,o=ji(n,t[n],a);n==="float"&&(n="cssFloat"),a?e.setProperty(n,o):e[n]=o}}var td=Z({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ml(e,t){if(t){if(td[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(s(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(s(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(s(61))}if(t.style!=null&&typeof t.style!="object")throw Error(s(62))}}function fl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var pl=null;function gl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var hl=null,Cn=null,Tn=null;function bi(e){if(e=wr(e)){if(typeof hl!="function")throw Error(s(280));var t=e.stateNode;t&&(t=ga(t),hl(e.stateNode,e.type,t))}}function ki(e){Cn?Tn?Tn.push(e):Tn=[e]:Cn=e}function wi(){if(Cn){var e=Cn,t=Tn;if(Tn=Cn=null,bi(e),t)for(e=0;e>>=0,e===0?32:31-(md(e)/fd|0)|0}var Xr=64,Zr=4194304;function ir(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Jr(e,t){var n=e.pendingLanes;if(n===0)return 0;var a=0,o=e.suspendedLanes,i=e.pingedLanes,d=n&268435455;if(d!==0){var g=d&~o;g!==0?a=ir(g):(i&=d,i!==0&&(a=ir(i)))}else d=n&~o,d!==0?a=ir(d):i!==0&&(a=ir(i));if(a===0)return 0;if(t!==0&&t!==a&&(t&o)===0&&(o=a&-a,i=t&-t,o>=i||o===16&&(i&4194240)!==0))return t;if((a&4)!==0&&(a|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=a;0n;n++)t.push(e);return t}function sr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-yt(t),e[t]=n}function _d(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var a=e.eventTimes;for(e=e.expirationTimes;0=hr),Ji=" ",es=!1;function ts(e,t){switch(e){case"keyup":return Hd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ns(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Rn=!1;function Qd(e,t){switch(e){case"compositionend":return ns(t);case"keypress":return t.which!==32?null:(es=!0,Ji);case"textInput":return e=t.data,e===Ji&&es?null:e;default:return null}}function Id(e,t){if(Rn)return e==="compositionend"||!Dl&&ts(e,t)?(e=Qi(),aa=Pl=Qt=null,Rn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=a}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=us(n)}}function ds(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ds(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ms(){for(var e=window,t=dn();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=dn(e.document)}return t}function $l(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function rm(e){var t=ms(),n=e.focusedElem,a=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ds(n.ownerDocument.documentElement,n)){if(a!==null&&$l(n)){if(t=a.start,e=a.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,i=Math.min(a.start,o);a=a.end===void 0?i:Math.min(a.end,o),!e.extend&&i>a&&(o=a,a=i,i=o),o=cs(n,i);var d=cs(n,a);o&&d&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==d.node||e.focusOffset!==d.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),i>a?(e.addRange(t),e.extend(d.node,d.offset)):(t.setEnd(d.node,d.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Dn=null,Ll=null,vr=null,Ol=!1;function fs(e,t,n){var a=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ol||Dn==null||Dn!==dn(a)||(a=Dn,"selectionStart"in a&&$l(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),vr&&yr(vr,a)||(vr=a,a=ma(Ll,"onSelect"),0On||(e.current=Xl[On],Xl[On]=null,On--)}function Ne(e,t){On++,Xl[On]=e.current,e.current=t}var Xt={},Ke=Yt(Xt),nt=Yt(!1),gn=Xt;function zn(e,t){var n=e.type.contextTypes;if(!n)return Xt;var a=e.stateNode;if(a&&a.__reactInternalMemoizedUnmaskedChildContext===t)return a.__reactInternalMemoizedMaskedChildContext;var o={},i;for(i in n)o[i]=t[i];return a&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function rt(e){return e=e.childContextTypes,e!=null}function ha(){Se(nt),Se(Ke)}function Ps(e,t,n){if(Ke.current!==Xt)throw Error(s(168));Ne(Ke,t),Ne(nt,n)}function Cs(e,t,n){var a=e.stateNode;if(t=t.childContextTypes,typeof a.getChildContext!="function")return n;a=a.getChildContext();for(var o in a)if(!(o in t))throw Error(s(108,ve(e)||"Unknown",o));return Z({},n,a)}function _a(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Xt,gn=Ke.current,Ne(Ke,e),Ne(nt,nt.current),!0}function Ts(e,t,n){var a=e.stateNode;if(!a)throw Error(s(169));n?(e=Cs(e,t,gn),a.__reactInternalMemoizedMergedChildContext=e,Se(nt),Se(Ke),Ne(Ke,e)):Se(nt),Ne(nt,n)}var Dt=null,xa=!1,Zl=!1;function Es(e){Dt===null?Dt=[e]:Dt.push(e)}function gm(e){xa=!0,Es(e)}function Zt(){if(!Zl&&Dt!==null){Zl=!0;var e=0,t=je;try{var n=Dt;for(je=1;e>=d,o-=d,Mt=1<<32-yt(t)+o|n<se?(Be=ie,ie=null):Be=ie.sibling;var ye=z(E,ie,F[se],G);if(ye===null){ie===null&&(ie=Be);break}e&&ie&&ye.alternate===null&&t(E,ie),k=i(ye,k,se),oe===null?re=ye:oe.sibling=ye,oe=ye,ie=Be}if(se===F.length)return n(E,ie),Pe&&_n(E,se),re;if(ie===null){for(;sese?(Be=ie,ie=null):Be=ie.sibling;var sn=z(E,ie,ye.value,G);if(sn===null){ie===null&&(ie=Be);break}e&&ie&&sn.alternate===null&&t(E,ie),k=i(sn,k,se),oe===null?re=sn:oe.sibling=sn,oe=sn,ie=Be}if(ye.done)return n(E,ie),Pe&&_n(E,se),re;if(ie===null){for(;!ye.done;se++,ye=F.next())ye=B(E,ye.value,G),ye!==null&&(k=i(ye,k,se),oe===null?re=ye:oe.sibling=ye,oe=ye);return Pe&&_n(E,se),re}for(ie=a(E,ie);!ye.done;se++,ye=F.next())ye=X(ie,E,se,ye.value,G),ye!==null&&(e&&ye.alternate!==null&&ie.delete(ye.key===null?se:ye.key),k=i(ye,k,se),oe===null?re=ye:oe.sibling=ye,oe=ye);return e&&ie.forEach(function(Km){return t(E,Km)}),Pe&&_n(E,se),re}function $e(E,k,F,G){if(typeof F=="object"&&F!==null&&F.type===L&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case R:e:{for(var re=F.key,oe=k;oe!==null;){if(oe.key===re){if(re=F.type,re===L){if(oe.tag===7){n(E,oe.sibling),k=o(oe,F.props.children),k.return=E,E=k;break e}}else if(oe.elementType===re||typeof re=="object"&&re!==null&&re.$$typeof===De&&$s(re)===oe.type){n(E,oe.sibling),k=o(oe,F.props),k.ref=Sr(E,oe,F),k.return=E,E=k;break e}n(E,oe);break}else t(E,oe);oe=oe.sibling}F.type===L?(k=wn(F.props.children,E.mode,G,F.key),k.return=E,E=k):(G=Ga(F.type,F.key,F.props,null,E.mode,G),G.ref=Sr(E,k,F),G.return=E,E=G)}return d(E);case M:e:{for(oe=F.key;k!==null;){if(k.key===oe)if(k.tag===4&&k.stateNode.containerInfo===F.containerInfo&&k.stateNode.implementation===F.implementation){n(E,k.sibling),k=o(k,F.children||[]),k.return=E,E=k;break e}else{n(E,k);break}else t(E,k);k=k.sibling}k=Yo(F,E.mode,G),k.return=E,E=k}return d(E);case De:return oe=F._init,$e(E,k,oe(F._payload),G)}if(tr(F))return ee(E,k,F,G);if(le(F))return ne(E,k,F,G);Na(E,F)}return typeof F=="string"&&F!==""||typeof F=="number"?(F=""+F,k!==null&&k.tag===6?(n(E,k.sibling),k=o(k,F),k.return=E,E=k):(n(E,k),k=Ko(F,E.mode,G),k.return=E,E=k),d(E)):n(E,k)}return $e}var Vn=Ls(!0),Os=Ls(!1),ba=Yt(null),ka=null,Hn=null,ao=null;function lo(){ao=Hn=ka=null}function oo(e){var t=ba.current;Se(ba),e._currentValue=t}function io(e,t,n){for(;e!==null;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,a!==null&&(a.childLanes|=t)):a!==null&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===n)break;e=e.return}}function Gn(e,t){ka=e,ao=Hn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(at=!0),e.firstContext=null)}function gt(e){var t=e._currentValue;if(ao!==e)if(e={context:e,memoizedValue:t,next:null},Hn===null){if(ka===null)throw Error(s(308));Hn=e,ka.dependencies={lanes:0,firstContext:e}}else Hn=Hn.next=e;return t}var xn=null;function so(e){xn===null?xn=[e]:xn.push(e)}function zs(e,t,n,a){var o=t.interleaved;return o===null?(n.next=n,so(t)):(n.next=o.next,o.next=n),t.interleaved=n,$t(e,a)}function $t(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Jt=!1;function uo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function qs(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Lt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function en(e,t,n){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(he&2)!==0){var o=a.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),a.pending=t,$t(e,n)}return o=a.interleaved,o===null?(t.next=t,so(a)):(t.next=o.next,o.next=t),a.interleaved=t,$t(e,n)}function wa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var a=t.lanes;a&=e.pendingLanes,n|=a,t.lanes=n,bl(e,n)}}function Ws(e,t){var n=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,n===a)){var o=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var d={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?o=i=d:i=i.next=d,n=n.next}while(n!==null);i===null?o=i=t:i=i.next=t}else o=i=t;n={baseState:a.baseState,firstBaseUpdate:o,lastBaseUpdate:i,shared:a.shared,effects:a.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Sa(e,t,n,a){var o=e.updateQueue;Jt=!1;var i=o.firstBaseUpdate,d=o.lastBaseUpdate,g=o.shared.pending;if(g!==null){o.shared.pending=null;var N=g,D=N.next;N.next=null,d===null?i=D:d.next=D,d=N;var q=e.alternate;q!==null&&(q=q.updateQueue,g=q.lastBaseUpdate,g!==d&&(g===null?q.firstBaseUpdate=D:g.next=D,q.lastBaseUpdate=N))}if(i!==null){var B=o.baseState;d=0,q=D=N=null,g=i;do{var z=g.lane,X=g.eventTime;if((a&z)===z){q!==null&&(q=q.next={eventTime:X,lane:0,tag:g.tag,payload:g.payload,callback:g.callback,next:null});e:{var ee=e,ne=g;switch(z=t,X=n,ne.tag){case 1:if(ee=ne.payload,typeof ee=="function"){B=ee.call(X,B,z);break e}B=ee;break e;case 3:ee.flags=ee.flags&-65537|128;case 0:if(ee=ne.payload,z=typeof ee=="function"?ee.call(X,B,z):ee,z==null)break e;B=Z({},B,z);break e;case 2:Jt=!0}}g.callback!==null&&g.lane!==0&&(e.flags|=64,z=o.effects,z===null?o.effects=[g]:z.push(g))}else X={eventTime:X,lane:z,tag:g.tag,payload:g.payload,callback:g.callback,next:null},q===null?(D=q=X,N=B):q=q.next=X,d|=z;if(g=g.next,g===null){if(g=o.shared.pending,g===null)break;z=g,g=z.next,z.next=null,o.lastBaseUpdate=z,o.shared.pending=null}}while(!0);if(q===null&&(N=B),o.baseState=N,o.firstBaseUpdate=D,o.lastBaseUpdate=q,t=o.shared.interleaved,t!==null){o=t;do d|=o.lane,o=o.next;while(o!==t)}else i===null&&(o.shared.lanes=0);jn|=d,e.lanes=d,e.memoizedState=B}}function Bs(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var a=go.transition;go.transition={};try{e(!1),t()}finally{je=n,go.transition=a}}function su(){return ht().memoizedState}function ym(e,t,n){var a=an(e);if(n={lane:a,action:n,hasEagerState:!1,eagerState:null,next:null},uu(e))cu(t,n);else if(n=zs(e,t,n,a),n!==null){var o=tt();wt(n,e,a,o),du(n,t,a)}}function vm(e,t,n){var a=an(e),o={lane:a,action:n,hasEagerState:!1,eagerState:null,next:null};if(uu(e))cu(t,o);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var d=t.lastRenderedState,g=i(d,n);if(o.hasEagerState=!0,o.eagerState=g,vt(g,d)){var N=t.interleaved;N===null?(o.next=o,so(t)):(o.next=N.next,N.next=o),t.interleaved=o;return}}catch{}finally{}n=zs(e,t,o,a),n!==null&&(o=tt(),wt(n,e,a,o),du(n,t,a))}}function uu(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function cu(e,t){Tr=Ca=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function du(e,t,n){if((n&4194240)!==0){var a=t.lanes;a&=e.pendingLanes,n|=a,t.lanes=n,bl(e,n)}}var Fa={readContext:gt,useCallback:Ye,useContext:Ye,useEffect:Ye,useImperativeHandle:Ye,useInsertionEffect:Ye,useLayoutEffect:Ye,useMemo:Ye,useReducer:Ye,useRef:Ye,useState:Ye,useDebugValue:Ye,useDeferredValue:Ye,useTransition:Ye,useMutableSource:Ye,useSyncExternalStore:Ye,useId:Ye,unstable_isNewReconciler:!1},jm={readContext:gt,useCallback:function(e,t){return Tt().memoizedState=[e,t===void 0?null:t],e},useContext:gt,useEffect:eu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ta(4194308,4,ru.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ta(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ta(4,2,e,t)},useMemo:function(e,t){var n=Tt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var a=Tt();return t=n!==void 0?n(t):t,a.memoizedState=a.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},a.queue=e,e=e.dispatch=ym.bind(null,Re,e),[a.memoizedState,e]},useRef:function(e){var t=Tt();return e={current:e},t.memoizedState=e},useState:Zs,useDebugValue:No,useDeferredValue:function(e){return Tt().memoizedState=e},useTransition:function(){var e=Zs(!1),t=e[0];return e=xm.bind(null,e[1]),Tt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var a=Re,o=Tt();if(Pe){if(n===void 0)throw Error(s(407));n=n()}else{if(n=t(),We===null)throw Error(s(349));(vn&30)!==0||Qs(a,t,n)}o.memoizedState=n;var i={value:n,getSnapshot:t};return o.queue=i,eu(Ks.bind(null,a,i,e),[e]),a.flags|=2048,Rr(9,Is.bind(null,a,i,n,t),void 0,null),n},useId:function(){var e=Tt(),t=We.identifierPrefix;if(Pe){var n=Ut,a=Mt;n=(a&~(1<<32-yt(a)-1)).toString(32)+n,t=":"+t+"R"+n,n=Er++,0<\/script>",e=e.removeChild(e.firstChild)):typeof a.is=="string"?e=d.createElement(n,{is:a.is}):(e=d.createElement(n),n==="select"&&(d=e,a.multiple?d.multiple=!0:a.size&&(d.size=a.size))):e=d.createElementNS(e,n),e[Pt]=t,e[kr]=a,Eu(e,t,!1,!1),t.stateNode=e;e:{switch(d=fl(n,a),n){case"dialog":we("cancel",e),we("close",e),o=a;break;case"iframe":case"object":case"embed":we("load",e),o=a;break;case"video":case"audio":for(o=0;oXn&&(t.flags|=128,a=!0,Dr(i,!1),t.lanes=4194304)}else{if(!a)if(e=Aa(d),e!==null){if(t.flags|=128,a=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Dr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!d.alternate&&!Pe)return Xe(t),null}else 2*Ue()-i.renderingStartTime>Xn&&n!==1073741824&&(t.flags|=128,a=!0,Dr(i,!1),t.lanes=4194304);i.isBackwards?(d.sibling=t.child,t.child=d):(n=i.last,n!==null?n.sibling=d:t.child=d,i.last=d)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Ue(),t.sibling=null,n=Fe.current,Ne(Fe,a?n&1|2:n&1),t):(Xe(t),null);case 22:case 23:return Go(),a=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==a&&(t.flags|=8192),a&&(t.mode&1)!==0?(mt&1073741824)!==0&&(Xe(t),t.subtreeFlags&6&&(t.flags|=8192)):Xe(t),null;case 24:return null;case 25:return null}throw Error(s(156,t.tag))}function Cm(e,t){switch(eo(t),t.tag){case 1:return rt(t.type)&&ha(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Qn(),Se(nt),Se(Ke),po(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return mo(t),null;case 13:if(Se(Fe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));Bn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(Fe),null;case 4:return Qn(),null;case 10:return oo(t.type._context),null;case 22:case 23:return Go(),null;case 24:return null;default:return null}}var Ua=!1,Ze=!1,Tm=typeof WeakSet=="function"?WeakSet:Set,J=null;function Kn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(a){Me(e,t,a)}else n.current=null}function Do(e,t,n){try{n()}catch(a){Me(e,t,a)}}var Du=!1;function Em(e,t){if(Hl=na,e=ms(),$l(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var a=n.getSelection&&n.getSelection();if(a&&a.rangeCount!==0){n=a.anchorNode;var o=a.anchorOffset,i=a.focusNode;a=a.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var d=0,g=-1,N=-1,D=0,q=0,B=e,z=null;t:for(;;){for(var X;B!==n||o!==0&&B.nodeType!==3||(g=d+o),B!==i||a!==0&&B.nodeType!==3||(N=d+a),B.nodeType===3&&(d+=B.nodeValue.length),(X=B.firstChild)!==null;)z=B,B=X;for(;;){if(B===e)break t;if(z===n&&++D===o&&(g=d),z===i&&++q===a&&(N=d),(X=B.nextSibling)!==null)break;B=z,z=B.parentNode}B=X}n=g===-1||N===-1?null:{start:g,end:N}}else n=null}n=n||{start:0,end:0}}else n=null;for(Gl={focusedElem:e,selectionRange:n},na=!1,J=t;J!==null;)if(t=J,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,J=e;else for(;J!==null;){t=J;try{var ee=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(ee!==null){var ne=ee.memoizedProps,$e=ee.memoizedState,E=t.stateNode,k=E.getSnapshotBeforeUpdate(t.elementType===t.type?ne:Nt(t.type,ne),$e);E.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var F=t.stateNode.containerInfo;F.nodeType===1?F.textContent="":F.nodeType===9&&F.documentElement&&F.removeChild(F.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(G){Me(t,t.return,G)}if(e=t.sibling,e!==null){e.return=t.return,J=e;break}J=t.return}return ee=Du,Du=!1,ee}function Mr(e,t,n){var a=t.updateQueue;if(a=a!==null?a.lastEffect:null,a!==null){var o=a=a.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,i!==void 0&&Do(t,n,i)}o=o.next}while(o!==a)}}function $a(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var a=n.create;n.destroy=a()}n=n.next}while(n!==t)}}function Mo(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Mu(e){var t=e.alternate;t!==null&&(e.alternate=null,Mu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Pt],delete t[kr],delete t[Yl],delete t[fm],delete t[pm])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Uu(e){return e.tag===5||e.tag===3||e.tag===4}function $u(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Uu(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Uo(e,t,n){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=pa));else if(a!==4&&(e=e.child,e!==null))for(Uo(e,t,n),e=e.sibling;e!==null;)Uo(e,t,n),e=e.sibling}function $o(e,t,n){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(a!==4&&(e=e.child,e!==null))for($o(e,t,n),e=e.sibling;e!==null;)$o(e,t,n),e=e.sibling}var He=null,bt=!1;function tn(e,t,n){for(n=n.child;n!==null;)Lu(e,t,n),n=n.sibling}function Lu(e,t,n){if(At&&typeof At.onCommitFiberUnmount=="function")try{At.onCommitFiberUnmount(Yr,n)}catch{}switch(n.tag){case 5:Ze||Kn(n,t);case 6:var a=He,o=bt;He=null,tn(e,t,n),He=a,bt=o,He!==null&&(bt?(e=He,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):He.removeChild(n.stateNode));break;case 18:He!==null&&(bt?(e=He,n=n.stateNode,e.nodeType===8?Kl(e.parentNode,n):e.nodeType===1&&Kl(e,n),fr(e)):Kl(He,n.stateNode));break;case 4:a=He,o=bt,He=n.stateNode.containerInfo,bt=!0,tn(e,t,n),He=a,bt=o;break;case 0:case 11:case 14:case 15:if(!Ze&&(a=n.updateQueue,a!==null&&(a=a.lastEffect,a!==null))){o=a=a.next;do{var i=o,d=i.destroy;i=i.tag,d!==void 0&&((i&2)!==0||(i&4)!==0)&&Do(n,t,d),o=o.next}while(o!==a)}tn(e,t,n);break;case 1:if(!Ze&&(Kn(n,t),a=n.stateNode,typeof a.componentWillUnmount=="function"))try{a.props=n.memoizedProps,a.state=n.memoizedState,a.componentWillUnmount()}catch(g){Me(n,t,g)}tn(e,t,n);break;case 21:tn(e,t,n);break;case 22:n.mode&1?(Ze=(a=Ze)||n.memoizedState!==null,tn(e,t,n),Ze=a):tn(e,t,n);break;default:tn(e,t,n)}}function Ou(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Tm),t.forEach(function(a){var o=zm.bind(null,e,a);n.has(a)||(n.add(a),a.then(o,o))})}}function kt(e,t){var n=t.deletions;if(n!==null)for(var a=0;ao&&(o=d),a&=~i}if(a=o,a=Ue()-a,a=(120>a?120:480>a?480:1080>a?1080:1920>a?1920:3e3>a?3e3:4320>a?4320:1960*Rm(a/1960))-a,10e?16:e,rn===null)var a=!1;else{if(e=rn,rn=null,Wa=0,(he&6)!==0)throw Error(s(331));var o=he;for(he|=4,J=e.current;J!==null;){var i=J,d=i.child;if((J.flags&16)!==0){var g=i.deletions;if(g!==null){for(var N=0;NUe()-zo?bn(e,0):Oo|=n),ot(e,t)}function Zu(e,t){t===0&&((e.mode&1)===0?t=1:(t=Zr,Zr<<=1,(Zr&130023424)===0&&(Zr=4194304)));var n=tt();e=$t(e,t),e!==null&&(sr(e,t,n),ot(e,n))}function Om(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Zu(e,n)}function zm(e,t){var n=0;switch(e.tag){case 13:var a=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:a=e.stateNode;break;default:throw Error(s(314))}a!==null&&a.delete(t),Zu(e,n)}var Ju;Ju=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||nt.current)at=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return at=!1,Am(e,t,n);at=(e.flags&131072)!==0}else at=!1,Pe&&(t.flags&1048576)!==0&&Fs(t,va,t.index);switch(t.lanes=0,t.tag){case 2:var a=t.type;Ma(e,t),e=t.pendingProps;var o=zn(t,Ke.current);Gn(t,n),o=_o(null,t,a,e,o,n);var i=xo();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,rt(a)?(i=!0,_a(t)):i=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,uo(t),o.updater=Ra,t.stateNode=o,o._reactInternals=t,ko(t,a,e,n),t=Po(null,t,a,!0,i,n)):(t.tag=0,Pe&&i&&Jl(t),et(null,t,o,n),t=t.child),t;case 16:a=t.elementType;e:{switch(Ma(e,t),e=t.pendingProps,o=a._init,a=o(a._payload),t.type=a,o=t.tag=Wm(a),e=Nt(a,e),o){case 0:t=Ao(null,t,a,e,n);break e;case 1:t=wu(null,t,a,e,n);break e;case 11:t=vu(null,t,a,e,n);break e;case 14:t=ju(null,t,a,Nt(a.type,e),n);break e}throw Error(s(306,a,""))}return t;case 0:return a=t.type,o=t.pendingProps,o=t.elementType===a?o:Nt(a,o),Ao(e,t,a,o,n);case 1:return a=t.type,o=t.pendingProps,o=t.elementType===a?o:Nt(a,o),wu(e,t,a,o,n);case 3:e:{if(Su(t),e===null)throw Error(s(387));a=t.pendingProps,i=t.memoizedState,o=i.element,qs(e,t),Sa(t,a,null,n);var d=t.memoizedState;if(a=d.element,i.isDehydrated)if(i={element:a,isDehydrated:!1,cache:d.cache,pendingSuspenseBoundaries:d.pendingSuspenseBoundaries,transitions:d.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){o=In(Error(s(423)),t),t=Au(e,t,a,n,o);break e}else if(a!==o){o=In(Error(s(424)),t),t=Au(e,t,a,n,o);break e}else for(dt=Kt(t.stateNode.containerInfo.firstChild),ct=t,Pe=!0,jt=null,n=Os(t,null,a,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Bn(),a===o){t=Ot(e,t,n);break e}et(e,t,a,n)}t=t.child}return t;case 5:return Vs(t),e===null&&no(t),a=t.type,o=t.pendingProps,i=e!==null?e.memoizedProps:null,d=o.children,Ql(a,o)?d=null:i!==null&&Ql(a,i)&&(t.flags|=32),ku(e,t),et(e,t,d,n),t.child;case 6:return e===null&&no(t),null;case 13:return Pu(e,t,n);case 4:return co(t,t.stateNode.containerInfo),a=t.pendingProps,e===null?t.child=Vn(t,null,a,n):et(e,t,a,n),t.child;case 11:return a=t.type,o=t.pendingProps,o=t.elementType===a?o:Nt(a,o),vu(e,t,a,o,n);case 7:return et(e,t,t.pendingProps,n),t.child;case 8:return et(e,t,t.pendingProps.children,n),t.child;case 12:return et(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(a=t.type._context,o=t.pendingProps,i=t.memoizedProps,d=o.value,Ne(ba,a._currentValue),a._currentValue=d,i!==null)if(vt(i.value,d)){if(i.children===o.children&&!nt.current){t=Ot(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var g=i.dependencies;if(g!==null){d=i.child;for(var N=g.firstContext;N!==null;){if(N.context===a){if(i.tag===1){N=Lt(-1,n&-n),N.tag=2;var D=i.updateQueue;if(D!==null){D=D.shared;var q=D.pending;q===null?N.next=N:(N.next=q.next,q.next=N),D.pending=N}}i.lanes|=n,N=i.alternate,N!==null&&(N.lanes|=n),io(i.return,n,t),g.lanes|=n;break}N=N.next}}else if(i.tag===10)d=i.type===t.type?null:i.child;else if(i.tag===18){if(d=i.return,d===null)throw Error(s(341));d.lanes|=n,g=d.alternate,g!==null&&(g.lanes|=n),io(d,n,t),d=i.sibling}else d=i.child;if(d!==null)d.return=i;else for(d=i;d!==null;){if(d===t){d=null;break}if(i=d.sibling,i!==null){i.return=d.return,d=i;break}d=d.return}i=d}et(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,a=t.pendingProps.children,Gn(t,n),o=gt(o),a=a(o),t.flags|=1,et(e,t,a,n),t.child;case 14:return a=t.type,o=Nt(a,t.pendingProps),o=Nt(a.type,o),ju(e,t,a,o,n);case 15:return Nu(e,t,t.type,t.pendingProps,n);case 17:return a=t.type,o=t.pendingProps,o=t.elementType===a?o:Nt(a,o),Ma(e,t),t.tag=1,rt(a)?(e=!0,_a(t)):e=!1,Gn(t,n),fu(t,a,o),ko(t,a,o,n),Po(null,t,a,!0,e,n);case 19:return Tu(e,t,n);case 22:return bu(e,t,n)}throw Error(s(156,t.tag))};function ec(e,t){return Ri(e,t)}function qm(e,t,n,a){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function xt(e,t,n,a){return new qm(e,t,n,a)}function Io(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wm(e){if(typeof e=="function")return Io(e)?1:0;if(e!=null){if(e=e.$$typeof,e===xe)return 11;if(e===Je)return 14}return 2}function on(e,t){var n=e.alternate;return n===null?(n=xt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ga(e,t,n,a,o,i){var d=2;if(a=e,typeof e=="function")Io(e)&&(d=1);else if(typeof e=="string")d=5;else e:switch(e){case L:return wn(n.children,o,i,t);case H:d=8,o|=8;break;case te:return e=xt(12,n,t,o|2),e.elementType=te,e.lanes=i,e;case Te:return e=xt(13,n,t,o),e.elementType=Te,e.lanes=i,e;case Ie:return e=xt(19,n,t,o),e.elementType=Ie,e.lanes=i,e;case ke:return Qa(n,o,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Q:d=10;break e;case _e:d=9;break e;case xe:d=11;break e;case Je:d=14;break e;case De:d=16,a=null;break e}throw Error(s(130,e==null?e:typeof e,""))}return t=xt(d,n,t,o),t.elementType=e,t.type=a,t.lanes=i,t}function wn(e,t,n,a){return e=xt(7,e,a,t),e.lanes=n,e}function Qa(e,t,n,a){return e=xt(22,e,a,t),e.elementType=ke,e.lanes=n,e.stateNode={isHidden:!1},e}function Ko(e,t,n){return e=xt(6,e,null,t),e.lanes=n,e}function Yo(e,t,n){return t=xt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Bm(e,t,n,a,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Nl(0),this.expirationTimes=Nl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Nl(0),this.identifierPrefix=a,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Xo(e,t,n,a,o,i,d,g,N){return e=new Bm(e,t,n,g,N),t===1?(t=1,i===!0&&(t|=8)):t=0,i=xt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:a,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},uo(i),e}function Vm(e,t,n){var a=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(u){console.error(u)}}return l(),ri.exports=nf(),ri.exports}var pc;function af(){if(pc)return el;pc=1;var l=rf();return el.createRoot=l.createRoot,el.hydrateRoot=l.hydrateRoot,el}var lf=af();const of=Sc(lf),sf=new Set(["import","from","export","default","const","let","var","function","return","if","else","for","while","do","switch","case","break","continue","new","this","class","extends","async","await","try","catch","throw","typeof","instanceof","in","of","true","false","null","undefined","void","type","interface","enum","as"]),uf=new Set(["console","Math","JSON","Array","Object","String","Number","Boolean","Promise","Map","Set","Date","Error","RegExp"]);function cf(l){const u=[];let s=0;for(;s0&&l.lastIndexOf(` +`,s-1)!+-*/%&|^~?".includes(l[s])){let c=s;for(;c!+-*/%&|^~?".includes(l[c]);)c++;u.push({type:"operator",value:l.slice(s,c)}),s=c;continue}if("{}[]();:.,".includes(l[s])){u.push({type:"punctuation",value:l[s]}),s++;continue}let m=s;for(;m!+\-*%&|^~?{}[\]();:.,]/.test(l[m]);)m++;u.push({type:"plain",value:l.slice(s,m||s+1)}),s=m||s+1}return u}const df={keyword:"text-purple-400",string:"text-green-400",number:"text-orange-300",comment:"text-gray-500 italic",property:"text-sky-300",punctuation:"text-gray-400",operator:"text-pink-400",builtin:"text-yellow-300",plain:"text-gray-100"};function Qe({code:l,title:u,language:s="typescript"}){const m=W.useMemo(()=>s==="bash"?l.split(` +`).map((h,f)=>h.trimStart().startsWith("#")?r.jsx("div",{children:r.jsx("span",{className:"text-gray-500 italic",children:h})},f):r.jsx("div",{children:h},f)):cf(l).map((h,f)=>r.jsx("span",{className:df[h.type],children:h.value},f)),[l,s]);return r.jsxs("div",{className:"rounded-lg overflow-hidden border border-gray-200",children:[u&&r.jsxs("div",{className:"bg-gray-800 px-4 py-2 text-xs text-gray-400 font-mono flex items-center justify-between",children:[r.jsx("span",{children:u}),s&&r.jsx("span",{className:"text-gray-500 text-[10px] uppercase",children:s})]}),r.jsx("pre",{className:"bg-gray-900 text-gray-100 p-4 text-xs overflow-x-auto font-mono leading-relaxed",children:m})]})}const mf=[{id:"per-unit",title:"Per Unit Pricing",desc:"Simple price x quantity calculations with tax support",icon:"📦",color:"bg-blue-50 border-blue-200"},{id:"tiered-volume",title:"Tiered Volume",desc:"Single tier selected based on total quantity",icon:"📊",color:"bg-indigo-50 border-indigo-200"},{id:"tiered-graduated",title:"Tiered Graduated",desc:"Different rates apply to different quantity ranges",icon:"📈",color:"bg-purple-50 border-purple-200"},{id:"tiered-flatfee",title:"Tiered Flat Fee",desc:"Fixed fee based on quantity range",icon:"🏷️",color:"bg-pink-50 border-pink-200"},{id:"tax",title:"Tax Handling",desc:"Inclusive/exclusive tax with multi-rate breakdown",icon:"🧾",color:"bg-green-50 border-green-200"},{id:"discounts",title:"Discounts & Coupons",desc:"Fixed, percentage, and cashback coupon types",icon:"🎟️",color:"bg-amber-50 border-amber-200"},{id:"composite",title:"Composite Pricing",desc:"Multi-component bundled price items",icon:"🧩",color:"bg-cyan-50 border-cyan-200"},{id:"recurring",title:"Recurring Billing",desc:"Billing periods and frequency normalization",icon:"🔄",color:"bg-teal-50 border-teal-200"},{id:"currency",title:"Currency & Formatting",desc:"Multi-currency support with locale-aware formatting",icon:"💱",color:"bg-emerald-50 border-emerald-200"},{id:"dynamic-tariff",title:"Dynamic Tariff",desc:"Market-based pricing with configurable markup",icon:"⚡",color:"bg-yellow-50 border-yellow-200"},{id:"getag",title:"GetAG Energy Pricing",desc:"German energy operator integration with tiered markups",icon:"🔌",color:"bg-orange-50 border-orange-200"}],ff=[{id:"electricity",title:"Electricity",desc:"Single & dual-tariff (HT/NT) electricity pricing with Grundpreis and Arbeitspreis",icon:"⚡",color:"bg-yellow-50 border-yellow-200"},{id:"gas",title:"Gas",desc:"Gas supply tariffs with CO2 levy, gas storage levy, and per-kWh work price",icon:"🔥",color:"bg-orange-50 border-orange-200"},{id:"house-connection",title:"House Connection",desc:"Hausanschluss fees with distance-based trench work and connection services",icon:"🏡",color:"bg-emerald-50 border-emerald-200"},{id:"non-commodity",title:"Non-Commodity",desc:"Solar panels, wallboxes, heat pumps, and smart home products with service contracts",icon:"📋",color:"bg-purple-50 border-purple-200"}];function Ac({onNavigate:l}){return r.jsxs("div",{children:[r.jsxs("div",{className:"mb-10",children:[r.jsx("h1",{className:"text-4xl font-extrabold text-gray-900 mb-3",children:"epilot Pricing Playground"}),r.jsxs("p",{className:"text-lg text-gray-500 max-w-2xl",children:["Interactive playground for ",r.jsx("code",{className:"text-sm bg-gray-100 px-1.5 py-0.5 rounded font-mono",children:"@epilot/pricing"})," — a comprehensive pricing calculation engine supporting 6 pricing models, tax handling, discounts, composite pricing, recurring billing, multi-currency formatting, and energy-market integrations. Explore each capability below."]})]}),r.jsx("div",{className:"grid grid-cols-4 gap-4 mb-10",children:[{label:"Pricing Models",value:"6"},{label:"Exported Functions",value:"40+"},{label:"Billing Periods",value:"6"},{label:"Decimal Precision",value:"12 digits"}].map(u=>r.jsxs("div",{className:"card text-center",children:[r.jsx("p",{className:"text-2xl font-bold text-primary-600",children:u.value}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:u.label})]},u.label))}),r.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-4",children:"Energy & Utility Use Cases"}),r.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:ff.map(u=>r.jsxs("button",{onClick:()=>l(u.id),className:`text-left p-5 rounded-xl border ${u.color} hover:shadow-md transition-shadow group`,children:[r.jsx("span",{className:"text-2xl",children:u.icon}),r.jsx("h3",{className:"font-semibold text-gray-900 mt-2 group-hover:text-primary-600 transition-colors",children:u.title}),r.jsx("p",{className:"text-sm text-gray-500 mt-1",children:u.desc})]},u.id))}),r.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-4 mt-10",children:"Capabilities"}),r.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:mf.map(u=>r.jsxs("button",{onClick:()=>l(u.id),className:`text-left p-5 rounded-xl border ${u.color} hover:shadow-md transition-shadow group`,children:[r.jsx("span",{className:"text-2xl",children:u.icon}),r.jsx("h3",{className:"font-semibold text-gray-900 mt-2 group-hover:text-primary-600 transition-colors",children:u.title}),r.jsx("p",{className:"text-sm text-gray-500 mt-1",children:u.desc})]},u.id))}),r.jsxs("div",{className:"mt-10 grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsx(Qe,{title:"Install",language:"bash",code:"npm install @epilot/pricing"}),r.jsx(Qe,{title:"Quick Start",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +const priceItem = { + quantity: 5, + pricing_model: 'per_unit', + is_tax_inclusive: true, + _price: { + unit_amount_decimal: '49.99', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: true, + tax: [{ rate: 19, type: 'VAT' }], + }, + taxes: [{ tax: { rate: 19 } }], +}; + +const result = computeAggregatedAndPriceTotals([priceItem]); +// result.amount_total → 24995 (€249.95)`})]}),r.jsxs("div",{className:"mt-10 card",children:[r.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-4",children:"How It Works"}),r.jsx("div",{className:"flex items-center gap-4 text-sm overflow-x-auto pb-2",children:[{step:"1",label:"Price Items",desc:"Define price, quantity, tax, coupons"},{step:"2",label:"Compute",desc:"computeAggregatedAndPriceTotals()"},{step:"3",label:"Results",desc:"Subtotals, tax, discounts, recurrences"}].map((u,s)=>r.jsxs("div",{className:"flex items-center gap-4",children:[s>0&&r.jsx("svg",{className:"w-6 h-6 text-gray-300 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 min-w-[180px]",children:[r.jsx("div",{className:"w-7 h-7 rounded-full bg-primary-100 text-primary-700 text-xs font-bold flex items-center justify-center mb-2",children:u.step}),r.jsx("p",{className:"font-semibold text-gray-900",children:u.label}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:u.desc})]})]},u.step))})]})]})}const Pc={EUR:{de:"Cent",default:"cent"},USD:{de:"Cent",default:"cent"},CHF:{de:"Centime",default:"centime"}},st="EUR",pf=Pc[st],di=12,qt=2,gf=6,nl="$0,0.00",hf="$0,0",rl="de";var _f={defaultAmount:0,defaultCurrency:"USD",defaultPrecision:2},xf={globalLocale:"en-US",globalFormat:"$0,0.00",globalRoundingMode:"HALF_EVEN",globalFormatRoundingMode:"HALF_AWAY_FROM_ZERO",globalExchangeRatesApi:{endpoint:void 0,headers:void 0,propertyPath:void 0}};function Br(l){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Br=function(u){return typeof u}:Br=function(u){return u&&typeof Symbol=="function"&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Br(l)}function gc(l){return yf(l)||vf(l)||jf(l)||Nf()}function yf(l){if(Array.isArray(l))return l}function vf(l){if(typeof Symbol<"u"&&Symbol.iterator in Object(l))return Array.from(l)}function jf(l,u){if(l){if(typeof l=="string")return hc(l,u);var s=Object.prototype.toString.call(l).slice(8,-1);if(s==="Object"&&l.constructor&&(s=l.constructor.name),s==="Map"||s==="Set")return Array.from(l);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return hc(l,u)}}function hc(l,u){(u==null||u>l.length)&&(u=l.length);for(var s=0,m=new Array(u);s=0}function wf(l){return l.length>0&&l.every(function(u){return u>=0})&&l.some(function(u){return u>0})}function _c(l){return l%2===0}function xc(l){return Cc(l)&&!Number.isInteger(l)}function Sf(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,u=l.toString();if(u.indexOf("e-")>0)return parseInt(u.split("e-")[1]);var s=u.split(".")[1];return s?s.length:0}function qr(l){return Math.abs(l)%1===.5}function Af(l){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(s,m){var c=Object.assign(new XMLHttpRequest,{onreadystatechange:function(){c.readyState===4&&(c.status>=200&&c.status<400?s(JSON.parse(c.responseText)):m(new Error(c.statusText)))},onerror:function(){m(new Error("Network error"))}});c.open("GET",l,!0),Pf(c,u.headers),c.send()})}function Pf(l){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};for(var s in u)l.setRequestHeader(s,u[s]);return l}function Wr(l){return typeof l>"u"}function Tc(l){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:".",s={};return Object.entries(l).forEach(function(m){if(Br(m[1])==="object"){var c=Tc(m[1]);Object.entries(c).forEach(function(h){s[m[0]+u+h[0]]=h[1]})}else s[m[0]]=m[1]}),s}function Cf(l){return!!l&&(Br(l)==="object"||typeof l=="function")&&typeof l.then=="function"}function Ec(){var l=function(m,c){var h=function(p){return Math.pow(10,Sf(p))},f=Math.max(h(m),h(c));return Math.round(m*f)*Math.round(c*f)/(f*f)},u={HALF_ODD:function(m){var c=Math.round(m);return qr(m)&&_c(c)?c-1:c},HALF_EVEN:function(m){var c=Math.round(m);return qr(m)?_c(c)?c:c-1:c},HALF_UP:function(m){return Math.round(m)},HALF_DOWN:function(m){return qr(m)?Math.floor(m):Math.round(m)},HALF_TOWARDS_ZERO:function(m){return qr(m)?Math.sign(m)*Math.floor(Math.abs(m)):Math.round(m)},HALF_AWAY_FROM_ZERO:function(m){return qr(m)?Math.sign(m)*Math.ceil(Math.abs(m)):Math.round(m)},DOWN:function(m){return Math.floor(m)}};return{add:function(m,c){return m+c},subtract:function(m,c){return m-c},multiply:function(m,c){return xc(m)||xc(c)?l(m,c):m*c},divide:function(m,c){return m/c},modulo:function(m,c){return m%c},round:function(m){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"HALF_EVEN";return u[c](m)}}}var Tf=Ec();function Ef(l){var u=/^(?:(\$|USD)?0(?:(,)0)?(\.)?(0+)?|0(?:(,)0)?(\.)?(0+)?\s?(dollar)?)$/gm.exec(l);return{getMatches:function(){return u!==null?u.slice(1).filter(function(m){return!Wr(m)}):[]},getMinimumFractionDigits:function(){var m=function(h){return h==="."};return Wr(this.getMatches().find(m))?0:this.getMatches()[Tf.add(this.getMatches().findIndex(m),1)].split("").length},getCurrencyDisplay:function(){var m={USD:"code",dollar:"name",$:"symbol"};return m[this.getMatches().find(function(c){return c==="USD"||c==="dollar"||c==="$"})]},getStyle:function(){return Wr(this.getCurrencyDisplay(this.getMatches()))?"decimal":"currency"},getUseGrouping:function(){return!Wr(this.getMatches().find(function(m){return m===","}))}}}function Ff(l){var u=function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",h=arguments.length>1?arguments[1]:void 0;for(var f in h)c=c.replace("{{".concat(f,"}}"),h[f]);return c},s=function(c,h){return Af(u(l.endpoint,{from:c,to:h}),{headers:l.headers})};return{getExchangeRate:function(c,h){return(Cf(l.endpoint)?l.endpoint:s(c,h)).then(function(f){return Tc(f)[u(l.propertyPath,{from:c,to:h})]})}}}function Vr(l,u){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Error;if(!l)throw new s(u)}function Rf(l){Vr(kf(l),"You must provide a numeric value between 0 and 100.",RangeError)}function Df(l){Vr(wf(l),"You must provide a non-empty array of numeric values greater than 0.",TypeError)}function oi(l){Vr(Number.isInteger(l),"You must provide an integer.",TypeError)}var Ae=Ec(),Mf=function l(u){var s=Object.assign({},{amount:l.defaultAmount,currency:l.defaultCurrency,precision:l.defaultPrecision},u),m=s.amount,c=s.currency,h=s.precision;oi(m),oi(h);var f=l.globalLocale,x=l.globalFormat,p=l.globalRoundingMode,S=l.globalFormatRoundingMode,y=Object.assign({},l.globalExchangeRatesApi),C=function(w){var A=Object.assign({},Object.assign({},{amount:m,currency:c,precision:h},w),Object.assign({},{locale:this.locale},w));return Object.assign(l({amount:A.amount,currency:A.currency,precision:A.precision}),{locale:A.locale})},j=function(w){Vr(this.hasSameCurrency(w),"You must provide a Dinero instance with the same currency.",TypeError)};return{getAmount:function(){return m},getCurrency:function(){return c},getLocale:function(){return this.locale||f},setLocale:function(w){return C.call(this,{locale:w})},getPrecision:function(){return h},convertPrecision:function(w){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:S;oi(w);var T=this.getPrecision(),U=w>T,I=U?Ae.multiply:Ae.divide,_=U?[w,T]:[T,w],$=Math.pow(10,Ae.subtract.apply(Ae,_));return C.call(this,{amount:Ae.round(I(this.getAmount(),$),A),precision:w})},add:function(w){j.call(this,w);var A=l.normalizePrecision([this,w]);return C.call(this,{amount:Ae.add(A[0].getAmount(),A[1].getAmount()),precision:A[0].getPrecision()})},subtract:function(w){j.call(this,w);var A=l.normalizePrecision([this,w]);return C.call(this,{amount:Ae.subtract(A[0].getAmount(),A[1].getAmount()),precision:A[0].getPrecision()})},multiply:function(w){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p;return C.call(this,{amount:Ae.round(Ae.multiply(this.getAmount(),w),A)})},divide:function(w){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p;return C.call(this,{amount:Ae.round(Ae.divide(this.getAmount(),w),A)})},percentage:function(w){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p;return Rf(w),this.multiply(Ae.divide(w,100),A)},allocate:function(w){var A=this;Df(w);for(var T=w.reduce(function($,R){return Ae.add($,R)}),U=this.getAmount(),I=w.map(function($){var R=Math.floor(Ae.divide(Ae.multiply(A.getAmount(),$),T));return U=Ae.subtract(U,R),C.call(A,{amount:R})}),_=0;U>0;)w[_]>0&&(I[_]=I[_].add(C.call(this,{amount:1})),U=Ae.subtract(U,1)),_+=1;return I},convert:function(w){var A=this,T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},U=T.endpoint,I=U===void 0?y.endpoint:U,_=T.propertyPath,$=_===void 0?y.propertyPath||"rates.{{to}}":_,R=T.headers,M=R===void 0?y.headers:R,L=T.roundingMode,H=L===void 0?p:L,te=Object.assign({},{endpoint:I,propertyPath:$,headers:M,roundingMode:H});return Ff(te).getExchangeRate(this.getCurrency(),w).then(function(Q){return Vr(!Wr(Q),'No rate was found for the destination currency "'.concat(w,'".'),TypeError),C.call(A,{amount:Ae.round(Ae.multiply(A.getAmount(),parseFloat(Q)),te.roundingMode),currency:w})})},equalsTo:function(w){return this.hasSameAmount(w)&&this.hasSameCurrency(w)},lessThan:function(w){j.call(this,w);var A=l.normalizePrecision([this,w]);return A[0].getAmount()A[1].getAmount()},greaterThanOrEqual:function(w){j.call(this,w);var A=l.normalizePrecision([this,w]);return A[0].getAmount()>=A[1].getAmount()},isZero:function(){return this.getAmount()===0},isPositive:function(){return this.getAmount()>=0},isNegative:function(){return this.getAmount()<0},hasSubUnits:function(){return Ae.modulo(this.getAmount(),Math.pow(10,h))!==0},hasCents:function(){return Ae.modulo(this.getAmount(),Math.pow(10,h))!==0},hasSameCurrency:function(w){return this.getCurrency()===w.getCurrency()},hasSameAmount:function(w){var A=l.normalizePrecision([this,w]);return A[0].getAmount()===A[1].getAmount()},toFormat:function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:x,A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:S,T=Ef(w);return this.toRoundedUnit(T.getMinimumFractionDigits(),A).toLocaleString(this.getLocale(),{currencyDisplay:T.getCurrencyDisplay(),useGrouping:T.getUseGrouping(),minimumFractionDigits:T.getMinimumFractionDigits(),style:T.getStyle(),currency:this.getCurrency()})},toUnit:function(){return Ae.divide(this.getAmount(),Math.pow(10,h))},toRoundedUnit:function(w){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:S,T=Math.pow(10,w);return Ae.divide(Ae.round(Ae.multiply(this.toUnit(),T),A),T)},toObject:function(){return{amount:m,currency:c,precision:h}},toJSON:function(){return this.toObject()}}},al=Object.assign(Mf,_f,xf,bf);const mi=(l,u)=>new Intl.NumberFormat(u,{style:"currency",currency:l}).formatToParts(1).find(s=>s.type==="currency").value,b=(l,u="EUR")=>al({amount:l,precision:di,...u&&{currency:u}}),ue=(l,u=st)=>{const[s="0",m="0"]=(l||"0").split("."),c=m.substr(0,di).padEnd(di,"0"),h=+`${s}${c}`;return b(h,u)},Fc=(l,{symbol:u,subunit:s})=>`${l.replace(u,"").trimEnd()} ${s}`,Rc=(l,u,s)=>{const[m]=u.split("-"),c=Pc[l]??pf,h=c[m]||c.default,f={symbol:mi(l,u),subunit:h};return s===1||typeof s=="string"&&/^010*$/.test(s)?f:{...f,subunit:`${f.subunit}${m!=="de"?"s":""}`}},Uf=l=>{const u=Number(l);return isNaN(u)?(console.error(`formatAmount: expects an integer amount, received this instead "${l}", fallbacks to zero.`,new Error(`NaN error, unable to cast ${l} to number.`)),0):u},yc=({amount:l,currency:u=st,format:s,locale:m=rl,enableSubunitDisplay:c=!1})=>{const h=Uf(l),f=al({amount:h,currency:u,precision:qt});if(c&&qf(h,u)){const x=Rc(u,m,h);return Fc(f.multiply(100).convertPrecision(qt).setLocale(m).toFormat(s||hf),x)}return f.setLocale(m).toFormat(s||nl)};function $f({decimalAmount:l,useRealPrecision:u,precision:s,shouldDisplayAsCents:m}){if(u){const[,c]=l.split("."),h=zf(c,m),f=m?Math.min(h,gf):h,x="0".repeat(f),p=nl.replace(".00",`.${x}`);return{amountPrecision:f,amountFormat:p}}if(s){const c="0".repeat(s),h=nl.replace(".00",`.${c}`);return{amountPrecision:s,amountFormat:h}}return{amountPrecision:qt,amountFormat:nl}}const Lf=({decimalAmount:l,precision:u,currency:s,format:m,locale:c,useRealPrecision:h=!1,enableSubunitDisplay:f=!1})=>{const x=Wf(l),p=ue(x,s||st),[S,y]=x.split("."),C=Number(S)===0&&p.hasSubUnits(),{amountPrecision:j,amountFormat:v}=$f({decimalAmount:x,useRealPrecision:h,shouldDisplayAsCents:f&&C,precision:u});if(f&&C){const w=Rc(s||st,c||rl,y);return Fc(p.multiply(100).convertPrecision(u??j).setLocale(c||rl).toFormat(m||v),w)}return p.setLocale(c||rl).convertPrecision(u??j).toFormat(m||v)},Of=l=>ue(l).convertPrecision(qt).getAmount();function zf(l,u){const m=!/[1-9]+/g.test(l),c=(l==null?void 0:l.length)??0;return c<2||m?2:u?Math.max(c-qt,qt):c||qt}function qf(l,u){const s=al({amount:100,currency:u||st,precision:qt}),m=al({amount:Math.abs(l),currency:u||st,precision:qt});return m.hasSubUnits()&&m.lessThan(s)}function Wf(l){if(!l||typeof l!="string")return"0.00";const u=/[,\\.]+/g,s=String(l).lastIndexOf(","),m=String(l).lastIndexOf("."),c=s>m?s:m,h=s!==-1&&m!==-1,f=c!==-1?l[c]:".",x=l.split(f).length>2,p=l.substring(0,c===-1?l.length:c).replace(u,""),S=l.substring(c===-1?l.length:c,l.length).replace(u,"");return!h&&x?`${p}${S}.00`:`${p}.${S||"00"}`}const Bf=Object.freeze({standard:.19,reduced:.07,nontaxable:0}),vc={yearly:1,every_6_months:2,every_quarter:4,monthly:12,weekly:52},Vf=["weekly","monthly","every_quarter","every_6_months","yearly"];new Set(Vf);const pi=(l,u,s)=>l.multiply(Hf(u,s)),Dc=(l,u,s)=>{const m=ue(String(l));return pi(m,u,s)},Hf=(l,u)=>{if(l==="monthly"&&u==="weekly")return 1/4;if(l==="weekly"&&u==="monthly")return 4;const s=vc[u],m=vc[l];return!s||!m?1:m/s},Mc=(l,u,s,m)=>{const c=typeof l=="number"?4:12,h=Dc(l,u==null?void 0:u.toLowerCase(),s==null?void 0:s.toLocaleLowerCase()).convertPrecision(c).toUnit().toString();return typeof l=="string"?h:Number(h)},Gf=l=>(l==null?void 0:l.is_tax_inclusive)??!0,Qf=l=>"before_discount_unit_amount_decimal"in l||"after_cashback_amount_total"in l,If=l=>{var u;return!!(l.is_composite_price||(u=l._price)!=null&&u.is_composite_price)},Uc=(l,u,s)=>{var m;if(s){const c=(s.item_components??[]).some(f=>{var x;return((x=f._price)==null?void 0:x.price_display_in_journeys)==="show_as_on_request"}),h=((m=s._price)==null?void 0:m.price_display_in_journeys)==="show_as_on_request";return c||h?!!s.on_request_approved:!0}return!!(u!=="show_as_on_request"||l.on_request_approved)},il=l=>l.type==="fixed"&&typeof l.fixed_value=="number"&&typeof l.fixed_value_decimal=="string"&&typeof l.fixed_value_currency=="string",Hr=l=>l.type==="percentage"&&typeof l.percentage_value=="string"&&!Number.isNaN(Number(l.percentage_value)),$c=l=>il(l)||Hr(l),gi=l=>l.category==="cashback",jc=l=>{const s=new Date(l??"").getTime();return isNaN(s)?0:s},Lc=(l,u)=>{if(l.category!==u.category)return gi(l)?-1:1;if(l.type!==u.type)return Hr(l)?-1:1;let s=0;return Hr(l)?s=Number(u.percentage_value??0)-Number(l.percentage_value??0):il(l)&&(s=(u.fixed_value??0)-(l.fixed_value??0)),s!==0?s:jc(l._created_at)-jc(u._created_at)},Oc=l=>l.flatMap(({coupons:u})=>(u==null?void 0:u.map(({_id:s})=>s))??[]),Kf=(l,u=[])=>{var c;const s=Oc(u);return(c=l==null?void 0:l._coupons)==null?void 0:c.filter(il).filter(gi).filter(h=>h.requires_promo_code?s.includes(h._id):!0).sort(Lc)};var Ce=(l=>(l.perUnit="per_unit",l.tieredGraduated="tiered_graduated",l.tieredVolume="tiered_volume",l.tieredFlatFee="tiered_flatfee",l.dynamicTariff="dynamic_tariff",l.externalGetAG="external_getag",l))(Ce||{}),ll=(l=>(l.perUnit="per_unit",l.tieredVolume="tiered_volume",l.tieredFlatFee="tiered_flatfee",l))(ll||{}),un=(l=>(l.basePrice="base_price",l.workPrice="work_price",l))(un||{}),zc=(l=>(l.dayAheadMarket="day_ahead_market",l.manual="manual",l))(zc||{});const Yf=(l,u=2)=>l.map(s=>qc(s,u)),qc=(l,u=2)=>{var s,m;return{...l,...typeof l.unit_amount=="number"&&{unit_amount:b(l.unit_amount).convertPrecision(u).getAmount(),unit_amount_decimal:b(l.unit_amount).toUnit().toString()},...typeof l.before_discount_unit_amount=="number"&&{before_discount_unit_amount:b(l.before_discount_unit_amount).convertPrecision(u).getAmount(),before_discount_unit_amount_decimal:b(l.before_discount_unit_amount).toUnit().toString()},...typeof l.before_discount_unit_amount_gross=="number"&&{before_discount_unit_amount_gross:b(l.before_discount_unit_amount_gross).convertPrecision(u).getAmount(),before_discount_unit_amount_gross_decimal:b(l.before_discount_unit_amount_gross).toUnit().toString()},...typeof l.before_discount_unit_amount_net=="number"&&{before_discount_unit_amount_net:b(l.before_discount_unit_amount_net).convertPrecision(u).getAmount(),before_discount_unit_amount_net_decimal:b(l.before_discount_unit_amount_net).toUnit().toString()},...typeof l.unit_discount_amount=="number"&&{unit_discount_amount:b(l.unit_discount_amount).convertPrecision(u).getAmount(),unit_discount_amount_decimal:b(l.unit_discount_amount).toUnit().toString()},...typeof l.unit_amount_net=="number"&&{unit_amount_net:b(l.unit_amount_net).convertPrecision(u).getAmount(),unit_amount_net_decimal:b(l.unit_amount_net).toUnit().toString()},...typeof l.unit_discount_amount_net=="number"&&{unit_discount_amount_net:b(l.unit_discount_amount_net).convertPrecision(u).getAmount(),unit_discount_amount_net_decimal:b(l.unit_discount_amount_net).toUnit().toString()},...typeof l.unit_amount_gross=="number"&&{unit_amount_gross:b(l.unit_amount_gross).convertPrecision(u).getAmount(),unit_amount_gross_decimal:b(l.unit_amount_gross).toUnit().toString()},amount_subtotal:b(l.amount_subtotal).convertPrecision(u).getAmount(),amount_subtotal_decimal:b(l.amount_subtotal).toUnit().toString(),amount_total:b(l.amount_total).convertPrecision(u).getAmount(),amount_total_decimal:b(l.amount_total).toUnit().toString(),...typeof l.discount_amount=="number"&&{discount_amount:b(l.discount_amount).convertPrecision(u).getAmount(),discount_amount_decimal:b(l.discount_amount).toUnit().toString()},...typeof l.discount_percentage=="number"&&{discount_percentage:l.discount_percentage},...typeof l.before_discount_amount_total=="number"&&{before_discount_amount_total:b(l.before_discount_amount_total).convertPrecision(u).getAmount(),before_discount_amount_total_decimal:b(l.before_discount_amount_total).toUnit().toString()},...typeof l.before_discount_amount_subtotal=="number"&&{before_discount_amount_subtotal:b(l.before_discount_amount_subtotal).convertPrecision(u).getAmount(),before_discount_amount_subtotal_decimal:b(l.before_discount_amount_subtotal).toUnit().toString()},...typeof l.cashback_amount=="number"&&{cashback_amount:b(l.cashback_amount).convertPrecision(u).getAmount(),cashback_amount_decimal:b(l.cashback_amount).toUnit().toString()},...typeof l.after_cashback_amount_total=="number"&&{after_cashback_amount_total:b(l.after_cashback_amount_total).convertPrecision(u).getAmount(),after_cashback_amount_total_decimal:b(l.after_cashback_amount_total).toUnit().toString()},amount_tax:b(l.amount_tax||0).convertPrecision(u).getAmount(),...typeof l.tax_discount_amount=="number"&&{tax_discount_amount:b(l.tax_discount_amount).convertPrecision(u).getAmount(),tax_discount_amount_decimal:b(l.tax_discount_amount).toUnit().toString()},...typeof l.discount_amount_net=="number"&&{discount_amount_net:b(l.discount_amount_net).convertPrecision(u).getAmount(),discount_amount_net_decimal:b(l.discount_amount_net).toUnit().toString()},...typeof l.before_discount_tax_amount=="number"&&{before_discount_tax_amount:b(l.before_discount_tax_amount).convertPrecision(u).getAmount(),before_discount_tax_amount_decimal:b(l.before_discount_tax_amount).toUnit().toString()},taxes:l.taxes.map(c=>({...c,amount:b(c.amount||0).convertPrecision(u).getAmount()})),...l.tiers_details&&{tiers_details:l.tiers_details.map(c=>({...c,unit_amount_gross:b(c.unit_amount_gross).convertPrecision(u).getAmount(),unit_amount_net:b(c.unit_amount_net).convertPrecision(u).getAmount(),amount_total:b(c.amount_total).convertPrecision(u).getAmount(),amount_subtotal:b(c.amount_subtotal).convertPrecision(u).getAmount(),amount_tax:b(c.amount_tax).convertPrecision(u).getAmount()}))},...l.get_ag&&(l.pricing_model===Ce.externalGetAG||((s=l._price)==null?void 0:s.pricing_model)===Ce.externalGetAG)&&{get_ag:{...l.get_ag,unit_amount_net:b(l.get_ag.unit_amount_net).convertPrecision(u).getAmount(),unit_amount_gross:b(l.get_ag.unit_amount_gross).convertPrecision(u).getAmount(),unit_amount_net_decimal:b(l.get_ag.unit_amount_net).toUnit().toString(),unit_amount_gross_decimal:b(l.get_ag.unit_amount_gross).toUnit().toString(),markup_amount_net:b(l.get_ag.markup_amount_net).convertPrecision(u).getAmount(),markup_amount_net_decimal:b(l.get_ag.markup_amount_net).toUnit().toString(),markup_amount_gross:b(l.get_ag.markup_amount_gross).convertPrecision(u).getAmount(),markup_amount_gross_decimal:b(l.get_ag.markup_amount_gross).toUnit().toString(),...l.get_ag.additional_markups_enabled&&l.get_ag.additional_markups&&{additional_markups:Object.entries(l.get_ag.additional_markups).reduce((c,[h,f])=>({...c,[h]:{amount:f.amount,amount_decimal:f.amount_decimal,amount_net:Number.isInteger(f.amount_net)?b(f.amount_net).convertPrecision(u).getAmount():void 0,amount_gross:Number.isInteger(f.amount_gross)?b(f.amount_gross).convertPrecision(u).getAmount():void 0,amount_net_decimal:Number.isInteger(f.amount_net)?b(f.amount_net).toUnit().toString():void 0,amount_gross_decimal:Number.isInteger(f.amount_gross)?b(f.amount_gross).toUnit().toString():void 0}}),{})},markup_total_amount_net:b(l.get_ag.markup_total_amount_net).convertPrecision(u).getAmount(),markup_total_amount_net_decimal:b(l.get_ag.markup_total_amount_net).toUnit().toString(),markup_total_amount_gross:b(l.get_ag.markup_total_amount_gross).convertPrecision(u).getAmount(),markup_total_amount_gross_decimal:b(l.get_ag.markup_total_amount_gross).toUnit().toString()}},...l.dynamic_tariff&&(l.pricing_model===Ce.dynamicTariff||((m=l._price)==null?void 0:m.pricing_model)===Ce.dynamicTariff)&&{dynamic_tariff:{...l.dynamic_tariff,unit_amount_net:l.dynamic_tariff.unit_amount_net?b(l.dynamic_tariff.unit_amount_net).convertPrecision(u).getAmount():void 0,unit_amount_gross:l.dynamic_tariff.unit_amount_gross?b(l.dynamic_tariff.unit_amount_gross).convertPrecision(u).getAmount():void 0,unit_amount_net_decimal:l.dynamic_tariff.unit_amount_net?b(l.dynamic_tariff.unit_amount_net).toUnit().toString():void 0,unit_amount_gross_decimal:l.dynamic_tariff.unit_amount_gross?b(l.dynamic_tariff.unit_amount_gross).toUnit().toString():void 0,markup_amount_net:l.dynamic_tariff.markup_amount_net?b(l.dynamic_tariff.markup_amount_net).convertPrecision(u).getAmount():void 0,markup_amount_net_decimal:l.dynamic_tariff.markup_amount_net?b(l.dynamic_tariff.markup_amount_net).toUnit().toString():void 0,markup_amount_gross:l.dynamic_tariff.markup_amount_gross?b(l.dynamic_tariff.markup_amount_gross).convertPrecision(u).getAmount():void 0,markup_amount_gross_decimal:l.dynamic_tariff.markup_amount_gross?b(l.dynamic_tariff.markup_amount_gross).toUnit().toString():void 0}}}},Xf=l=>!!(l&&typeof l=="object"&&"amount_tax"in l&&l.amount_tax!==void 0),Nc=(l,u)=>{var s,m,c,h,f,x,p,S,y,C,j;return{amount_subtotal:b(l.amount_subtotal).convertPrecision(u).getAmount(),amount_total:b(l.amount_total).convertPrecision(u).getAmount(),...Xf(l)&&{amount_tax:b(l.amount_tax).convertPrecision(u).getAmount()},total_details:{...l.total_details,amount_tax:b((s=l.total_details)==null?void 0:s.amount_tax).convertPrecision(u).getAmount(),breakdown:{...(m=l.total_details)==null?void 0:m.breakdown,taxes:(h=(c=l.total_details)==null?void 0:c.breakdown)==null?void 0:h.taxes.map(v=>({...v,amount:b(v.amount).convertPrecision(u).getAmount()})),recurrences:(x=(f=l.total_details)==null?void 0:f.breakdown)==null?void 0:x.recurrences.map(v=>({...v,unit_amount_gross:b(v.unit_amount_gross).convertPrecision(u).getAmount(),...Number.isInteger(v.unit_amount_net)&&{unit_amount_net:b(v.unit_amount_net).convertPrecision(u).getAmount()},amount_subtotal:b(v.amount_subtotal).convertPrecision(u).getAmount(),amount_total:b(v.amount_total).convertPrecision(u).getAmount(),amount_tax:b(v.amount_tax).convertPrecision(u).getAmount(),...Number.isInteger(v.discount_amount)&&{discount_amount:b(v.discount_amount).convertPrecision(u).getAmount()},...Number.isInteger(v.before_discount_amount_total)&&{before_discount_amount_total:b(v.before_discount_amount_total).convertPrecision(u).getAmount()},...Number.isInteger(v.before_discount_amount_subtotal)&&{before_discount_amount_subtotal:b(v.before_discount_amount_subtotal).convertPrecision(u).getAmount()},...typeof v.after_cashback_amount_total=="number"&&Number.isInteger(v.after_cashback_amount_total)&&{after_cashback_amount_total:b(v.after_cashback_amount_total).convertPrecision(u).getAmount()}})),recurrencesByTax:(S=(p=l.total_details)==null?void 0:p.breakdown)==null?void 0:S.recurrencesByTax.map(v=>{var w;return{...v,amount_total:b(v.amount_total).convertPrecision(u).getAmount(),amount_subtotal:b(v.amount_subtotal).convertPrecision(u).getAmount(),amount_tax:b(v.amount_tax).convertPrecision(u).getAmount(),tax:{...v.tax,amount:b((w=v.tax)==null?void 0:w.amount).convertPrecision(u).getAmount()}}}),cashbacks:(j=(C=(y=l.total_details)==null?void 0:y.breakdown)==null?void 0:C.cashbacks)==null?void 0:j.map(v=>({...v,amount_total:b(v.amount_total).convertPrecision(u).getAmount()}))}}}},Zf=(l,u)=>({...l,items:l.items.map(s=>s.total_details?{...s,...Nc(s,u)}:s),...Nc(l,u)}),Jf=({before_discount_amount_total:l,before_discount_amount_total_decimal:u,before_discount_amount_subtotal:s,before_discount_amount_subtotal_decimal:m,before_discount_unit_amount:c,before_discount_unit_amount_decimal:h,before_discount_unit_amount_gross:f,before_discount_unit_amount_gross_decimal:x,before_discount_unit_amount_net:p,before_discount_unit_amount_net_decimal:S,before_discount_tax_amount:y,before_discount_tax_amount_decimal:C,discount_amount:j,discount_amount_decimal:v,discount_percentage:w,discount_amount_net:A,discount_amount_net_decimal:T,tax_discount_amount:U,tax_discount_amount_decimal:I,unit_discount_amount:_,unit_discount_amount_decimal:$,unit_discount_amount_net:R,unit_discount_amount_net_decimal:M,cashback_amount:L,cashback_amount_decimal:H,after_cashback_amount_total:te,after_cashback_amount_total_decimal:Q,cashback_period:_e,...xe})=>({...xe,...c&&{unit_amount:c,unit_amount_decimal:h},_price:xe._price}),ep=(l,u,s=2)=>({...l&&typeof l=="number"&&{cashback_amount:b(l).convertPrecision(s).getAmount(),cashback_amount_decimal:b(l).toUnit().toString()},...u}),Wc=(l,u,s)=>{if(l)return l;if(Array.isArray(s)&&s.length>0)return s[0].tax;const m=l===null,c=Array.isArray(u==null?void 0:u.tax)&&u.tax[0];return!m&&c?c:l},tp=l=>l.pricing_model===Ce.tieredVolume||l.pricing_model===Ce.tieredGraduated||l.pricing_model===Ce.tieredFlatFee,np=l=>{if(l.is_composite_price||Array.isArray(l.price_components))return!1;const u=l,{pricing_model:s,get_ag:m,variable_price:c}=u;return tp(u)||s===Ce.dynamicTariff?!0:s===Ce.externalGetAG?(m==null?void 0:m.type)===un.workPrice||(m==null?void 0:m.type)===un.basePrice&&(m==null?void 0:m.markup_pricing_model)===ll.tieredFlatFee:s===Ce.perUnit||!s?!!c:!1},Bc=new Set(["_org","_schema","_created_at","_updated_at","_owners","_acl","_acl_sync","_viewers","_relations","$relation","file","_files","workflows","_slug"]),rp=l=>Array.isArray(l),ol=l=>l?Object.fromEntries(Object.entries(l).filter(([u])=>!Bc.has(u)).map(([u,s])=>u==="price_components"&&rp(s)?[u,s.map(m=>ol(m))]:[u,s])):{},Vc=l=>l?Object.fromEntries(Object.entries(l).filter(([u])=>!Bc.has(u))):void 0,Jn=l=>typeof l=="number"&&!Number.isNaN(l)?l:1,ap=(l,u)=>{if(!u||!l||typeof l.value!="number"&&!l.frequency_unit)return null;const s=Jn(l.value);return u.type!=="one_time"&&l.value?Dc(s,l.frequency_unit,u.billing_period):ue(String(s))},ii=(l,u,s)=>Math.min(Math.max(l,u),s),sl=l=>{var u;return l?Array.isArray(l)?(Number((u=l[0])==null?void 0:u.rate)||0)/100:(Number(l.rate)||0)/100:Bf.nontaxable},lp=(l,{priceItem:u,currency:s,isTaxInclusive:m,unitAmountMultiplier:c,tax:h,coupon:f})=>{var $,R;const x=sl(h);let p,S,y,C,j;const v=b(l.unit_amount_net,s),w=b(l.unit_amount_gross,s);if(gi(f)){if(il(f))C=ue(f.fixed_value_decimal,f.fixed_value_currency);else{const H=ii(Number(f.percentage_value),0,100);C=w.multiply(H).divide(100)}const M=C.multiply(c),L=pi(M,"yearly",($=u==null?void 0:u._price)==null?void 0:$.billing_period);return j=w.subtract(L),{...l,cashback_amount:M.getAmount(),after_cashback_amount_total:j.getAmount()}}if(((R=u._price)==null?void 0:R.pricing_model)===Ce.tieredGraduated&&l.tiers_details){const L=l.tiers_details.map(H=>{const te=b(H.unit_amount_net,s),Q=b(H.unit_amount_gross,s);if(Hr(f))p=ii(Number(f.percentage_value),0,100),m?(S=Q.multiply(p).divide(100),y=S.divide(1+x)):(y=te.multiply(p).divide(100),S=y.multiply(1+x));else{const De=ue(f.fixed_value_decimal,f.fixed_value_currency);m?(S=De.greaterThan(Q)?Q:De,y=S.divide(1+x)):(y=De.greaterThan(te)?te:De,S=y.multiply(1+x))}const _e=te.subtract(y),xe=m?Q.subtract(S):_e.multiply(1+x),Te=m?Q.subtract(te):te.multiply(x),Ie=xe.subtract(_e).multiply(H.quantity),Je=m?S.subtract(y).multiply(H.quantity):y.multiply(x).multiply(H.quantity);return{quantity:H.quantity,unit_amount_gross:xe.getAmount(),unit_amount_net:_e.getAmount(),amount_subtotal:_e.multiply(H.quantity).getAmount(),amount_total:xe.multiply(H.quantity).getAmount(),amount_tax:Ie.getAmount(),unit_discount_amount:S.getAmount(),before_discount_unit_amount:m?Q.getAmount():te.getAmount(),before_discount_unit_amount_gross:Q.getAmount(),before_discount_unit_amount_net:te.getAmount(),unit_discount_amount_net:y.getAmount(),tax_discount_amount:Je.getAmount(),before_discount_tax_amount:Te.multiply(H.quantity).getAmount(),discount_amount:S.multiply(H.quantity).getAmount(),discount_amount_net:y.multiply(H.quantity).getAmount(),before_discount_amount_total:Q.multiply(H.quantity).getAmount(),before_discount_amount_subtotal:te.multiply(H.quantity).getAmount()}}).reduce((H,te)=>({unit_amount_gross:b(H.unit_amount_gross).add(b(te.unit_amount_gross)).getAmount(),unit_amount_net:b(H.unit_amount_net).add(b(te.unit_amount_net)).getAmount(),amount_subtotal:b(H.amount_subtotal).add(b(te.amount_subtotal)).getAmount(),amount_total:b(H.amount_total).add(b(te.amount_total)).getAmount(),amount_tax:b(H.amount_tax).add(b(te.amount_tax)).getAmount(),unit_discount_amount:b(H.unit_discount_amount||0).add(b(te.unit_discount_amount)).getAmount(),before_discount_unit_amount:b(H.before_discount_unit_amount||0).add(b(te.before_discount_unit_amount)).getAmount(),before_discount_unit_amount_gross:b(H.before_discount_unit_amount_gross||0).add(b(te.before_discount_unit_amount_gross)).getAmount(),before_discount_unit_amount_net:b(H.before_discount_unit_amount_net||0).add(b(te.before_discount_unit_amount_net)).getAmount(),unit_discount_amount_net:b(H.unit_discount_amount_net||0).add(b(te.unit_discount_amount_net)).getAmount(),tax_discount_amount:b(H.tax_discount_amount||0).add(b(te.tax_discount_amount)).getAmount(),before_discount_tax_amount:b(H.before_discount_tax_amount||0).add(b(te.before_discount_tax_amount)).getAmount(),discount_amount:b(H.discount_amount||0).add(b(te.discount_amount)).getAmount(),discount_amount_net:b(H.discount_amount_net||0).add(b(te.discount_amount_net)).getAmount(),before_discount_amount_total:b(H.before_discount_amount_total||0).add(b(te.before_discount_amount_total)).getAmount(),before_discount_amount_subtotal:b(H.before_discount_amount_subtotal||0).add(b(te.before_discount_amount_subtotal)).getAmount()}),{unit_amount_gross:0,unit_amount_net:0,amount_subtotal:0,amount_total:0,amount_tax:0,unit_discount_amount:0,before_discount_unit_amount:0,before_discount_unit_amount_gross:0,before_discount_unit_amount_net:0,unit_discount_amount_net:0,tax_discount_amount:0,before_discount_tax_amount:0,discount_amount:0,discount_amount_net:0,before_discount_amount_total:0,before_discount_amount_subtotal:0});return{...l,...L,tiers_details:l.tiers_details,...typeof p=="number"&&{discount_percentage:p}}}if(Hr(f))p=ii(Number(f.percentage_value),0,100),m?(S=w.multiply(p).divide(100),y=S.divide(1+x)):(y=v.multiply(p).divide(100),S=y.multiply(1+x));else{const M=ue(f.fixed_value_decimal,f.fixed_value_currency);m?(S=M.greaterThan(w)?w:M,y=S.divide(1+x)):(y=M.greaterThan(v)?v:M,S=y.multiply(1+x))}const A=v.subtract(y),T=m?w.subtract(S):A.multiply(1+x),U=m?w.subtract(v):v.multiply(x),I=T.subtract(A).multiply(c),_=m?S.subtract(y).multiply(c):y.multiply(x).multiply(c);return{...l,unit_amount:m?T.getAmount():A.getAmount(),unit_amount_gross:T.getAmount(),unit_amount_net:A.getAmount(),amount_subtotal:A.multiply(c).getAmount(),amount_total:T.multiply(c).getAmount(),amount_tax:I.getAmount(),unit_discount_amount:S.getAmount(),before_discount_unit_amount:m?w.getAmount():v.getAmount(),before_discount_unit_amount_gross:w.getAmount(),before_discount_unit_amount_net:v.getAmount(),unit_discount_amount_net:y.getAmount(),tax_discount_amount:_.getAmount(),before_discount_tax_amount:U.multiply(c).getAmount(),discount_amount:S.multiply(c).getAmount(),discount_amount_net:y.multiply(c).getAmount(),...typeof p=="number"&&{discount_percentage:p},before_discount_amount_total:w.multiply(c).getAmount(),before_discount_amount_subtotal:v.multiply(c).getAmount()}},er=({unitAmountDecimal:l,currency:u,isTaxInclusive:s,unitAmountMultiplier:m,tax:c})=>{const h=ue(l,u),f=sl(c);let x,p;s?(x=h.divide(1+f),p=h.subtract(x)):(x=h,p=h.multiply(f));const S=x.add(p),y=p.multiply(m),C=x.multiply(m),j=S.multiply(m);return{unit_amount:h.getAmount(),unit_amount_net:x.getAmount(),unit_amount_gross:S.getAmount(),amount_subtotal:C.getAmount(),amount_total:j.getAmount(),amount_tax:y.getAmount()}},op=({dynamicTariff:l,currency:u,isTaxInclusive:s,unitAmountMultiplier:m,externalFeeAmountDecimal:c,tax:h})=>{if(c===void 0||l===void 0)return{unit_amount_net:0,unit_amount_gross:0,amount_tax:0,amount_subtotal:0,amount_total:0,dynamic_tariff:{...l,unit_amount_net:0,unit_amount_gross:0,markup_amount_net:0,markup_amount_gross:0}};const f=sl(h);if(l.mode===zc.manual){const A=ue(l.average_price_decimal),T=s?A.divide(1+f).getAmount():A.getAmount(),U=s?A.getAmount():A.multiply(1+f).getAmount();return{...er({unitAmountDecimal:A.toUnit().toString(),currency:u,isTaxInclusive:s,unitAmountMultiplier:m,tax:h}),dynamic_tariff:{...l,markup_amount_net:T,markup_amount_gross:U,unit_amount_net:0,unit_amount_gross:0}}}const x=ue(l.markup_amount_decimal),p=s?x.divide(1+f).getAmount():x.getAmount(),S=s?x.getAmount():x.multiply(1+f).getAmount(),y=ue(c),C=y.getAmount(),j=y.multiply(1+f).getAmount(),v=s?y.multiply(1+f).add(x).toUnit().toString():y.add(x).toUnit().toString();return{...er({unitAmountDecimal:v,currency:u,isTaxInclusive:s,unitAmountMultiplier:m,tax:h}),dynamic_tariff:{...l,markup_amount_net:p,markup_amount_gross:S,unit_amount_net:C,unit_amount_gross:j}}},ip=(l,u)=>(s,m)=>{var c;return m===0?u>=0:u>(((c=l[m-1])==null?void 0:c.up_to)||0)},Hc=(l,u)=>l.filter(ip(l,u)),Gc=(l,u)=>{const s=Hc(l,u);return s[s.length-1]??null},Qc=({tiers:l=[],currency:u,isTaxInclusive:s,quantityToSelectTier:m,tax:c,quantity:h,isUsingPriceMappingToSelectTier:f,unchangedPriceDisplayInJourneys:x})=>{const p=Gc(l,m),S=f?h:1,y=er({unitAmountDecimal:p==null?void 0:p.flat_fee_amount_decimal,currency:u,isTaxInclusive:s,unitAmountMultiplier:S,tax:c}),C=(p==null?void 0:p.display_mode)==="on_request"?"show_as_on_request":x;return{tiers_details:[{quantity:m,unit_amount:(p==null?void 0:p.flat_fee_amount)||0,unit_amount_decimal:(p==null?void 0:p.flat_fee_amount_decimal)||"0",unit_amount_net:y.unit_amount_net||0,unit_amount_gross:y.unit_amount_gross||0,amount_subtotal:y.unit_amount_net||0,amount_total:y.unit_amount_gross||0,amount_tax:b(y.unit_amount_gross).subtract(b(y.unit_amount_net)).getAmount()||0}],unit_amount_gross:b(y.unit_amount_gross).getAmount(),unit_amount_net:b(y.unit_amount_net).getAmount(),amount_subtotal:b(y.amount_subtotal).getAmount(),amount_total:b(y.amount_total).getAmount(),amount_tax:b(y.amount_tax).getAmount(),price_display_in_journeys:C}},Ic=({tiers:l=[],currency:u,isTaxInclusive:s,quantityToSelectTier:m,tax:c,unitAmountMultiplier:h,unchangedPriceDisplayInJourneys:f})=>{const x=Gc(l,m),p=er({unitAmountDecimal:x==null?void 0:x.unit_amount_decimal,currency:u,isTaxInclusive:s,unitAmountMultiplier:h,tax:c}),S=(x==null?void 0:x.display_mode)==="on_request"?"show_as_on_request":f;return{tiers_details:[{quantity:h,unit_amount:(x==null?void 0:x.unit_amount)||0,unit_amount_decimal:(x==null?void 0:x.unit_amount_decimal)||"0",unit_amount_net:p.unit_amount_net||0,unit_amount_gross:p.unit_amount_gross||0,amount_subtotal:p.amount_subtotal||0,amount_total:p.amount_total||0,amount_tax:p.amount_tax||0}],unit_amount_gross:b(p.unit_amount_gross).getAmount(),unit_amount_net:b(p.unit_amount_net).getAmount(),amount_subtotal:b(p.amount_subtotal).getAmount(),amount_total:b(p.amount_total).getAmount(),amount_tax:b(p.amount_tax).getAmount(),price_display_in_journeys:S}},sp=({getAg:l,currency:u,isTaxInclusive:s,unitAmountMultiplier:m,userInput:c,externalFeeAmountDecimal:h,tax:f})=>{var te;if(h===void 0||l===void 0||c===0)return{unit_amount_net:0,unit_amount_gross:0,amount_tax:0,amount_subtotal:0,amount_total:0,get_ag:{...l,unit_amount_net:0,unit_amount_gross:0,markup_amount_net:0,markup_amount_gross:0,markup_total_amount_net:0,markup_total_amount_gross:0}};const x=sl(f),p=l.markup_pricing_model===ll.tieredVolume&&l.markup_tiers?Ic({tiers:l.markup_tiers,currency:u,isTaxInclusive:s,quantityToSelectTier:c,tax:f,unitAmountMultiplier:c,unchangedPriceDisplayInJourneys:"show_price"}):l.markup_pricing_model===ll.tieredFlatFee&&l.markup_tiers?Qc({tiers:l.markup_tiers,currency:u,isTaxInclusive:s,quantityToSelectTier:c,tax:f,quantity:c,isUsingPriceMappingToSelectTier:!0,unchangedPriceDisplayInJourneys:"show_price"}):{unit_amount_net:s?ue(l.markup_amount_decimal).divide(1+x).getAmount():ue(l.markup_amount_decimal).getAmount(),unit_amount_gross:s?ue(l.markup_amount_decimal).getAmount():ue(l.markup_amount_decimal).multiply(1+x).getAmount()},S=(te=p.tiers_details)==null?void 0:te[0],y=l.type===un.workPrice&&l.additional_markups_enabled&&l.additional_markups?Object.entries(l.additional_markups).reduce((Q,[_e,xe])=>({...Q,[_e]:{amount_net:s?ue(xe.amount_decimal).divide(1+x).getAmount():ue(xe.amount_decimal).getAmount(),amount_gross:s?ue(xe.amount_decimal).getAmount():ue(xe.amount_decimal).multiply(1+x).getAmount(),amount_decimal:xe.amount_decimal,amount:xe.amount}}),{}):void 0,C=y?Object.values(y).reduce((Q,_e)=>({amount_net:b(Q.amount_net||0).add(b(_e.amount_net||0)).getAmount(),amount_gross:b(Q.amount_gross||0).add(b(_e.amount_gross||0)).getAmount()}),{amount_net:0,amount_gross:0}):void 0,j=C?{unit_amount_net:b(p.unit_amount_net||0).add(b(C.amount_net||0)).getAmount(),unit_amount_gross:b(p.unit_amount_gross||0).add(b(C.amount_gross||0)).getAmount()}:p,v=l.type===un.basePrice?ue(h):ue(h).divide(c),w=v.multiply(1+x),A=v.add(b(j.unit_amount_net||0)),T=A.multiply(1+x),U=T.subtract(A),I=b(p.unit_amount_net||0),_=b(p.unit_amount_gross||0),$=b(j.unit_amount_net||0),R=b(j.unit_amount_gross||0),M=l.type===un.basePrice?A:A.multiply(m),L=l.type===un.basePrice?T:T.multiply(m),H=l.type===un.basePrice?U:U.multiply(m);return{unit_amount_net:A.getAmount(),unit_amount_gross:T.getAmount(),amount_tax:H.getAmount(),amount_subtotal:M.getAmount(),amount_total:L.getAmount(),get_ag:{...l,unit_amount_net:v.getAmount(),unit_amount_gross:w.getAmount(),markup_amount_net:I.getAmount(),markup_amount_gross:_.getAmount(),markup_amount:(S?S==null?void 0:S.unit_amount:l.markup_amount)||0,markup_total_amount_net:$.getAmount(),markup_total_amount_gross:R.getAmount(),additional_markups:y,markup_amount_decimal:(S?S==null?void 0:S.unit_amount_decimal:l.markup_amount_decimal)||"0"}}},up=({min:l,max:u,quantity:s})=>{if(typeof l!="number"||isNaN(l))throw new Error("Tier min quantity must be a number");if(typeof u!="number"||isNaN(u))throw new Error("Tier max quantity must be a number");if(l>=u)throw new Error("Tier min quantity must be less than tier max quantity");if(s=u?ue(u.toString(),st).subtract(ue(l.toString(),st)).toUnit():ue(s.toString(),st).subtract(ue(l.toString(),st)).toUnit()},cp=({tiers:l=[],currency:u,isTaxInclusive:s,quantityToSelectTier:m,tax:c,quantity:h,isUsingPriceMappingToSelectTier:f,unchangedPriceDisplayInJourneys:x})=>{const S=Hc(l,m).reduce((C,j,v)=>{const w=v===0?0:l[v-1].up_to??void 0,A=j.up_to||1/0,T=up({min:w,max:A,quantity:m}),U=er({unitAmountDecimal:j.unit_amount_decimal,currency:u,isTaxInclusive:s,unitAmountMultiplier:T,tax:c}),I=(j==null?void 0:j.display_mode)==="on_request"?"show_as_on_request":x;return{tiers_details:[...C.tiers_details||[],{quantity:T,unit_amount:j.unit_amount||0,unit_amount_decimal:j.unit_amount_decimal||"0",unit_amount_net:U.unit_amount_net||0,unit_amount_gross:U.unit_amount_gross||0,amount_subtotal:U.amount_subtotal||0,amount_total:U.amount_total||0,amount_tax:U.amount_tax||0}],unit_amount_gross:b(C.unit_amount_gross).add(b(U.unit_amount_gross)).getAmount(),unit_amount_net:b(C.unit_amount_net).add(b(U.unit_amount_net)).getAmount(),amount_subtotal:b(C.amount_subtotal).add(b(U.amount_subtotal)).getAmount(),amount_total:b(C.amount_total).add(b(U.amount_total)).getAmount(),amount_tax:b(C.amount_tax).add(b(U.amount_tax)).getAmount(),price_display_in_journeys:I}},{unit_amount_gross:0,unit_amount_net:0,amount_subtotal:0,amount_total:0,amount_tax:0}),y=f?h:1;return{...S,amount_subtotal:b(S.amount_subtotal).multiply(y).getAmount(),amount_total:b(S.amount_total).multiply(y).getAmount(),amount_tax:b(S.amount_tax).multiply(y).getAmount()}},dp=(l,u)=>{if(!(!l||!l.amount_total_decimal))return u?Mc(l.amount_total_decimal,l.frequency_unit,u):l.amount_total_decimal},mp=(l,u,s)=>{const m=Jn(u);if(!l||!np(l))return{safeQuantity:m,unitAmountMultiplier:m,isUsingPriceMappingToSelectTier:!1};const c=ap(s,l),h=c?c.toUnit():1,f=c?c.multiply(m).toUnit():m;return{safeQuantity:m,quantityToSelectTier:h,unitAmountMultiplier:f,isUsingPriceMappingToSelectTier:!!c}},Kc=(l,{tax:u,quantity:s,priceMapping:m,externalFeeMapping:c,redeemedPromos:h})=>{var H,te,Q,_e,xe;const f=Qf(l)?Jf(l):l,x=f._price,p=((x==null?void 0:x.unit_amount_currency)||st).toUpperCase(),S=f.description??(x==null?void 0:x.description),y=Wc(u,x,f.taxes),C=f.is_tax_inclusive??Gf(x),{safeQuantity:j,quantityToSelectTier:v,unitAmountMultiplier:w,isUsingPriceMappingToSelectTier:A}=mp(x,s,m),T=dp(c,f.billing_period||(x==null?void 0:x.billing_period));let U;switch(x==null?void 0:x.pricing_model){case Ce.tieredVolume:U=Ic({tiers:x.tiers,currency:p,isTaxInclusive:C,quantityToSelectTier:v===void 0?1:v,tax:y,unitAmountMultiplier:w,unchangedPriceDisplayInJourneys:(H=f._price)==null?void 0:H.unchanged_price_display_in_journeys});break;case Ce.tieredFlatFee:U=Qc({tiers:x.tiers,currency:p,isTaxInclusive:C,quantityToSelectTier:v===void 0?1:v,tax:y,quantity:j,isUsingPriceMappingToSelectTier:A,unchangedPriceDisplayInJourneys:(te=f._price)==null?void 0:te.unchanged_price_display_in_journeys});break;case Ce.tieredGraduated:U=cp({tiers:x.tiers,currency:p,isTaxInclusive:C,quantityToSelectTier:v===void 0?1:v,tax:y,quantity:j,isUsingPriceMappingToSelectTier:A,unchangedPriceDisplayInJourneys:(Q=f._price)==null?void 0:Q.unchanged_price_display_in_journeys});break;case Ce.dynamicTariff:U=op({dynamicTariff:x.dynamic_tariff,currency:p,isTaxInclusive:C,unitAmountMultiplier:w,externalFeeAmountDecimal:T,tax:y});break;case Ce.externalGetAG:U=sp({getAg:x.get_ag,currency:p,isTaxInclusive:C,unitAmountMultiplier:w,userInput:v===void 0?1:v,externalFeeAmountDecimal:T,tax:y});break;case Ce.perUnit:default:U=er({unitAmountDecimal:f.unit_amount_decimal||(x==null?void 0:x.unit_amount_decimal)||"0",currency:p,isTaxInclusive:C,unitAmountMultiplier:w,tax:y})}const I=Oc(h),_=(_e=f._coupons)==null?void 0:_e.filter($c).filter(Te=>Te.requires_promo_code?I.includes(Te._id):!0).sort(Lc),$=_==null?void 0:_.slice(0,1),[R]=$??[];if(R){const Te=(x==null?void 0:x.pricing_model)===Ce.tieredFlatFee?j:w;U=lp(U,{priceItem:f,currency:p,isTaxInclusive:C,unitAmountMultiplier:Te,tax:y,coupon:R})}const M=R==null?void 0:R.cashback_period,L=(f==null?void 0:f.type)??(x==null?void 0:x.type);return{...f,...U,...$&&{_coupons:$},currency:p,...S&&{description:S},...Number.isInteger(U.cashback_amount)&&{cashback_period:M??"0"},taxes:[{...y?{tax:y}:{rate:"nontaxable",rateValue:0},amount:U.amount_tax}],...f._product&&{_product:Vc(f._product)},type:L,...L==="recurring"&&{billing_period:f.billing_period??(x==null?void 0:x.billing_period)},_price:{...ol(x),...U.price_display_in_journeys&&{price_display_in_journeys:U.price_display_in_journeys??(x==null?void 0:x.price_display_in_journeys),unchanged_price_display_in_journeys:((xe=f._price)==null?void 0:xe.unchanged_price_display_in_journeys)??(x==null?void 0:x.price_display_in_journeys)}},is_tax_inclusive:C}},si=l=>{var h,f;const u=ue(l.amount_total_decimal||"0"),s=ue(l.amount_subtotal_decimal||"0"),m=u.subtract(s).getAmount(),c=(f=(h=l._coupons)==null?void 0:h.filter($c))==null?void 0:f[0];return{...l,amount_total:u.getAmount(),amount_subtotal:s.getAmount(),unit_amount_gross:ue(l.unit_amount_gross_decimal||"0").getAmount(),unit_amount_net:ue(l.unit_amount_net_decimal||"0").getAmount(),unit_amount:ue(l.unit_amount_decimal||"0").getAmount(),amount_tax:m,...l.taxes&&Array.isArray(l.taxes)&&l.taxes[0]&&{taxes:[{...l.taxes[0],amount:m},...l.taxes.slice(1)]},...c&&c.category==="discount"&&{discount_amount:ue(l.discount_amount_decimal||"0").getAmount(),discount_amount_net:ue(l.discount_amount_net_decimal||"0").getAmount(),before_discount_amount_total:ue(l.before_discount_amount_total_decimal||"0").getAmount(),before_discount_amount_subtotal:ue(l.before_discount_amount_subtotal_decimal||"0").getAmount(),before_discount_tax_amount:ue(l.before_discount_tax_amount_decimal||"0").getAmount(),before_discount_unit_amount:ue(l.before_discount_unit_amount_decimal||"0").getAmount(),before_discount_unit_amount_gross:ue(l.before_discount_unit_amount_gross_decimal||"0").getAmount(),before_discount_unit_amount_net:ue(l.before_discount_unit_amount_net_decimal||"0").getAmount(),tax_discount_amount:ue(l.tax_discount_amount_decimal||"0").getAmount(),unit_discount_amount:ue(l.unit_discount_amount_decimal||"0").getAmount(),unit_discount_amount_net:ue(l.unit_discount_amount_net_decimal||"0").getAmount()},...c&&c.category==="cashback"&&{cashback_amount:ue(l.cashback_amount_decimal||"0").getAmount(),after_cashback_amount_total:ue(l.after_cashback_amount_total_decimal||"0").getAmount()}}},fp=l=>{var s,m;const u=(s=l==null?void 0:l.items)==null?void 0:s[0];if(u){if(u.is_composite_price){const c=u;return{...si(c),item_components:(m=c.item_components)==null?void 0:m.map(h=>si(h))}}return si(u)}},pp=(l,u)=>(l==null?void 0:l.type)==="recurring"?u.find(s=>s.type===l.type&&s.billing_period===l.billing_period):u.find(s=>s.type==="one_time"),gp=(l,u,s)=>(l==null?void 0:l.type)==="recurring"?u.find(m=>{var c,h;return m.type===l.type&&m.billing_period===l.billing_period&&(!s||((h=(c=m.tax)==null?void 0:c.tax)==null?void 0:h.rate)===s)}):u.find(m=>{var c,h;return m.type==="one_time"&&(!s||((h=(c=m.tax)==null?void 0:c.tax)==null?void 0:h.rate)===s)}),hp=(l,u,{redeemedPromos:s=[]}={})=>{var S,y,C,j;const m=(y=(S=l.taxes)==null?void 0:S[0])==null?void 0:y.tax,c=(C=u.price_mappings)==null?void 0:C.find(({price_id:v})=>l.price_id===v||l._price._id===v),h=(j=u.external_fees_mappings)==null?void 0:j.find(({price_id:v})=>l._price._id===v),f=Jn(l.quantity),x=Jn(u.quantity),p=ue(String(f)).multiply(x).toUnit();return Kc(l,{tax:m,quantity:p,priceMapping:c,externalFeeMapping:h,redeemedPromos:s})},_p=l=>{switch(l.pricing_model||Ce.perUnit){case Ce.perUnit:return!!(typeof l.unit_amount=="number"&&l.unit_amount_decimal);case Ce.tieredFlatFee:case Ce.tieredVolume:case Ce.tieredGraduated:return!!l.tiers;default:return!0}},xp=l=>({...l,unit_amount:Number.isInteger(l.unit_amount)?l.unit_amount:0,unit_amount_decimal:typeof l.unit_amount_decimal<"u"?l.unit_amount_decimal:"0"}),yp=l=>{var u;return Array.isArray(l.item_components)?l.item_components.map(s=>({_itemRef:xp(s),...s._price})):Array.isArray((u=l._price)==null?void 0:u.price_components)?l._price.price_components.filter(_p):[]},vp=(l,u={})=>{var h,f;const m=yp(l).map(x=>{const p=Array.isArray(x.tax)?x.tax:[],S=p[0]&&{tax:p[0]}||{rate:"nontaxable"},{_itemRef:y,...C}=x,j=(y==null?void 0:y.type)||x.type,v={...y,pricing_model:(y==null?void 0:y.pricing_model)||x.pricing_model,quantity:Jn(y==null?void 0:y.quantity),type:j,...j==="recurring"&&{billing_period:(y==null?void 0:y.billing_period)||x.billing_period},price_id:(y==null?void 0:y.price_id)||x._id,product_id:(y==null?void 0:y.product_id)||l.product_id,_price:ol((y==null?void 0:y._price)||C),taxes:(y==null?void 0:y.taxes)||[{...S,...S.tax&&{tax:Wc(S.tax,x)}}],...x._coupons&&{_coupons:x._coupons},...(y==null?void 0:y._coupons)&&{_coupons:y._coupons}};return hp(v,l,u)}),c=l.description??((h=l._price)==null?void 0:h.description);return{...l,...l._product&&{_product:Vc(l._product)},_price:ol(l._price),currency:((f=l._price)==null?void 0:f.unit_amount_currency)||st,...c&&{description:c},item_components:m}},jp=(l,u,s=[])=>{var f,x,p;const m=Kf(l,s),c=[],h=[...((x=(f=u.total_details)==null?void 0:f.breakdown)==null?void 0:x.cashbacks)??[]];for(const S of m??[]){let y;y=ue(S.fixed_value_decimal,S.fixed_value_currency);const C=Jn(l.quantity),v=y.multiply(C).getAmount(),w=(S==null?void 0:S.cashback_period)??"0",A=ep(v,void 0,2);c.push({...S,cashback_amount:A.cashback_amount,cashback_amount_decimal:A.cashback_amount_decimal});const T=h.find(U=>U.cashback_period===w);if(T){const U=b(T.amount_total);T.amount_total=U.add(b(v)).getAmount()}else h.push({cashback_period:w,amount_total:v})}return{pricingDetails:{...u,total_details:{...u.total_details,breakdown:{...(p=u.total_details)==null?void 0:p.breakdown,cashbacks:h}}},...m&&{_coupons:c}}},Np=(l,u)=>{const s=u[0];if(!s||!l.type)return l;const m=b(s.amount_total),c=l.type==="recurring"?pi(m,"yearly",l.billing_period):m,h=b(l.amount_total).subtract(c);return{...l,after_cashback_amount_total:h.getAmount(),after_cashback_amount_total_decimal:h.toUnit().toString()}},Ve=(l,{redeemedPromos:u=[]}={})=>{var h,f,x,p,S,y;const s={items:[],amount_subtotal:0,amount_total:0,amount_tax:0,total_details:{amount_shipping:0,amount_tax:0,breakdown:{taxes:[],recurrences:[],recurrencesByTax:[],cashbacks:[]}},...u.length&&{redeemed_promos:u}},m=l.reduce((C,j)=>{var w,A,T,U,I;const v=fp(j._immutable_pricing_details);if(If(j)){const _=v??vp(j,{redeemedPromos:u}),$=bc(void 0,_,u),R=bc(C,_,u),M={..._,...$,...typeof($==null?void 0:$.amount_subtotal)=="number"&&{amount_subtotal_decimal:b($.amount_subtotal).toUnit().toString()},...typeof($==null?void 0:$.amount_total)=="number"&&{amount_total_decimal:b($.amount_total).toUnit().toString()},item_components:Yf(_.item_components??[],2)};return{...R,items:C.items.concat(M)}}else{const _=j._price,$=(A=(w=j.taxes)==null?void 0:w[0])==null?void 0:A.tax,R=j._price?(T=j.price_mappings)==null?void 0:T.find(({price_id:Q})=>j._price._id===Q):void 0,M=(U=j.external_fees_mappings)==null?void 0:U.find(({price_id:Q})=>j._price._id===Q),L=v??Kc(j,{tax:$,quantity:j.quantity,priceMapping:R,externalFeeMapping:M,redeemedPromos:u}),H=Uc(j,((I=L==null?void 0:L._price)==null?void 0:I.price_display_in_journeys)??(_==null?void 0:_.price_display_in_journeys),void 0)?Yc(C,_,L):C,te=qc(L,2);return{...H,items:C.items.concat(te)}}},s);m.currency=((h=m.items[0])==null?void 0:h.currency)||st;const c=(x=(f=m.total_details)==null?void 0:f.breakdown)==null?void 0:x.cashbacks;return c!=null&&c.length&&(m.total_details.breakdown.recurrences=(y=(S=(p=m.total_details)==null?void 0:p.breakdown)==null?void 0:S.recurrences)==null?void 0:y.map(C=>Np(C,c))),Zf(m,2)},Yc=(l,u,s)=>{var xe,Te,Ie,Je,De,ke,Y,le,Z,P,O,ce,de,pe,ge,ve;const m=((Te=(xe=l.total_details)==null?void 0:xe.breakdown)==null?void 0:Te.taxes)||[],c=(Ie=s.taxes)==null?void 0:Ie[0],h=(c==null?void 0:c.tax)??{rate:Number(c==null?void 0:c.rateValue)},f=(De=(Je=s.taxes)==null?void 0:Je[0])==null?void 0:De.rateValue,x=m.find(ae=>{var me,Ee,St,cn;return((me=ae.tax)==null?void 0:me._id)&&(h==null?void 0:h._id)&&((Ee=ae.tax)==null?void 0:Ee._id)===(h==null?void 0:h._id)||((St=ae.tax)==null?void 0:St.rate)===(h==null?void 0:h.rate)||((cn=ae.tax)==null?void 0:cn.rate)===f}),p=[...((Y=(ke=l.total_details)==null?void 0:ke.breakdown)==null?void 0:Y.recurrences)??[]],S=pp({...s,type:s.type??(u==null?void 0:u.type),billing_period:s.billing_period??(u==null?void 0:u.billing_period)},p),y=[...((Z=(le=l.total_details)==null?void 0:le.breakdown)==null?void 0:Z.recurrencesByTax)??[]],C=gp(u,y,((P=x==null?void 0:x.tax)==null?void 0:P.rate)??(h==null?void 0:h.rate)),j=b(l.amount_total),v=b(l.amount_subtotal),w=b((O=l==null?void 0:l.total_details)==null?void 0:O.amount_tax),A=[...((de=(ce=l.total_details)==null?void 0:ce.breakdown)==null?void 0:de.cashbacks)??[]],T=b(s.unit_amount_gross),U=Number.isInteger(s.unit_amount_net)?b(s.unit_amount_net):null,I=b(s.amount_subtotal),_=b(s.amount_total),$=typeof s.discount_amount<"u"?b(s.discount_amount):void 0,R=typeof s.before_discount_amount_total<"u"?b(s.before_discount_amount_total):void 0,M=typeof s.before_discount_amount_subtotal<"u"?b(s.before_discount_amount_subtotal):void 0,L=b(((ge=(pe=s.taxes)==null?void 0:pe[0])==null?void 0:ge.amount)||s.amount_tax||0);if(x)x.amount=b(x.amount).add(L).getAmount(),x.tax&&h&&(!x.tax._id&&h._id&&(x.tax._id=h._id),!x.tax.type&&h.type&&(x.tax.type=h.type));else if(h){const{_id:ae,type:me,rate:Ee}=h;m.push({tax:{...ae&&{_id:ae},...me&&{type:me},rate:Ee},amount:L.getAmount()})}if(S){const ae=b(S.unit_amount_gross).add(T),me=S.unit_amount_net?b(S.unit_amount_net).add(U):void 0,Ee=b(S.amount_subtotal).add(I),St=b(S.amount_total).add(_),cn=b(S.amount_tax).add(L);S.unit_amount_gross=ae.getAmount(),S.unit_amount_net=me==null?void 0:me.getAmount(),S.amount_subtotal=Ee.getAmount(),S.amount_subtotal_decimal=Ee.toUnit().toString(),S.amount_total=St.getAmount(),S.amount_total_decimal=St.toUnit().toString(),S.amount_tax=cn.getAmount();const dn=typeof S.before_discount_amount_total<"u"?b(S.before_discount_amount_total):void 0,Sn=typeof S.before_discount_amount_subtotal<"u"?b(S.before_discount_amount_subtotal):void 0,An=typeof S.discount_amount<"u"?b(S.discount_amount):void 0;if(R||dn){const Ft=dn??b(S.amount_total).subtract(_),mn=R||_,Wt=Ft.add(mn);S.before_discount_amount_total=Wt.getAmount(),S.before_discount_amount_total_decimal=Wt.toUnit().toString()}if(M||Sn){const Ft=Sn??b(S.amount_subtotal).subtract(I),mn=M||I,Wt=Ft.add(mn);S.before_discount_amount_subtotal=Wt.getAmount(),S.before_discount_amount_subtotal_decimal=Wt.toUnit().toString()}if($){const Ft=(An==null?void 0:An.add($))??$;S.discount_amount=Ft.getAmount(),S.discount_amount_decimal=Ft.toUnit().toString()}}else{const ae=s.type??(u==null?void 0:u.type);p.push({type:ae==="recurring"?ae:"one_time",...ae==="recurring"&&{billing_period:(s==null?void 0:s.billing_period)??(u==null?void 0:u.billing_period)},unit_amount_gross:T.getAmount(),unit_amount_net:(U==null?void 0:U.getAmount())??void 0,amount_subtotal:I.getAmount(),amount_total:_.getAmount(),amount_subtotal_decimal:I.toUnit().toString(),amount_total_decimal:_.toUnit().toString(),amount_tax:L.getAmount(),...R&&{before_discount_amount_total:R.getAmount(),before_discount_amount_total_decimal:R.toUnit().toString()},...M&&{before_discount_amount_subtotal:M.getAmount(),before_discount_amount_subtotal_decimal:M.toUnit().toString()},...$&&{discount_amount:$.getAmount(),discount_amount_decimal:$.toUnit().toString()}})}const H=!x&&h?m==null?void 0:m[(m==null?void 0:m.length)-1]:x;if(C){const ae=b(C.amount_total).add(_),me=b(C.amount_subtotal).add(I),Ee=b(C.amount_tax).add(L);C.amount_total=ae.getAmount(),C.amount_subtotal=me.getAmount(),C.amount_tax=Ee.getAmount()}else{const ae=s.type||(u==null?void 0:u.type);y.push({type:ae==="recurring"?ae:"one_time",...ae==="recurring"&&{billing_period:(S==null?void 0:S.billing_period)??(u==null?void 0:u.billing_period)},amount_total:_.getAmount(),amount_subtotal:I.getAmount(),amount_tax:L.getAmount(),tax:H??{amount:0,rate:"nontaxable",rateValue:0,tax:{rate:0}}})}const te=(ve=s==null?void 0:s._coupons)==null?void 0:ve[0],Q=s.cashback_period??"0",_e=typeof s.cashback_amount<"u"?b(s.cashback_amount):void 0;if(_e&&te){const ae=A.find(me=>me.cashback_period===Q);if(ae){const me=b(ae.amount_total);ae.amount_total=me.add(_e).getAmount()}else A.push({cashback_period:Q,amount_total:_e.getAmount()})}return A.length>0&&A.filter(ae=>ae.amount_total>0),{...l,amount_subtotal:v.add(I).getAmount(),amount_total:j.add(_).getAmount(),amount_tax:w.add(L).getAmount(),total_details:{amount_tax:w.add(L).getAmount(),breakdown:{taxes:m,recurrences:p,recurrencesByTax:y,cashbacks:A}}}},bc=(l,u,s=[])=>{const m={amount_subtotal:0,amount_total:0,total_details:{amount_shipping:0,amount_tax:0,breakdown:{taxes:[],recurrences:[],recurrencesByTax:[],cashbacks:[]}}},c=!l,h=(u.item_components??[]).reduce((S,y)=>{var j;const C=Uc(y,(j=y._price)==null?void 0:j.price_display_in_journeys,u)?Yc(S,y._price,y):{amount_subtotal:(l==null?void 0:l.amount_subtotal)||0,amount_total:(l==null?void 0:l.amount_total)||0,amount_tax:(l==null?void 0:l.amount_tax)||0,total_details:(l==null?void 0:l.total_details)||m.total_details};return{...S,...C}},l||m),{pricingDetails:f,...x}=jp(u,h,s);return{...h,...f,...c&&{...x}}},bp={default:"text-gray-900",green:"text-green-600",red:"text-red-600",blue:"text-primary-600",amber:"text-amber-600"};function K({label:l,value:u,sublabel:s,highlight:m,color:c="default"}){return r.jsxs("div",{className:`rounded-lg p-4 ${m?"bg-primary-50 border border-primary-200":"bg-gray-50 border border-gray-100"}`,children:[r.jsx("p",{className:"result-label",children:l}),r.jsx("p",{className:`text-xl font-bold mt-1 ${bp[c]}`,children:u}),s&&r.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:s})]})}function V(l,u="EUR"){return l==null?"-":new Intl.NumberFormat("en-US",{style:"currency",currency:u.toUpperCase(),minimumFractionDigits:2,maximumFractionDigits:2}).format(l/100)}function Xc(l,u){return{_id:u||`tax-${l}`,_title:`Tax ${l}%`,_org:"demo",_schema:"tax",_tags:[],_created_at:new Date().toISOString(),_updated_at:new Date().toISOString(),type:"VAT",rate:l,active:!0,region:"DE",region_label:"Germany"}}function be({unitAmountDecimal:l,quantity:u,currency:s="EUR",pricingModel:m="per_unit",type:c="one_time",billingPeriod:h,isTaxInclusive:f=!0,taxRate:x=19,tiers:p,coupons:S,description:y="Demo Price",dynamicTariff:C,getAg:j}){const v=Xc(x),w=Math.round(parseFloat(l)*100),A={_id:"demo-price-"+Math.random().toString(36).slice(2,8),unit_amount:w,unit_amount_currency:s,unit_amount_decimal:l,type:c,billing_period:h,tax:[v],is_tax_inclusive:f,pricing_model:m,description:y,_title:y,...p&&{tiers:p},...C&&{dynamic_tariff:C},...j&&{get_ag:j}},T={quantity:u,product_id:"demo-product",price_id:A._id,taxes:[{tax:v}],_price:A,_product:{name:"Demo Product",type:"product"},pricing_model:m,is_tax_inclusive:f};return S&&S.length>0&&(T._coupons=S),T}function kc({type:l,category:u,percentageValue:s,fixedValue:m,fixedValueDecimal:c,currency:h="EUR",name:f="Demo Coupon",cashbackPeriod:x}){return{_id:"coupon-"+Math.random().toString(36).slice(2,8),_title:f,_org:"demo",_schema:"coupon",_tags:[],_created_at:new Date().toISOString(),_updated_at:new Date().toISOString(),name:f,type:l,category:u,...s!==void 0&&{percentage_value:s},...m!==void 0&&{fixed_value:m},...c!==void 0&&{fixed_value_decimal:c},fixed_value_currency:h,active:!0,...x!==void 0&&{cashback_period:x}}}function kp(){var j;const[l,u]=W.useState("49.99"),[s,m]=W.useState(5),[c,h]=W.useState(19),[f,x]=W.useState(!0),[p,S]=W.useState("EUR"),y=W.useMemo(()=>{const v=be({unitAmountDecimal:l,quantity:s,currency:p,taxRate:c,isTaxInclusive:f,description:"Product"});return Ve([v])},[l,s,c,f,p]),C=(j=y.items)==null?void 0:j[0];return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Per Unit Pricing"}),r.jsx("p",{className:"section-desc",children:"The simplest model: unit price multiplied by quantity. Supports tax-inclusive and tax-exclusive modes."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"card space-y-4",children:[r.jsx("h3",{className:"font-semibold text-gray-900",children:"Configure"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Unit Price"}),r.jsx("input",{type:"number",step:"0.01",value:l,onChange:v=>u(v.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Quantity: ",r.jsx("span",{className:"text-primary-600 font-bold",children:s})]}),r.jsx("input",{type:"range",min:"1",max:"100",value:s,onChange:v=>m(Number(v.target.value)),className:"w-full mt-1 accent-primary-600"}),r.jsxs("div",{className:"flex justify-between text-xs text-gray-400",children:[r.jsx("span",{children:"1"}),r.jsx("span",{children:"100"})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Tax Rate (%)"}),r.jsxs("select",{value:c,onChange:v=>h(Number(v.target.value)),className:"select-field mt-1",children:[r.jsx("option",{value:0,children:"0%"}),r.jsx("option",{value:6,children:"6%"}),r.jsx("option",{value:7,children:"7%"}),r.jsx("option",{value:10,children:"10%"}),r.jsx("option",{value:19,children:"19%"}),r.jsx("option",{value:21,children:"21%"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Currency"}),r.jsxs("select",{value:p,onChange:v=>S(v.target.value),className:"select-field mt-1",children:[r.jsx("option",{value:"EUR",children:"EUR"}),r.jsx("option",{value:"USD",children:"USD"}),r.jsx("option",{value:"GBP",children:"GBP"}),r.jsx("option",{value:"CHF",children:"CHF"})]})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Tax Mode:"}),r.jsx("button",{onClick:()=>x(!0),className:`px-3 py-1.5 text-xs rounded-lg font-medium transition-colors ${f?"bg-primary-100 text-primary-700":"bg-gray-100 text-gray-500"}`,children:"Inclusive"}),r.jsx("button",{onClick:()=>x(!1),className:`px-3 py-1.5 text-xs rounded-lg font-medium transition-colors ${f?"bg-gray-100 text-gray-500":"bg-primary-100 text-primary-700"}`,children:"Exclusive"})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-4",children:"Computed Result"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Unit Amount (Net)",value:V(C==null?void 0:C.unit_amount,p)}),r.jsx(K,{label:"Unit Amount (Gross)",value:V(C==null?void 0:C.unit_amount_gross,p)}),r.jsx(K,{label:"Subtotal (Net)",value:V(C==null?void 0:C.amount_subtotal,p)}),r.jsx(K,{label:"Total (Gross)",value:V(C==null?void 0:C.amount_total,p),highlight:!0})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-4",children:"Aggregated Totals"}),r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsx(K,{label:"Amount Subtotal",value:V(y.amount_subtotal,p)}),r.jsx(K,{label:"Amount Tax",value:V(y.amount_tax,p),color:"amber"}),r.jsx(K,{label:"Amount Total",value:V(y.amount_total,p),highlight:!0,color:"green"})]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +const priceItem = { + quantity: ${s}, + pricing_model: 'per_unit', + is_tax_inclusive: ${f}, + _price: { + unit_amount_decimal: '${l}', + unit_amount_currency: '${p}', + pricing_model: 'per_unit', + is_tax_inclusive: ${f}, + tax: [{ rate: ${c}, type: 'VAT' }], + }, + taxes: [{ tax: { rate: ${c} } }], +}; + +const result = computeAggregatedAndPriceTotals([priceItem]); +// result.amount_total = ${y.amount_total} (${V(y.amount_total,p)})`})})]})}function wp({bars:l,title:u,valueFormatter:s=m=>m.toFixed(2)}){const m=Math.max(...l.map(c=>c.value),1);return r.jsxs("div",{className:"w-full",children:[u&&r.jsx("p",{className:"text-sm font-medium text-gray-700 mb-3",children:u}),r.jsx("div",{className:"flex items-end gap-2 h-48",children:l.map((c,h)=>{const f=Math.max(c.value/m*100,4);return r.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-gray-600",children:s(c.value)}),r.jsx("div",{className:`w-full rounded-t-md transition-all duration-300 ${c.active?"bg-primary-500 shadow-md shadow-primary-200":"bg-gray-200"}`,style:{height:`${f}%`}}),r.jsx("span",{className:"text-xs text-gray-500 text-center leading-tight",children:c.label}),c.sublabel&&r.jsx("span",{className:"text-[10px] text-gray-400 text-center",children:c.sublabel})]},h)})})]})}const Sp=[{up_to:10,unit_amount:5e3,unit_amount_decimal:"50.00",flat_fee_amount:0,flat_fee_amount_decimal:"0"},{up_to:50,unit_amount:4e3,unit_amount_decimal:"40.00",flat_fee_amount:0,flat_fee_amount_decimal:"0"},{up_to:100,unit_amount:3e3,unit_amount_decimal:"30.00",flat_fee_amount:0,flat_fee_amount_decimal:"0"},{up_to:null,unit_amount:2e3,unit_amount_decimal:"20.00",flat_fee_amount:0,flat_fee_amount_decimal:"0"}];function Ap(){var v,w;const[l,u]=W.useState(25),[s,m]=W.useState(Sp),[c,h]=W.useState(19),[f,x]=W.useState(!0),p=W.useMemo(()=>{const A=be({unitAmountDecimal:"0",quantity:l,pricingModel:"tiered_volume",taxRate:c,isTaxInclusive:f,tiers:s,description:"Volume Product"});return Ve([A])},[l,s,c,f]),S=(v=p.items)==null?void 0:v[0],y=s.findIndex(A=>A.up_to===null||l<=A.up_to),C=(A,T,U)=>{m(I=>I.map((_,$)=>{if($!==A)return _;if(T==="up_to"){const M=U===""?null:Number(U);return{..._,up_to:M}}const R=Number(U);return{..._,unit_amount_decimal:U,unit_amount:Math.round(R*100)}}))},j=s.map((A,T)=>({label:A.up_to?`≤ ${A.up_to}`:"∞",value:parseFloat(A.unit_amount_decimal),active:T===y,sublabel:`${A.unit_amount_decimal}/unit`}));return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Tiered Volume Pricing"}),r.jsxs("p",{className:"section-desc",children:["A single tier is selected based on total quantity. The selected tier's unit price applies to ",r.jsx("strong",{children:"all"})," units."]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Tier Configuration"}),r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-left text-xs text-gray-500 uppercase",children:[r.jsx("th",{className:"pb-2",children:"Tier"}),r.jsx("th",{className:"pb-2",children:"Up To"}),r.jsx("th",{className:"pb-2",children:"Unit Price"}),r.jsx("th",{className:"pb-2",children:"Active"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-100",children:s.map((A,T)=>r.jsxs("tr",{className:T===y?"bg-primary-50":"",children:[r.jsxs("td",{className:"py-2 font-medium text-gray-600",children:["Tier ",T+1]}),r.jsx("td",{className:"py-2",children:r.jsx("input",{type:"number",value:A.up_to??"",placeholder:"∞",onChange:U=>C(T,"up_to",U.target.value),className:"input-field w-20"})}),r.jsx("td",{className:"py-2",children:r.jsx("input",{type:"number",step:"0.01",value:A.unit_amount_decimal,onChange:U=>C(T,"unit_amount_decimal",U.target.value),className:"input-field w-24"})}),r.jsx("td",{className:"py-2",children:T===y&&r.jsx("span",{className:"badge-blue",children:"Active"})})]},T))})]})]}),r.jsxs("div",{className:"card",children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Quantity: ",r.jsx("span",{className:"text-primary-600 font-bold text-lg",children:l})]}),r.jsx("input",{type:"range",min:"1",max:"200",value:l,onChange:A=>u(Number(A.target.value)),className:"w-full mt-2 accent-primary-600"}),r.jsxs("div",{className:"flex justify-between text-xs text-gray-400",children:[r.jsx("span",{children:"1"}),r.jsx("span",{children:"200"})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[r.jsxs("span",{className:"text-xs text-gray-500",children:["Tax: ",c,"%"]}),r.jsx("span",{className:"text-xs text-gray-500",children:"|"}),r.jsx("button",{onClick:()=>x(!f),className:"text-xs text-primary-600 font-medium",children:f?"Tax Inclusive":"Tax Exclusive"})]})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"card",children:r.jsx(wp,{bars:j,title:"Unit Price by Tier (active tier highlighted)",valueFormatter:A=>`€${A.toFixed(0)}`})}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed Result"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Unit Price (selected tier)",value:V(S==null?void 0:S.unit_amount)}),r.jsx(K,{label:"Quantity",value:l}),r.jsx(K,{label:"Subtotal (Net)",value:V(p.amount_subtotal)}),r.jsx(K,{label:"Total (Gross)",value:V(p.amount_total),highlight:!0,color:"green"})]}),r.jsxs("div",{className:"mt-3 p-3 bg-gray-50 rounded-lg text-xs text-gray-500",children:[r.jsx("strong",{children:"How it works:"})," With quantity ",l,", tier ",y+1," is selected (",(w=s[y])==null?void 0:w.unit_amount_decimal,"/unit). All ",l," units use this price."]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +const priceItem = { + quantity: ${l}, + pricing_model: 'tiered_volume', + is_tax_inclusive: ${f}, + _price: { + unit_amount_decimal: '0', + unit_amount_currency: 'EUR', + pricing_model: 'tiered_volume', + is_tax_inclusive: ${f}, + tax: [{ rate: ${c}, type: 'VAT' }], + tiers: [ +${s.map(A=>` { up_to: ${A.up_to===null?"null":A.up_to}, unit_amount_decimal: '${A.unit_amount_decimal}', flat_fee_amount_decimal: '0' },`).join(` +`)} + ], + }, + taxes: [{ tax: { rate: ${c} } }], +}; + +const result = computeAggregatedAndPriceTotals([priceItem]); +// result.amount_total = ${p.amount_total} (${V(p.amount_total)})`})})]})}const Pp=[{up_to:10,unit_amount:5e3,unit_amount_decimal:"50.00",flat_fee_amount:0,flat_fee_amount_decimal:"0"},{up_to:50,unit_amount:3e3,unit_amount_decimal:"30.00",flat_fee_amount:0,flat_fee_amount_decimal:"0"},{up_to:100,unit_amount:2e3,unit_amount_decimal:"20.00",flat_fee_amount:0,flat_fee_amount_decimal:"0"},{up_to:null,unit_amount:1e3,unit_amount_decimal:"10.00",flat_fee_amount:0,flat_fee_amount_decimal:"0"}];function Cp(l,u){const s=[];let m=l,c=0;for(let h=0;h0;h++){const f=u[h].up_to??1/0,x=f-c,p=Math.min(m,x),S=parseFloat(u[h].unit_amount_decimal);s.push({tier:h+1,from:c+1,to:c+p,qty:p,rate:u[h].unit_amount_decimal,subtotal:p*S*100}),m-=p,c=f===1/0?c+p:f}return s}function Tp(){const[l,u]=W.useState(75),[s,m]=W.useState(Pp),[c,h]=W.useState(!0),[f,x]=W.useState(19),p=W.useMemo(()=>{const v=be({unitAmountDecimal:"0",quantity:l,pricingModel:"tiered_graduated",taxRate:f,isTaxInclusive:c,tiers:s,description:"Graduated Product"});return Ve([v])},[l,s,f,c]),S=Cp(l,s),y=(v,w,A)=>{m(T=>T.map((U,I)=>I!==v?U:w==="up_to"?{...U,up_to:A===""?null:Number(A)}:{...U,unit_amount_decimal:A,unit_amount:Math.round(Number(A)*100)}))},C=S.reduce((v,w)=>v+w.qty,0),j=["bg-blue-400","bg-indigo-400","bg-purple-400","bg-pink-400"];return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Tiered Graduated Pricing"}),r.jsx("p",{className:"section-desc",children:'Units are spread across tiers. Each tier charges its own rate for the units within its range. This is the "graduated" model used by many SaaS platforms.'}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Tier Configuration"}),r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-left text-xs text-gray-500 uppercase",children:[r.jsx("th",{className:"pb-2",children:"Tier"}),r.jsx("th",{className:"pb-2",children:"Up To"}),r.jsx("th",{className:"pb-2",children:"Unit Price"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-100",children:s.map((v,w)=>r.jsxs("tr",{children:[r.jsxs("td",{className:"py-2",children:[r.jsx("span",{className:`inline-block w-3 h-3 rounded-sm ${j[w]} mr-2`}),"Tier ",w+1]}),r.jsx("td",{className:"py-2",children:r.jsx("input",{type:"number",value:v.up_to??"",placeholder:"∞",onChange:A=>y(w,"up_to",A.target.value),className:"input-field w-20"})}),r.jsx("td",{className:"py-2",children:r.jsx("input",{type:"number",step:"0.01",value:v.unit_amount_decimal,onChange:A=>y(w,"unit_amount_decimal",A.target.value),className:"input-field w-24"})})]},w))})]})]}),r.jsxs("div",{className:"card",children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Quantity: ",r.jsx("span",{className:"text-primary-600 font-bold text-lg",children:l})]}),r.jsx("input",{type:"range",min:"1",max:"200",value:l,onChange:v=>u(Number(v.target.value)),className:"w-full mt-2 accent-primary-600"}),r.jsx("div",{className:"flex items-center gap-3 mt-2",children:r.jsxs("button",{onClick:()=>h(!c),className:"text-xs text-primary-600 font-medium",children:[c?"Tax Inclusive":"Tax Exclusive"," (",f,"%)"]})})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Tier Breakdown Visualization"}),r.jsx("div",{className:"h-12 flex rounded-lg overflow-hidden",children:S.map((v,w)=>r.jsx("div",{className:`${j[w]} flex items-center justify-center text-white text-xs font-medium transition-all duration-300`,style:{width:`${v.qty/Math.max(C,1)*100}%`},title:`Tier ${v.tier}: ${v.qty} units @ €${v.rate}`,children:v.qty>5&&`${v.qty}u`},w))}),r.jsx("div",{className:"mt-3 space-y-1.5",children:S.map((v,w)=>r.jsxs("div",{className:"flex items-center text-sm",children:[r.jsx("span",{className:`inline-block w-3 h-3 rounded-sm ${j[w]} mr-2`}),r.jsxs("span",{className:"text-gray-600 flex-1",children:["Tier ",v.tier,": units ",v.from,"-",v.to," (",v.qty," units)"]}),r.jsxs("span",{className:"text-gray-500",children:["@ €",v.rate,"/unit"]}),r.jsx("span",{className:"ml-3 font-medium text-gray-900",children:V(v.subtotal)})]},w))})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed Result"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Subtotal (Net)",value:V(p.amount_subtotal)}),r.jsx(K,{label:"Tax",value:V(p.amount_tax),color:"amber"}),r.jsx(K,{label:"Total (Gross)",value:V(p.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Avg Price/Unit",value:l>0?V(Math.round((p.amount_total??0)/l)):"-",color:"blue"})]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +const priceItem = { + quantity: ${l}, + pricing_model: 'tiered_graduated', + is_tax_inclusive: ${c}, + _price: { + unit_amount_decimal: '0', + unit_amount_currency: 'EUR', + pricing_model: 'tiered_graduated', + is_tax_inclusive: ${c}, + tax: [{ rate: ${f}, type: 'VAT' }], + tiers: [ +${s.map(v=>` { up_to: ${v.up_to===null?"null":v.up_to}, unit_amount_decimal: '${v.unit_amount_decimal}', flat_fee_amount_decimal: '0' },`).join(` +`)} + ], + }, + taxes: [{ tax: { rate: ${f} } }], +}; + +const result = computeAggregatedAndPriceTotals([priceItem]); +// result.amount_total = ${p.amount_total} (${V(p.amount_total)})`})})]})}const Ep=[{up_to:10,unit_amount:0,unit_amount_decimal:"0",flat_fee_amount:9900,flat_fee_amount_decimal:"99.00"},{up_to:50,unit_amount:0,unit_amount_decimal:"0",flat_fee_amount:19900,flat_fee_amount_decimal:"199.00"},{up_to:100,unit_amount:0,unit_amount_decimal:"0",flat_fee_amount:34900,flat_fee_amount_decimal:"349.00"},{up_to:null,unit_amount:0,unit_amount_decimal:"0",flat_fee_amount:49900,flat_fee_amount_decimal:"499.00"}];function Fp(){const[l,u]=W.useState(30),[s,m]=W.useState(Ep),[c,h]=W.useState(19),[f,x]=W.useState(!0),p=W.useMemo(()=>{const C=be({unitAmountDecimal:"0",quantity:l,pricingModel:"tiered_flatfee",taxRate:c,isTaxInclusive:f,tiers:s,description:"Flat Fee Product"});return Ve([C])},[l,s,c,f]),S=s.findIndex(C=>C.up_to===null||l<=C.up_to),y=(C,j,v)=>{m(w=>w.map((A,T)=>T!==C?A:j==="up_to"?{...A,up_to:v===""?null:Number(v)}:{...A,flat_fee_amount_decimal:v,flat_fee_amount:Math.round(Number(v)*100)}))};return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Tiered Flat Fee"}),r.jsxs("p",{className:"section-desc",children:["A single fixed fee is charged based on the quantity range. Unlike volume pricing, the fee does ",r.jsx("strong",{children:"not"})," multiply by quantity."]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Tier Configuration"}),r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-left text-xs text-gray-500 uppercase",children:[r.jsx("th",{className:"pb-2",children:"Tier"}),r.jsx("th",{className:"pb-2",children:"Up To"}),r.jsx("th",{className:"pb-2",children:"Flat Fee"}),r.jsx("th",{className:"pb-2",children:"Status"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-100",children:s.map((C,j)=>r.jsxs("tr",{className:j===S?"bg-green-50":"",children:[r.jsxs("td",{className:"py-2 font-medium text-gray-600",children:["Tier ",j+1]}),r.jsx("td",{className:"py-2",children:r.jsx("input",{type:"number",value:C.up_to??"",placeholder:"∞",onChange:v=>y(j,"up_to",v.target.value),className:"input-field w-20"})}),r.jsx("td",{className:"py-2",children:r.jsx("input",{type:"number",step:"0.01",value:C.flat_fee_amount_decimal,onChange:v=>y(j,"flat_fee_amount_decimal",v.target.value),className:"input-field w-28"})}),r.jsx("td",{className:"py-2",children:j===S&&r.jsx("span",{className:"badge-green",children:"Selected"})})]},j))})]})]}),r.jsxs("div",{className:"card",children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Quantity: ",r.jsx("span",{className:"text-primary-600 font-bold text-lg",children:l})]}),r.jsx("input",{type:"range",min:"1",max:"200",value:l,onChange:C=>u(Number(C.target.value)),className:"w-full mt-2 accent-primary-600"}),r.jsx("div",{className:"flex items-center gap-3 mt-2",children:r.jsxs("button",{onClick:()=>x(!f),className:"text-xs text-primary-600 font-medium",children:[f?"Tax Inclusive":"Tax Exclusive"," (",c,"%)"]})})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Fee by Range"}),r.jsx("div",{className:"space-y-2",children:s.map((C,j)=>{const v=j===0?0:s[j-1].up_to??0,w=j===S;return r.jsxs("div",{className:`flex items-center rounded-lg p-3 transition-colors ${w?"bg-green-50 border border-green-200":"bg-gray-50"}`,children:[r.jsx("div",{className:"flex-1",children:r.jsxs("span",{className:"text-sm font-medium text-gray-700",children:[v+1," - ",C.up_to??"∞"," units"]})}),r.jsxs("span",{className:`text-lg font-bold ${w?"text-green-600":"text-gray-400"}`,children:["€",C.flat_fee_amount_decimal]}),w&&r.jsx("span",{className:"ml-2 text-xs text-green-600 font-medium",children:"← Your plan"})]},j)})})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed Result"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Subtotal (Net)",value:V(p.amount_subtotal)}),r.jsx(K,{label:"Tax",value:V(p.amount_tax),color:"amber"}),r.jsx(K,{label:"Total (Gross)",value:V(p.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Effective $/unit",value:l>0?V(Math.round((p.amount_total??0)/l)):"-",color:"blue"})]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +const priceItem = { + quantity: ${l}, + pricing_model: 'tiered_flatfee', + is_tax_inclusive: ${f}, + _price: { + unit_amount_decimal: '0', + unit_amount_currency: 'EUR', + pricing_model: 'tiered_flatfee', + is_tax_inclusive: ${f}, + tax: [{ rate: ${c}, type: 'VAT' }], + tiers: [ +${s.map(C=>` { up_to: ${C.up_to===null?"null":C.up_to}, unit_amount_decimal: '0', flat_fee_amount_decimal: '${C.flat_fee_amount_decimal}' },`).join(` +`)} + ], + }, + taxes: [{ tax: { rate: ${c} } }], +}; + +const result = computeAggregatedAndPriceTotals([priceItem]); +// result.amount_total = ${p.amount_total} (${V(p.amount_total)})`})})]})}function Rp(){var v,w,A,T,U,I;const[l,u]=W.useState("100.00"),[s,m]=W.useState(3),[c,h]=W.useState(19),f=W.useMemo(()=>{const _=be({unitAmountDecimal:l,quantity:s,taxRate:c,isTaxInclusive:!0});return Ve([_])},[l,s,c]),x=W.useMemo(()=>{const _=be({unitAmountDecimal:l,quantity:s,taxRate:c,isTaxInclusive:!1});return Ve([_])},[l,s,c]),[p,S]=W.useState(!1),y=W.useMemo(()=>{const _=be({unitAmountDecimal:"50.00",quantity:2,taxRate:19,isTaxInclusive:!0,description:"Standard Rate Item"}),$=be({unitAmountDecimal:"30.00",quantity:3,taxRate:7,isTaxInclusive:!0,description:"Reduced Rate Item"});return Ve([_,$])},[]),C=(v=f.items)==null?void 0:v[0],j=(w=x.items)==null?void 0:w[0];return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Tax Handling"}),r.jsx("p",{className:"section-desc",children:"Compare tax-inclusive vs tax-exclusive pricing side by side. The library handles tax calculations precisely using Dinero.js for decimal arithmetic."}),r.jsx("div",{className:"card mb-6",children:r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Unit Price"}),r.jsx("input",{type:"number",step:"0.01",value:l,onChange:_=>u(_.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Quantity: ",r.jsx("span",{className:"text-primary-600 font-bold",children:s})]}),r.jsx("input",{type:"range",min:"1",max:"20",value:s,onChange:_=>m(Number(_.target.value)),className:"w-full mt-3 accent-primary-600"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Tax Rate (%)"}),r.jsxs("select",{value:c,onChange:_=>h(Number(_.target.value)),className:"select-field mt-1",children:[r.jsx("option",{value:0,children:"0%"}),r.jsx("option",{value:6,children:"6%"}),r.jsx("option",{value:7,children:"7%"}),r.jsx("option",{value:10,children:"10%"}),r.jsx("option",{value:19,children:"19%"}),r.jsx("option",{value:21,children:"21%"})]})]})]})}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[r.jsxs("div",{className:"card border-blue-200",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[r.jsx("span",{className:"badge-blue",children:"Tax Inclusive"}),r.jsx("span",{className:"text-xs text-gray-500",children:"Price includes tax"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(K,{label:"Unit Price (what customer sees)",value:`€${l}`}),r.jsx(K,{label:"Net per unit (excluding tax)",value:V(C==null?void 0:C.unit_amount)}),r.jsx(K,{label:"Line Subtotal (Net)",value:V(f.amount_subtotal)}),r.jsx(K,{label:"Tax Amount",value:V(f.amount_tax),color:"amber"}),r.jsx(K,{label:"Line Total (Gross)",value:V(f.amount_total),highlight:!0,color:"green"})]}),r.jsxs("div",{className:"mt-3 p-3 bg-blue-50 rounded text-xs text-blue-700",children:["The €",l," price already contains ",c,"% tax. Net = €",l," / 1.",String(c).padStart(2,"0")," per unit."]})]}),r.jsxs("div",{className:"card border-amber-200",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[r.jsx("span",{className:"badge-amber",children:"Tax Exclusive"}),r.jsx("span",{className:"text-xs text-gray-500",children:"Tax added on top"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(K,{label:"Unit Price (net)",value:`€${l}`}),r.jsx(K,{label:"Gross per unit (including tax)",value:V(j==null?void 0:j.unit_amount_gross)}),r.jsx(K,{label:"Line Subtotal (Net)",value:V(x.amount_subtotal)}),r.jsx(K,{label:"Tax Amount",value:V(x.amount_tax),color:"amber"}),r.jsx(K,{label:"Line Total (Gross)",value:V(x.amount_total),highlight:!0,color:"green"})]}),r.jsxs("div",{className:"mt-3 p-3 bg-amber-50 rounded text-xs text-amber-700",children:["€",l," is the net price. ",c,"% tax is added on top. Gross = €",l," * 1.",String(c).padStart(2,"0")," per unit."]})]})]}),r.jsxs("div",{className:"card",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"font-semibold text-gray-900",children:"Multi-Tax Breakdown"}),r.jsxs("button",{onClick:()=>S(!p),className:"btn-secondary text-xs",children:[p?"Hide":"Show"," Example"]})]}),p&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Two items with different tax rates (19% standard, 7% reduced). The library tracks tax breakdown by rate."}),r.jsxs("div",{className:"grid grid-cols-4 gap-3 mb-4",children:[r.jsx(K,{label:"Subtotal",value:V(y.amount_subtotal)}),r.jsx(K,{label:"Tax (Total)",value:V(y.amount_tax),color:"amber"}),r.jsx(K,{label:"Total",value:V(y.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Items",value:((A=y.items)==null?void 0:A.length)??0})]}),r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium text-gray-700 mb-2",children:"Tax Breakdown:"}),(I=(U=(T=y.total_details)==null?void 0:T.breakdown)==null?void 0:U.taxes)==null?void 0:I.map((_,$)=>{var L,H;const R=((L=_.tax)==null?void 0:L.rate)??_.rateValue??0,M=((H=_.tax)==null?void 0:H.type)||"VAT";return r.jsxs("div",{className:"flex items-center gap-3 py-1.5 border-b border-gray-100",children:[r.jsxs("span",{className:"badge-amber",children:[R,"%"]}),r.jsxs("span",{className:"text-gray-600 flex-1",children:[M," ",R,"%"]}),r.jsx("span",{className:"font-medium",children:V(_.amount)})]},$)})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +// Tax-inclusive: price already contains tax +const inclusiveItem = { + quantity: ${s}, + pricing_model: 'per_unit', + is_tax_inclusive: true, + _price: { + unit_amount_decimal: '${l}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: true, + tax: [{ rate: ${c}, type: 'VAT' }], + }, + taxes: [{ tax: { rate: ${c} } }], +}; + +// Tax-exclusive: tax is added on top +const exclusiveItem = { + ...inclusiveItem, + is_tax_inclusive: false, + _price: { ...inclusiveItem._price, is_tax_inclusive: false }, +}; + +const inclusiveResult = computeAggregatedAndPriceTotals([inclusiveItem]); +const exclusiveResult = computeAggregatedAndPriceTotals([exclusiveItem]); +// Inclusive total: ${V(f.amount_total)} +// Exclusive total: ${V(x.amount_total)}`})})]})}function Dp(){var A;const[l,u]=W.useState("100.00"),[s,m]=W.useState(5),[c,h]=W.useState(19),[f,x]=W.useState(!0),[p,S]=W.useState({type:"percentage",category:"discount",value:"15"}),y=W.useMemo(()=>{const T=be({unitAmountDecimal:l,quantity:s,taxRate:c,isTaxInclusive:f});return Ve([T])},[l,s,c,f]),C=W.useMemo(()=>{const T=p.type==="percentage"?kc({type:"percentage",category:p.category,percentageValue:p.value,name:`${p.value}% ${p.category}`,...p.category==="cashback"&&{cashbackPeriod:12}}):kc({type:"fixed",category:p.category,fixedValueDecimal:p.value,fixedValue:Math.round(parseFloat(p.value)*100),name:`€${p.value} ${p.category}`,...p.category==="cashback"&&{cashbackPeriod:12}}),U=be({unitAmountDecimal:l,quantity:s,taxRate:c,isTaxInclusive:f,coupons:[T]});return Ve([U])},[l,s,c,f,p]),j=(A=C.items)==null?void 0:A[0],v=(y.amount_total??0)-(C.amount_total??0),w=[{label:"10% Off",config:{type:"percentage",category:"discount",value:"10"}},{label:"25% Off",config:{type:"percentage",category:"discount",value:"25"}},{label:"€50 Off",config:{type:"fixed",category:"discount",value:"50.00"}},{label:"€20 Cashback",config:{type:"fixed",category:"cashback",value:"20.00"}},{label:"10% Cashback",config:{type:"percentage",category:"cashback",value:"10"}}];return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Discounts & Coupons"}),r.jsx("p",{className:"section-desc",children:"Apply fixed-value, percentage discounts, and cashback coupons. Coupons are prioritized: cashback > discounts, percentage > fixed, highest value first."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Base Price"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Unit Price"}),r.jsx("input",{type:"number",step:"0.01",value:l,onChange:T=>u(T.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Quantity"}),r.jsx("input",{type:"number",min:"1",value:s,onChange:T=>m(Number(T.target.value)),className:"input-field mt-1"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[r.jsx("button",{onClick:()=>x(!f),className:"text-xs text-primary-600 font-medium",children:f?"Tax Inclusive":"Tax Exclusive"}),r.jsxs("span",{className:"text-xs text-gray-400",children:["(",c,"%)"]})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Coupon Configuration"}),r.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:w.map(T=>r.jsx("button",{onClick:()=>S(T.config),className:`px-3 py-1.5 text-xs rounded-lg font-medium transition-colors ${p.value===T.config.value&&p.type===T.config.type&&p.category===T.config.category?"bg-primary-100 text-primary-700":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:T.label},T.label))}),r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Type"}),r.jsxs("select",{value:p.type,onChange:T=>S(U=>({...U,type:T.target.value})),className:"select-field mt-1",children:[r.jsx("option",{value:"percentage",children:"Percentage"}),r.jsx("option",{value:"fixed",children:"Fixed"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Category"}),r.jsxs("select",{value:p.category,onChange:T=>S(U=>({...U,category:T.target.value})),className:"select-field mt-1",children:[r.jsx("option",{value:"discount",children:"Discount"}),r.jsx("option",{value:"cashback",children:"Cashback"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:p.type==="percentage"?"Percentage":"Amount (€)"}),r.jsx("input",{type:"number",step:p.type==="percentage"?"1":"0.01",value:p.value,onChange:T=>S(U=>({...U,value:T.target.value})),className:"input-field mt-1"})]})]})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-4",children:"Before vs After"}),r.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[r.jsxs("div",{className:"flex-1 text-center p-4 bg-gray-50 rounded-lg",children:[r.jsx("p",{className:"text-xs text-gray-500 uppercase font-medium",children:"Before"}),r.jsx("p",{className:"text-xl font-bold text-gray-400 line-through mt-1",children:V(y.amount_total)})]}),r.jsx("svg",{className:"w-6 h-6 text-gray-300 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r.jsxs("div",{className:"flex-1 text-center p-4 bg-green-50 rounded-lg border border-green-200",children:[r.jsx("p",{className:"text-xs text-green-600 uppercase font-medium",children:"After"}),r.jsx("p",{className:"text-xl font-bold text-green-600 mt-1",children:V(C.amount_total)})]})]}),v>0&&r.jsx("div",{className:"text-center p-3 bg-red-50 rounded-lg",children:r.jsxs("span",{className:"text-sm font-semibold text-red-600",children:["You save ",V(v),j!=null&&j.discount_percentage?` (${j.discount_percentage}%)`:""]})})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Detailed Breakdown"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Before Discount (Total)",value:V(j==null?void 0:j.before_discount_amount_total)}),r.jsx(K,{label:"Discount Amount",value:V(j==null?void 0:j.discount_amount),color:"red"}),r.jsx(K,{label:"Amount Subtotal",value:V(C.amount_subtotal)}),r.jsx(K,{label:"Amount Tax",value:V(C.amount_tax),color:"amber"}),r.jsx(K,{label:"Final Total",value:V(C.amount_total),highlight:!0,color:"green"}),p.category==="cashback"&&r.jsx(K,{label:"Cashback Amount",value:V(j==null?void 0:j.cashback_amount),color:"blue"})]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +const priceItem = { + quantity: ${s}, + pricing_model: 'per_unit', + is_tax_inclusive: ${f}, + _price: { + unit_amount_decimal: '${l}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: ${f}, + tax: [{ rate: ${c}, type: 'VAT' }], + }, + taxes: [{ tax: { rate: ${c} } }], + // Attach coupons to the price item + _coupons: [ + { + type: '${p.type}', + category: '${p.category}',${p.type==="percentage"?` + percentage_value: '${p.value}',`:` + fixed_value: ${Math.round(parseFloat(p.value)*100)}, + fixed_value_decimal: '${p.value}', + fixed_value_currency: 'EUR',`} + }, + ], +}; + +const result = computeAggregatedAndPriceTotals([priceItem]); +// result.amount_total = ${V(C.amount_total)} +// savings = ${V(v)}`})})]})}const Mp=[{name:"Installation Fee",unitAmountDecimal:"299.00",quantity:1,type:"one_time"},{name:"Monthly Service",unitAmountDecimal:"49.99",quantity:1,type:"recurring",billingPeriod:"monthly"},{name:"Hardware Lease",unitAmountDecimal:"19.99",quantity:2,type:"recurring",billingPeriod:"monthly"}];function Up(){var y,C,j,v,w,A,T,U,I;const[l,u]=W.useState(Mp),[s,m]=W.useState(1),[c,h]=W.useState(19),f=W.useMemo(()=>{const _=Xc(c),$={quantity:s,product_id:"composite-product",price_id:"composite-price",is_tax_inclusive:!0,pricing_model:"per_unit",taxes:[{tax:_}],_price:{_id:"composite-price",is_composite_price:!0,pricing_model:"per_unit",is_tax_inclusive:!0,unit_amount:0,unit_amount_decimal:"0",unit_amount_currency:"EUR",tax:[_],price_components:l.map((R,M)=>({_id:`comp-${M}`,unit_amount:Math.round(parseFloat(R.unitAmountDecimal)*100),unit_amount_decimal:R.unitAmountDecimal,unit_amount_currency:"EUR",pricing_model:"per_unit",is_tax_inclusive:!0,type:R.type,billing_period:R.billingPeriod,tax:[_],description:R.name,_title:R.name}))},_product:{name:"Bundle Package",type:"product"},price_components:l.map((R,M)=>({_id:`comp-${M}`,quantity:R.quantity,unit_amount:Math.round(parseFloat(R.unitAmountDecimal)*100),unit_amount_decimal:R.unitAmountDecimal,unit_amount_currency:"EUR",pricing_model:"per_unit",is_tax_inclusive:!0,type:R.type,billing_period:R.billingPeriod,tax:[_],description:R.name,_title:R.name,taxes:[{tax:_}],_price:{_id:`comp-price-${M}`,unit_amount:Math.round(parseFloat(R.unitAmountDecimal)*100),unit_amount_decimal:R.unitAmountDecimal,unit_amount_currency:"EUR",pricing_model:"per_unit",is_tax_inclusive:!0,type:R.type,billing_period:R.billingPeriod,tax:[_],description:R.name,_title:R.name}}))};return Ve([$])},[l,s,c]),x=(_,$,R)=>{u(M=>M.map((L,H)=>H===_?{...L,[$]:R}:L))},p=()=>{u(_=>[..._,{name:`Component ${_.length+1}`,unitAmountDecimal:"10.00",quantity:1,type:"one_time"}])},S=_=>{l.length>1&&u($=>$.filter((R,M)=>M!==_))};return(y=f.items)==null||y.filter(_=>{var $,R;return(($=_._price)==null?void 0:$.type)==="one_time"||!((R=_._price)!=null&&R.billing_period)}),(C=f.items)==null||C.filter(_=>{var $;return(($=_._price)==null?void 0:$.type)==="recurring"}),r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Composite Pricing"}),r.jsx("p",{className:"section-desc",children:"Bundle multiple price components into a single product. Each component can have its own pricing model, recurrence, and quantity. Component quantities multiply with the parent quantity."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"font-semibold text-gray-900",children:"Price Components"}),r.jsx("button",{onClick:p,className:"btn-primary text-xs",children:"+ Add"})]}),r.jsx("div",{className:"space-y-3",children:l.map((_,$)=>r.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg border border-gray-100",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("input",{value:_.name,onChange:R=>x($,"name",R.target.value),className:"text-sm font-medium bg-transparent border-none outline-none text-gray-700 flex-1"}),r.jsx("button",{onClick:()=>S($),className:"text-gray-400 hover:text-red-500 text-xs ml-2",children:"Remove"})]}),r.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-gray-500",children:"Price"}),r.jsx("input",{type:"number",step:"0.01",value:_.unitAmountDecimal,onChange:R=>x($,"unitAmountDecimal",R.target.value),className:"input-field text-xs"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-gray-500",children:"Qty"}),r.jsx("input",{type:"number",min:"1",value:_.quantity,onChange:R=>x($,"quantity",Number(R.target.value)),className:"input-field text-xs"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-gray-500",children:"Type"}),r.jsxs("select",{value:_.type,onChange:R=>x($,"type",R.target.value),className:"select-field text-xs",children:[r.jsx("option",{value:"one_time",children:"One-time"}),r.jsx("option",{value:"recurring",children:"Recurring"})]})]}),_.type==="recurring"&&r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-gray-500",children:"Period"}),r.jsxs("select",{value:_.billingPeriod||"monthly",onChange:R=>x($,"billingPeriod",R.target.value),className:"select-field text-xs",children:[r.jsx("option",{value:"weekly",children:"Weekly"}),r.jsx("option",{value:"monthly",children:"Monthly"}),r.jsx("option",{value:"every_quarter",children:"Quarterly"}),r.jsx("option",{value:"yearly",children:"Yearly"})]})]})]})]},$))})]}),r.jsx("div",{className:"card",children:r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Parent Quantity"}),r.jsx("input",{type:"number",min:"1",value:s,onChange:_=>m(Number(_.target.value)),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Tax Rate"}),r.jsxs("select",{value:c,onChange:_=>h(Number(_.target.value)),className:"select-field mt-1",children:[r.jsx("option",{value:0,children:"0%"}),r.jsx("option",{value:7,children:"7%"}),r.jsx("option",{value:19,children:"19%"})]})]})]})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Bundle Breakdown"}),r.jsx("div",{className:"space-y-2",children:l.map((_,$)=>{const R=parseFloat(_.unitAmountDecimal)*_.quantity*s;return r.jsxs("div",{className:"flex items-center gap-3 p-2 rounded bg-gray-50",children:[r.jsx("div",{className:`w-2 h-8 rounded-full ${_.type==="one_time"?"bg-blue-400":"bg-green-400"}`}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:_.name}),r.jsxs("p",{className:"text-xs text-gray-400",children:["€",_.unitAmountDecimal," x ",_.quantity,s>1?` x ${s}`:"",_.type==="recurring"&&` / ${_.billingPeriod}`]})]}),r.jsxs("div",{className:"text-right",children:[r.jsxs("p",{className:"text-sm font-semibold",children:["€",R.toFixed(2)]}),r.jsx("span",{className:`text-[10px] ${_.type==="one_time"?"text-blue-500":"text-green-500"}`,children:_.type==="one_time"?"One-time":_.billingPeriod})]})]},$)})})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed Totals"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Subtotal (Net)",value:V(f.amount_subtotal)}),r.jsx(K,{label:"Tax",value:V(f.amount_tax),color:"amber"}),r.jsx(K,{label:"Total",value:V(f.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Total Items",value:((j=f.items)==null?void 0:j.length)??0})]}),(((A=(w=(v=f.total_details)==null?void 0:v.breakdown)==null?void 0:w.recurrences)==null?void 0:A.length)??0)>0&&r.jsxs("div",{className:"mt-4",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700 mb-2",children:"By Recurrence:"}),(I=(U=(T=f.total_details)==null?void 0:T.breakdown)==null?void 0:U.recurrences)==null?void 0:I.map((_,$)=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100 text-sm",children:[r.jsx("span",{className:_.type==="one_time"?"badge-blue":"badge-green",children:_.type==="one_time"?"One-time":_.billing_period}),r.jsx("span",{className:"font-medium",children:V(_.amount_total)})]},$))]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +const compositeItem = { + quantity: ${s}, + pricing_model: 'per_unit', + is_tax_inclusive: true, + _price: { + is_composite_price: true, + pricing_model: 'per_unit', + is_tax_inclusive: true, + unit_amount: 0, + unit_amount_decimal: '0', + unit_amount_currency: 'EUR', + tax: [{ rate: ${c}, type: 'VAT' }], + price_components: [ +${l.map(_=>` { + unit_amount_decimal: '${_.unitAmountDecimal}', + pricing_model: 'per_unit', + is_tax_inclusive: true, + type: '${_.type}',${_.billingPeriod?` + billing_period: '${_.billingPeriod}',`:""} + description: '${_.name}', + },`).join(` +`)} + ], + }, + price_components: [ +${l.map(_=>` { quantity: ${_.quantity}, unit_amount_decimal: '${_.unitAmountDecimal}', type: '${_.type}'${_.billingPeriod?`, billing_period: '${_.billingPeriod}'`:""} },`).join(` +`)} + ], + taxes: [{ tax: { rate: ${c} } }], +}; + +const result = computeAggregatedAndPriceTotals([compositeItem]); +// result.amount_total = ${V(f.amount_total)}`})})]})}const ui=[{value:"weekly",label:"Weekly"},{value:"monthly",label:"Monthly"},{value:"every_quarter",label:"Quarterly"},{value:"every_6_months",label:"Semi-Annual"},{value:"yearly",label:"Yearly"}],$p={weekly:{weekly:1,monthly:4,every_quarter:13,every_6_months:26,yearly:52},monthly:{weekly:1/4,monthly:1,every_quarter:3,every_6_months:6,yearly:12},every_quarter:{weekly:1/13,monthly:1/3,every_quarter:1,every_6_months:2,yearly:4},every_6_months:{weekly:1/26,monthly:1/6,every_quarter:1/2,every_6_months:1,yearly:2},yearly:{weekly:1/52,monthly:1/12,every_quarter:1/4,every_6_months:1/2,yearly:1}};function Lp(){var A,T,U,I,_,$,R,M;const[l,u]=W.useState("29.99"),[s,m]=W.useState("monthly"),[c,h]=W.useState(1),[f,x]=W.useState(19),[p,S]=W.useState(!0),y=W.useMemo(()=>{const L=be({unitAmountDecimal:l,quantity:c,pricingModel:"per_unit",type:"recurring",billingPeriod:s,taxRate:f,isTaxInclusive:p,description:"Subscription"});return Ve([L])},[l,c,s,f,p]),C=W.useMemo(()=>{const L=parseFloat(l);return isNaN(L)?[]:ui.map(H=>{var te;try{const Q=Mc(l,s,H.value);return{period:H.label,periodValue:H.value,amount:typeof Q=="string"?parseFloat(Q):Q,isBase:H.value===s}}catch{const Q=((te=$p[s])==null?void 0:te[H.value])??1;return{period:H.label,periodValue:H.value,amount:L*Q,isBase:H.value===s}}})},[l,s]),[j,v]=W.useState(!1),w=W.useMemo(()=>{const L=[be({unitAmountDecimal:"499.00",quantity:1,type:"one_time",taxRate:19,isTaxInclusive:!0,description:"Setup Fee"}),be({unitAmountDecimal:"29.99",quantity:1,type:"recurring",billingPeriod:"monthly",taxRate:19,isTaxInclusive:!0,description:"Monthly Plan"}),be({unitAmountDecimal:"199.00",quantity:1,type:"recurring",billingPeriod:"yearly",taxRate:19,isTaxInclusive:!0,description:"Annual License"})];return Ve(L)},[]);return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Recurring Billing"}),r.jsx("p",{className:"section-desc",children:"Support for one-time and recurring prices with frequency normalization. Convert prices between billing periods automatically."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Configure"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Price"}),r.jsx("input",{type:"number",step:"0.01",value:l,onChange:L=>u(L.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Billing Period"}),r.jsx("select",{value:s,onChange:L=>m(L.target.value),className:"select-field mt-1",children:ui.map(L=>r.jsx("option",{value:L.value,children:L.label},L.value))})]})]}),r.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[r.jsxs("span",{className:"text-xs text-gray-500",children:["Qty: ",c]}),r.jsx("span",{className:"text-xs text-gray-400",children:"|"}),r.jsxs("button",{onClick:()=>S(!p),className:"text-xs text-primary-600 font-medium",children:[p?"Inclusive":"Exclusive"," (",f,"%)"]})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed Result"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Subtotal",value:V(y.amount_subtotal)}),r.jsx(K,{label:"Tax",value:V(y.amount_tax),color:"amber"}),r.jsx(K,{label:"Total",value:V(y.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Billing Period",value:((A=ui.find(L=>L.value===s))==null?void 0:A.label)??s})]})]})]}),r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Frequency Normalization"}),r.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"Same price expressed in different billing periods using normalizeValueToFrequencyUnit()"}),r.jsx("div",{className:"space-y-2",children:C.map(L=>r.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg ${L.isBase?"bg-primary-50 border border-primary-200":"bg-gray-50"}`,children:[r.jsxs("span",{className:"text-sm font-medium text-gray-700",children:[L.period,L.isBase&&r.jsx("span",{className:"text-primary-600 ml-1 text-xs",children:"(base)"})]}),r.jsxs("span",{className:`text-lg font-bold ${L.isBase?"text-primary-600":"text-gray-900"}`,children:["€",typeof L.amount=="number"?L.amount.toFixed(2):L.amount]})]},L.period))})]})})]}),r.jsxs("div",{className:"card mt-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"font-semibold text-gray-900",children:"Mixed Recurrence Example"}),r.jsx("button",{onClick:()=>v(!j),className:"btn-secondary text-xs",children:j?"Hide":"Show"})]}),j&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Three items: a one-time setup fee, a monthly subscription, and an annual license. The library groups totals by recurrence type."}),r.jsx("div",{className:"grid grid-cols-3 gap-4 mb-4",children:["Setup Fee (€499, one-time)","Monthly Plan (€29.99/mo)","Annual License (€199/yr)"].map((L,H)=>{var te,Q;return r.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg text-center",children:[r.jsx("p",{className:"text-xs text-gray-500",children:L}),r.jsx("p",{className:"font-bold mt-1",children:V((Q=(te=w.items)==null?void 0:te[H])==null?void 0:Q.amount_total)})]},H)})}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[r.jsx(K,{label:"Total Subtotal",value:V(w.amount_subtotal)}),r.jsx(K,{label:"Total Tax",value:V(w.amount_tax),color:"amber"}),r.jsx(K,{label:"Grand Total",value:V(w.amount_total),highlight:!0,color:"green"})]}),(((I=(U=(T=w.total_details)==null?void 0:T.breakdown)==null?void 0:U.recurrences)==null?void 0:I.length)??0)>0&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-gray-700 mb-2",children:"Grouped by Recurrence:"}),(R=($=(_=w.total_details)==null?void 0:_.breakdown)==null?void 0:$.recurrences)==null?void 0:R.map((L,H)=>r.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100",children:[r.jsx("span",{className:L.type==="one_time"?"badge-blue":"badge-green",children:L.type==="one_time"?"One-time":L.billing_period}),r.jsxs("div",{className:"text-right",children:[r.jsx("span",{className:"text-sm font-medium",children:V(L.amount_total)}),r.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:["(net: ",V(L.amount_subtotal),")"]})]})]},H))]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals, normalizeValueToFrequencyUnit } from '@epilot/pricing'; + +// Recurring price item +const priceItem = { + quantity: ${c}, + pricing_model: 'per_unit', + is_tax_inclusive: ${p}, + _price: { + unit_amount_decimal: '${l}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: ${p}, + type: 'recurring', + billing_period: '${s}', + tax: [{ rate: ${f}, type: 'VAT' }], + }, + taxes: [{ tax: { rate: ${f} } }], +}; + +const result = computeAggregatedAndPriceTotals([priceItem]); +// result.amount_total = ${V(y.amount_total)} + +// Normalize price across billing periods +const yearlyPrice = normalizeValueToFrequencyUnit( + '${l}', // amount + '${s}', // from + 'yearly', // to +); +// yearlyPrice = ${((M=C.find(L=>L.periodValue==="yearly"))==null?void 0:M.amount.toFixed(2))??"N/A"}`})})]})}const ci=[{code:"EUR",name:"Euro",locale:"de-DE"},{code:"USD",name:"US Dollar",locale:"en-US"},{code:"GBP",name:"British Pound",locale:"en-GB"},{code:"CHF",name:"Swiss Franc",locale:"de-CH"},{code:"SEK",name:"Swedish Krona",locale:"sv-SE"},{code:"PLN",name:"Polish Zloty",locale:"pl-PL"},{code:"CZK",name:"Czech Koruna",locale:"cs-CZ"},{code:"DKK",name:"Danish Krone",locale:"da-DK"}];function Op(){const[l,u]=W.useState("1234.56"),[s,m]=W.useState("EUR"),[c,h]=W.useState("de-DE"),f=W.useMemo(()=>{const j=parseFloat(l);return isNaN(j)?0:Math.round(j*100)},[l]),x=W.useMemo(()=>{try{return yc({amount:f,currency:s,locale:c})}catch{return`${s} ${parseFloat(l).toFixed(2)}`}},[f,s,c]),p=W.useMemo(()=>{try{return Lf({decimalAmount:l,currency:s,locale:c})}catch{return`${s} ${l}`}},[l,s,c]),S=W.useMemo(()=>{try{return mi(s,c)}catch{return s}},[s,c]),y=W.useMemo(()=>{try{return Of(l)}catch{return Math.round(parseFloat(l)*100)}},[l]),C=W.useMemo(()=>ci.map(j=>{try{const v=yc({amount:f,currency:j.code,locale:j.locale}),w=mi(j.code,j.locale);return{...j,formatted:v,symbol:w}}catch{return{...j,formatted:`${j.code} ${parseFloat(l).toFixed(2)}`,symbol:j.code}}}),[f,l]);return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Currency & Formatting"}),r.jsx("p",{className:"section-desc",children:"Multi-currency support with locale-aware formatting. Uses Dinero.js for precise decimal arithmetic and provides utilities for converting between string/integer representations."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Configure"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Amount (decimal)"}),r.jsx("input",{type:"number",step:"0.01",value:l,onChange:j=>u(j.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Currency"}),r.jsx("select",{value:s,onChange:j=>{m(j.target.value);const v=ci.find(w=>w.code===j.target.value);v&&h(v.locale)},className:"select-field mt-1",children:ci.map(j=>r.jsxs("option",{value:j.code,children:[j.code," - ",j.name]},j.code))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Locale"}),r.jsx("input",{value:c,onChange:j=>h(j.target.value),className:"input-field mt-1",placeholder:"e.g., en-US"})]})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Function Results"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[r.jsxs("p",{className:"text-xs text-gray-500 font-mono",children:["formatAmount(","{"," amount: ",f,", currency: '",s,"', locale: '",c,"' ","}",")"]}),r.jsx("p",{className:"text-lg font-bold text-gray-900 mt-1",children:x})]}),r.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[r.jsxs("p",{className:"text-xs text-gray-500 font-mono",children:["formatAmountFromString(","{"," decimalAmount: '",l,"', currency: '",s,"', locale: '",c,"' ","}",")"]}),r.jsx("p",{className:"text-lg font-bold text-gray-900 mt-1",children:p})]}),r.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[r.jsxs("p",{className:"text-xs text-gray-500 font-mono",children:["getCurrencySymbol('",s,"', '",c,"')"]}),r.jsx("p",{className:"text-lg font-bold text-gray-900 mt-1",children:S})]}),r.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[r.jsxs("p",{className:"text-xs text-gray-500 font-mono",children:["toIntegerAmount('",l,"')"]}),r.jsxs("p",{className:"text-lg font-bold text-gray-900 mt-1",children:[y," ",r.jsx("span",{className:"text-sm text-gray-400",children:"(cents)"})]})]})]})]})]}),r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Same Amount in All Currencies"}),r.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:[f," cents formatted per locale"]}),r.jsx("div",{className:"space-y-2",children:C.map(j=>r.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg transition-colors ${j.code===s?"bg-primary-50 border border-primary-200":"bg-gray-50"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"w-10 h-10 rounded-full bg-white border border-gray-200 flex items-center justify-center text-sm font-bold text-gray-600",children:j.symbol}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:j.name}),r.jsxs("p",{className:"text-xs text-gray-400",children:[j.code," (",j.locale,")"]})]})]}),r.jsx("span",{className:"text-lg font-bold text-gray-900",children:j.formatted})]},j.code))})]})})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { + formatAmount, + formatAmountFromString, + getCurrencySymbol, + toIntegerAmount, +} from '@epilot/pricing'; + +// Format from integer (cents) amount +formatAmount({ amount: ${f}, currency: '${s}', locale: '${c}' }); +// => '${x}' + +// Format from decimal string +formatAmountFromString({ decimalAmount: '${l}', currency: '${s}', locale: '${c}' }); +// => '${p}' + +// Get currency symbol +getCurrencySymbol('${s}', '${c}'); +// => '${S}' + +// Convert decimal string to integer (cents) +toIntegerAmount('${l}'); +// => ${y}`})})]})}function zp(){var A;const[l,u]=W.useState("8.50"),[s,m]=W.useState("2.00"),[c,h]=W.useState(1e3),[f,x]=W.useState(19),[p,S]=W.useState(!1),y=W.useMemo(()=>{const T=(parseFloat(l)+parseFloat(s)).toFixed(2),U=be({unitAmountDecimal:T,quantity:c,pricingModel:"per_unit",type:"recurring",billingPeriod:"monthly",taxRate:f,isTaxInclusive:p,description:"Dynamic Energy Tariff",dynamicTariff:{mode:"manual",average_market_price_decimal:l,markup_amount_decimal:s,markup_amount:Math.round(parseFloat(s)*100)}});return Ve([U])},[l,s,c,f,p]),C=parseFloat(l)+parseFloat(s);(A=y.items)==null||A[0];const j=W.useMemo(()=>{const T=parseFloat(l);return Array.from({length:24},(U,I)=>({hour:`${String(I).padStart(2,"0")}:00`,price:Math.max(0,T+Math.sin(I/4)*3+(Math.random()-.5)*2)}))},[l]),v=j.reduce((T,U)=>T+U.price,0)/j.length,w=Math.max(...j.map(T=>T.price));return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Dynamic Tariff"}),r.jsx("p",{className:"section-desc",children:"Market-based pricing for energy products. Combines a day-ahead market price with a configurable markup. Supports both automatic (day_ahead_market) and manual modes."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Configuration"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Market Price (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:l,onChange:T=>u(T.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Markup (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:s,onChange:T=>m(T.target.value),className:"input-field mt-1"})]})]}),r.jsxs("div",{className:"mt-3",children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Consumption: ",r.jsxs("span",{className:"text-primary-600 font-bold",children:[c," kWh"]})]}),r.jsx("input",{type:"range",min:"100",max:"10000",step:"100",value:c,onChange:T=>h(Number(T.target.value)),className:"w-full mt-1 accent-primary-600"}),r.jsxs("div",{className:"flex justify-between text-xs text-gray-400",children:[r.jsx("span",{children:"100 kWh"}),r.jsx("span",{children:"10,000 kWh"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[r.jsx("button",{onClick:()=>S(!p),className:"text-xs text-primary-600 font-medium",children:p?"Tax Inclusive":"Tax Exclusive"}),r.jsxs("span",{className:"text-xs text-gray-400",children:["(",f,"%)"]})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Price Composition"}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between p-3 bg-yellow-50 rounded-lg",children:[r.jsx("span",{className:"text-sm text-gray-700",children:"Market Price"}),r.jsxs("span",{className:"font-bold text-yellow-600",children:[l," ct/kWh"]})]}),r.jsx("div",{className:"flex items-center justify-center text-gray-400 text-lg",children:"+"}),r.jsxs("div",{className:"flex items-center justify-between p-3 bg-blue-50 rounded-lg",children:[r.jsx("span",{className:"text-sm text-gray-700",children:"Supplier Markup"}),r.jsxs("span",{className:"font-bold text-blue-600",children:[s," ct/kWh"]})]}),r.jsx("div",{className:"flex items-center justify-center text-gray-400 text-lg",children:"="}),r.jsxs("div",{className:"flex items-center justify-between p-3 bg-green-50 rounded-lg border border-green-200",children:[r.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Total Unit Price"}),r.jsxs("span",{className:"font-bold text-green-600",children:[C.toFixed(2)," ct/kWh"]})]})]})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Simulated 24h Market Prices"}),r.jsx("div",{className:"flex items-end gap-[2px] h-32",children:j.map((T,U)=>{const I=Math.max(T.price/w*100,2);return r.jsx("div",{className:"flex-1 bg-yellow-400 rounded-t-sm hover:bg-yellow-500 transition-colors",style:{height:`${I}%`},title:`${T.hour}: ${T.price.toFixed(2)} ct/kWh`},U)})}),r.jsxs("div",{className:"flex justify-between text-xs text-gray-400 mt-1",children:[r.jsx("span",{children:"00:00"}),r.jsxs("span",{children:["Avg: ",v.toFixed(2)," ct/kWh"]}),r.jsx("span",{children:"23:00"})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed Result"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Unit Price",value:`${C.toFixed(2)} ct/kWh`}),r.jsx(K,{label:"Consumption",value:`${c} kWh`}),r.jsx(K,{label:"Subtotal (Net)",value:V(y.amount_subtotal)}),r.jsx(K,{label:"Tax",value:V(y.amount_tax),color:"amber"}),r.jsx(K,{label:"Monthly Total",value:V(y.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Annual Estimate",value:V((y.amount_total??0)*12),color:"blue"})]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +const priceItem = { + quantity: ${c}, + pricing_model: 'per_unit', + is_tax_inclusive: ${p}, + _price: { + unit_amount_decimal: '${C.toFixed(2)}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: ${p}, + type: 'recurring', + billing_period: 'monthly', + tax: [{ rate: ${f}, type: 'VAT' }], + // Dynamic tariff configuration + dynamic_tariff: { + mode: 'manual', // or 'day_ahead_market' + average_market_price_decimal: '${l}', + markup_amount_decimal: '${s}', + }, + }, + taxes: [{ tax: { rate: ${f} } }], +}; + +const result = computeAggregatedAndPriceTotals([priceItem]); +// result.amount_total = ${V(y.amount_total)}`})})]})}function qp(){const[l,u]=W.useState("120.00"),[s,m]=W.useState("6.50"),[c,h]=W.useState(3500),[f,x]=W.useState("1.50"),[p,S]=W.useState("24.00"),[y,C]=W.useState(19),j=W.useMemo(()=>{const U=be({unitAmountDecimal:l,quantity:1,type:"recurring",billingPeriod:"yearly",taxRate:y,isTaxInclusive:!1,description:"Base Price (Grundpreis)"}),I=(parseFloat(s)+parseFloat(f)).toFixed(4),_=be({unitAmountDecimal:I,quantity:c,type:"recurring",billingPeriod:"yearly",taxRate:y,isTaxInclusive:!1,description:"Work Price (Arbeitspreis)"}),$=be({unitAmountDecimal:p,quantity:1,type:"recurring",billingPeriod:"yearly",taxRate:y,isTaxInclusive:!1,description:"Additional Markup"});return Ve([U,_,$])},[l,s,c,f,p,y]),v=parseFloat(l),w=(parseFloat(s)+parseFloat(f))*c,A=parseFloat(p),T=v+w+A;return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"GetAG Energy Pricing"}),r.jsx("p",{className:"section-desc",children:"German energy operator (GetAG) integration supporting base price + work price models with tiered markups and additional fees. Used for electricity and gas tariffs."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Tariff Configuration"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"p-3 bg-blue-50 rounded-lg",children:[r.jsx("h4",{className:"text-sm font-medium text-blue-800 mb-2",children:"Grundpreis (Base Price)"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-blue-600",children:"Annual base fee (€/year)"}),r.jsx("input",{type:"number",step:"0.01",value:l,onChange:U=>u(U.target.value),className:"input-field mt-1"})]})]}),r.jsxs("div",{className:"p-3 bg-green-50 rounded-lg",children:[r.jsx("h4",{className:"text-sm font-medium text-green-800 mb-2",children:"Arbeitspreis (Work Price)"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-green-600",children:"GetAG price (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:s,onChange:U=>m(U.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-green-600",children:"Markup (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:f,onChange:U=>x(U.target.value),className:"input-field mt-1"})]})]})]}),r.jsxs("div",{className:"p-3 bg-amber-50 rounded-lg",children:[r.jsx("h4",{className:"text-sm font-medium text-amber-800 mb-2",children:"Additional Markup"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-amber-600",children:"Fixed annual fee (€/year)"}),r.jsx("input",{type:"number",step:"0.01",value:p,onChange:U=>S(U.target.value),className:"input-field mt-1"})]})]})]})]}),r.jsxs("div",{className:"card",children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Annual Consumption: ",r.jsxs("span",{className:"text-primary-600 font-bold",children:[c.toLocaleString()," kWh"]})]}),r.jsx("input",{type:"range",min:"500",max:"10000",step:"100",value:c,onChange:U=>h(Number(U.target.value)),className:"w-full mt-2 accent-primary-600"}),r.jsxs("div",{className:"flex justify-between text-xs text-gray-400",children:[r.jsx("span",{children:"500 kWh"}),r.jsx("span",{children:"10,000 kWh"})]})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Annual Cost Breakdown"}),r.jsx("div",{className:"h-10 flex rounded-lg overflow-hidden mb-4",children:[{value:v,color:"bg-blue-400",label:"Base"},{value:w,color:"bg-green-400",label:"Work"},{value:A,color:"bg-amber-400",label:"Markup"}].map(U=>r.jsx("div",{className:`${U.color} flex items-center justify-center text-white text-xs font-medium transition-all duration-300`,style:{width:`${U.value/T*100}%`},title:`${U.label}: €${U.value.toFixed(2)}`,children:U.value/T*100>10?U.label:""},U.label))}),r.jsxs("div",{className:"space-y-2",children:[[{label:"Grundpreis (Base)",value:v,color:"bg-blue-400",detail:`€${parseFloat(l).toFixed(2)}/year`},{label:"Arbeitspreis (Work)",value:w,color:"bg-green-400",detail:`${(parseFloat(s)+parseFloat(f)).toFixed(2)} ct/kWh x ${c.toLocaleString()} kWh`},{label:"Additional Markup",value:A,color:"bg-amber-400",detail:`€${parseFloat(p).toFixed(2)}/year`}].map(U=>r.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 rounded",children:[r.jsx("div",{className:`w-3 h-3 rounded-sm ${U.color}`}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:U.label}),r.jsx("p",{className:"text-xs text-gray-400",children:U.detail})]}),r.jsxs("span",{className:"font-bold text-sm",children:["€",U.value.toFixed(2)]})]},U.label)),r.jsx("div",{className:"border-t border-gray-200 pt-2 mt-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm font-semibold text-gray-700",children:"Net Total (annual)"}),r.jsxs("span",{className:"text-lg font-bold text-gray-900",children:["€",T.toFixed(2)]})]})})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed via Library"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Annual Net",value:V(j.amount_subtotal)}),r.jsx(K,{label:"Tax ({taxRate}%)",value:V(j.amount_tax),color:"amber"}),r.jsx(K,{label:"Annual Gross",value:V(j.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Monthly Gross",value:V(Math.round((j.amount_total??0)/12)),color:"blue"})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Work Price Detail"}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsxs("div",{className:"flex-1 text-center p-2 bg-green-50 rounded",children:[r.jsx("p",{className:"text-xs text-green-600",children:"GetAG Price"}),r.jsxs("p",{className:"font-bold text-green-700",children:[s," ct"]})]}),r.jsx("span",{className:"text-gray-400",children:"+"}),r.jsxs("div",{className:"flex-1 text-center p-2 bg-amber-50 rounded",children:[r.jsx("p",{className:"text-xs text-amber-600",children:"Markup"}),r.jsxs("p",{className:"font-bold text-amber-700",children:[f," ct"]})]}),r.jsx("span",{className:"text-gray-400",children:"="}),r.jsxs("div",{className:"flex-1 text-center p-2 bg-primary-50 rounded",children:[r.jsx("p",{className:"text-xs text-primary-600",children:"Total"}),r.jsxs("p",{className:"font-bold text-primary-700",children:[(parseFloat(s)+parseFloat(f)).toFixed(2)," ct"]})]})]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +// GetAG-style tariff: base price + work price + markups +const items = [ + { + quantity: 1, + _price: { + unit_amount_decimal: '${l}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: 'recurring', + billing_period: 'yearly', + tax: [{ rate: ${y}, type: 'VAT' }], + description: 'Grundpreis (Base Price)', + }, + taxes: [{ tax: { rate: ${y} } }], + }, + { + quantity: ${c}, // kWh consumption + _price: { + unit_amount_decimal: '${(parseFloat(s)+parseFloat(f)).toFixed(4)}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: 'recurring', + billing_period: 'yearly', + tax: [{ rate: ${y}, type: 'VAT' }], + description: 'Arbeitspreis (Work Price)', + }, + taxes: [{ tax: { rate: ${y} } }], + }, +]; + +const result = computeAggregatedAndPriceTotals(items); +// result.amount_total = ${V(j.amount_total)} (annual gross)`})})]})}function Wp(){const[l,u]=W.useState("single"),[s,m]=W.useState("96.00"),[c,h]=W.useState("28.50"),[f,x]=W.useState("22.30"),[p,S]=W.useState("3.20"),[y,C]=W.useState("2.10"),[j,v]=W.useState(2800),[w,A]=W.useState(1200),[T,U]=W.useState(19),I=W.useMemo(()=>{const Q=[];Q.push(be({unitAmountDecimal:s,quantity:1,type:"recurring",billingPeriod:"yearly",taxRate:T,isTaxInclusive:!1,description:"Grundpreis (Base Price)"}));const _e=(parseFloat(c)+parseFloat(p)).toFixed(4);if(Q.push(be({unitAmountDecimal:_e,quantity:l==="dual"?j:j+w,type:"recurring",billingPeriod:"yearly",taxRate:T,isTaxInclusive:!1,description:l==="dual"?"Arbeitspreis HT (Peak)":"Arbeitspreis (Work Price)"})),l==="dual"){const xe=(parseFloat(f)+parseFloat(y)).toFixed(4);Q.push(be({unitAmountDecimal:xe,quantity:w,type:"recurring",billingPeriod:"yearly",taxRate:T,isTaxInclusive:!1,description:"Arbeitspreis NT (Off-Peak)"}))}return Ve(Q)},[l,s,c,f,p,y,j,w,T]),_=j+w,$=parseFloat(s),R=parseFloat(c)+parseFloat(p),M=parseFloat(f)+parseFloat(y),L=R*(l==="dual"?j:_),H=l==="dual"?M*w:0,te=$+L+H;return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Electricity Tariff"}),r.jsx("p",{className:"section-desc",children:"Standard German electricity pricing with Grundpreis (base fee) and Arbeitspreis (work price per kWh). Supports single-tariff and dual-tariff (HT/NT) meters for peak and off-peak consumption."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Meter Type"}),r.jsx("div",{className:"flex gap-2",children:["single","dual"].map(Q=>r.jsx("button",{onClick:()=>u(Q),className:`flex-1 py-2 px-3 rounded-lg text-sm font-medium transition-colors ${l===Q?"bg-primary-600 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:Q==="single"?"Single Tariff (ET)":"Dual Tariff (HT/NT)"},Q))})]}),r.jsx("div",{className:"card",children:r.jsxs("div",{className:"p-3 bg-blue-50 rounded-lg",children:[r.jsx("h4",{className:"text-sm font-medium text-blue-800 mb-2",children:"Grundpreis (Base Price)"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-blue-600",children:"Annual base fee (EUR/year)"}),r.jsx("input",{type:"number",step:"0.01",value:s,onChange:Q=>m(Q.target.value),className:"input-field mt-1"})]})]})}),r.jsxs("div",{className:"card",children:[r.jsxs("div",{className:"p-3 bg-yellow-50 rounded-lg mb-3",children:[r.jsx("h4",{className:"text-sm font-medium text-yellow-800 mb-2",children:l==="dual"?"Arbeitspreis HT (Peak)":"Arbeitspreis (Work Price)"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-yellow-600",children:"Base price (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:c,onChange:Q=>h(Q.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-yellow-600",children:"Markup (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:p,onChange:Q=>S(Q.target.value),className:"input-field mt-1"})]})]})]}),l==="dual"&&r.jsxs("div",{className:"p-3 bg-indigo-50 rounded-lg",children:[r.jsx("h4",{className:"text-sm font-medium text-indigo-800 mb-2",children:"Arbeitspreis NT (Off-Peak)"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-indigo-600",children:"Base price (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:f,onChange:Q=>x(Q.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-indigo-600",children:"Markup (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:y,onChange:Q=>C(Q.target.value),className:"input-field mt-1"})]})]})]})]}),r.jsx("div",{className:"card",children:l==="dual"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["HT Consumption: ",r.jsxs("span",{className:"text-yellow-600 font-bold",children:[j.toLocaleString()," kWh"]})]}),r.jsx("input",{type:"range",min:"500",max:"8000",step:"100",value:j,onChange:Q=>v(Number(Q.target.value)),className:"w-full mt-1 accent-yellow-500"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["NT Consumption: ",r.jsxs("span",{className:"text-indigo-600 font-bold",children:[w.toLocaleString()," kWh"]})]}),r.jsx("input",{type:"range",min:"200",max:"5000",step:"100",value:w,onChange:Q=>A(Number(Q.target.value)),className:"w-full mt-1 accent-indigo-500"})]}),r.jsxs("p",{className:"text-xs text-gray-400",children:["Total: ",_.toLocaleString()," kWh/year"]})]}):r.jsxs("div",{children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Annual Consumption: ",r.jsxs("span",{className:"text-primary-600 font-bold",children:[_.toLocaleString()," kWh"]})]}),r.jsx("input",{type:"range",min:"1000",max:"10000",step:"100",value:j+w,onChange:Q=>{const _e=Number(Q.target.value);v(Math.round(_e*.7)),A(Math.round(_e*.3))},className:"w-full mt-1 accent-primary-600"}),r.jsxs("div",{className:"flex justify-between text-xs text-gray-400",children:[r.jsx("span",{children:"1,000 kWh"}),r.jsx("span",{children:"10,000 kWh"})]})]})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Annual Cost Breakdown"}),r.jsx("div",{className:"h-10 flex rounded-lg overflow-hidden mb-4",children:[{value:$,color:"bg-blue-400",label:"Base"},{value:L,color:"bg-yellow-400",label:l==="dual"?"HT":"Work"},...l==="dual"?[{value:H,color:"bg-indigo-400",label:"NT"}]:[]].map(Q=>r.jsx("div",{className:`${Q.color} flex items-center justify-center text-white text-xs font-medium transition-all duration-300`,style:{width:`${Q.value/te*100}%`},title:`${Q.label}: EUR ${Q.value.toFixed(2)}`,children:Q.value/te*100>10?Q.label:""},Q.label))}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 rounded",children:[r.jsx("div",{className:"w-3 h-3 rounded-sm bg-blue-400"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Grundpreis"}),r.jsxs("p",{className:"text-xs text-gray-400",children:["EUR ",parseFloat(s).toFixed(2),"/year"]})]}),r.jsxs("span",{className:"font-bold text-sm",children:["EUR ",$.toFixed(2)]})]}),r.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 rounded",children:[r.jsx("div",{className:"w-3 h-3 rounded-sm bg-yellow-400"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:l==="dual"?"Arbeitspreis HT":"Arbeitspreis"}),r.jsxs("p",{className:"text-xs text-gray-400",children:[R.toFixed(2)," ct/kWh x ",(l==="dual"?j:_).toLocaleString()," kWh"]})]}),r.jsxs("span",{className:"font-bold text-sm",children:["EUR ",L.toFixed(2)]})]}),l==="dual"&&r.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 rounded",children:[r.jsx("div",{className:"w-3 h-3 rounded-sm bg-indigo-400"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Arbeitspreis NT"}),r.jsxs("p",{className:"text-xs text-gray-400",children:[M.toFixed(2)," ct/kWh x ",w.toLocaleString()," kWh"]})]}),r.jsxs("span",{className:"font-bold text-sm",children:["EUR ",H.toFixed(2)]})]}),r.jsx("div",{className:"border-t border-gray-200 pt-2 mt-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm font-semibold text-gray-700",children:"Net Total (annual)"}),r.jsxs("span",{className:"text-lg font-bold text-gray-900",children:["EUR ",te.toFixed(2)]})]})})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed via Library"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Annual Net",value:V(I.amount_subtotal)}),r.jsx(K,{label:`Tax (${T}%)`,value:V(I.amount_tax),color:"amber"}),r.jsx(K,{label:"Annual Gross",value:V(I.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Monthly Gross",value:V(Math.round((I.amount_total??0)/12)),color:"blue"})]})]}),l==="dual"&&r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"HT vs NT Rate Comparison"}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("div",{className:"flex-1 text-center p-3 bg-yellow-50 rounded-lg",children:[r.jsx("p",{className:"text-xs text-yellow-600",children:"HT (Peak)"}),r.jsxs("p",{className:"text-lg font-bold text-yellow-700",children:[R.toFixed(2)," ct"]}),r.jsxs("p",{className:"text-xs text-yellow-500",children:[j.toLocaleString()," kWh"]})]}),r.jsxs("div",{className:"flex-1 text-center p-3 bg-indigo-50 rounded-lg",children:[r.jsx("p",{className:"text-xs text-indigo-600",children:"NT (Off-Peak)"}),r.jsxs("p",{className:"text-lg font-bold text-indigo-700",children:[M.toFixed(2)," ct"]}),r.jsxs("p",{className:"text-xs text-indigo-500",children:[w.toLocaleString()," kWh"]})]})]}),r.jsxs("p",{className:"text-xs text-gray-400 mt-2 text-center",children:["Savings vs. all-HT: EUR ",((R-M)*w).toFixed(2),"/year"]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +// Electricity tariff: Grundpreis + Arbeitspreis +const items = [ + { + quantity: 1, + _price: { + unit_amount_decimal: '${s}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: 'recurring', + billing_period: 'yearly', + tax: [{ rate: ${T}, type: 'VAT' }], + description: 'Grundpreis (Base Price)', + }, + taxes: [{ tax: { rate: ${T} } }], + }, + { + quantity: ${l==="dual"?j:_}, // ${l==="dual"?"HT":"total"} kWh + _price: { + unit_amount_decimal: '${R.toFixed(4)}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: 'recurring', + billing_period: 'yearly', + tax: [{ rate: ${T}, type: 'VAT' }], + description: '${l==="dual"?"Arbeitspreis HT (Peak)":"Arbeitspreis (Work Price)"}', + }, + taxes: [{ tax: { rate: ${T} } }], + },${l==="dual"?` + { + quantity: ${w}, // NT kWh + _price: { + unit_amount_decimal: '${M.toFixed(4)}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: 'recurring', + billing_period: 'yearly', + tax: [{ rate: ${T}, type: 'VAT' }], + description: 'Arbeitspreis NT (Off-Peak)', + }, + taxes: [{ tax: { rate: ${T} } }], + },`:""} +]; + +const result = computeAggregatedAndPriceTotals(items); +// result.amount_total = ${V(I.amount_total)} (annual gross)`})})]})}function Bp(){const[l,u]=W.useState("144.00"),[s,m]=W.useState("8.90"),[c,h]=W.useState("1.80"),[f,x]=W.useState(15e3),[p,S]=W.useState("0.546"),[y,C]=W.useState("0.059"),[j,v]=W.useState(19),w=W.useMemo(()=>{const R=[];R.push(be({unitAmountDecimal:l,quantity:1,type:"recurring",billingPeriod:"yearly",taxRate:j,isTaxInclusive:!1,description:"Grundpreis (Base Price)"}));const M=parseFloat(s)+parseFloat(c)+parseFloat(p)+parseFloat(y);return R.push(be({unitAmountDecimal:M.toFixed(4),quantity:f,type:"recurring",billingPeriod:"yearly",taxRate:j,isTaxInclusive:!1,description:"Arbeitspreis (Work Price)"})),Ve(R)},[l,s,c,f,p,y,j]),A=parseFloat(l),T=parseFloat(s)+parseFloat(c),U=parseFloat(p)+parseFloat(y),I=T*f,_=U*f,$=A+I+_;return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Gas Tariff"}),r.jsx("p",{className:"section-desc",children:"German gas supply pricing with Grundpreis, Arbeitspreis, and gas-specific levies including CO2 tax and gas storage levy. Typical household consumption: 10,000 - 25,000 kWh/year."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"card",children:r.jsxs("div",{className:"p-3 bg-blue-50 rounded-lg",children:[r.jsx("h4",{className:"text-sm font-medium text-blue-800 mb-2",children:"Grundpreis (Base Price)"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-blue-600",children:"Annual base fee (EUR/year)"}),r.jsx("input",{type:"number",step:"0.01",value:l,onChange:R=>u(R.target.value),className:"input-field mt-1"})]})]})}),r.jsxs("div",{className:"card",children:[r.jsxs("div",{className:"p-3 bg-orange-50 rounded-lg mb-3",children:[r.jsx("h4",{className:"text-sm font-medium text-orange-800 mb-2",children:"Arbeitspreis (Work Price)"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-orange-600",children:"Base price (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:s,onChange:R=>m(R.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-orange-600",children:"Markup (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.01",value:c,onChange:R=>h(R.target.value),className:"input-field mt-1"})]})]})]}),r.jsxs("div",{className:"p-3 bg-red-50 rounded-lg",children:[r.jsx("h4",{className:"text-sm font-medium text-red-800 mb-2",children:"Gas Levies"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-red-600",children:"CO2 levy (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.001",value:p,onChange:R=>S(R.target.value),className:"input-field mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-red-600",children:"Gas storage levy (ct/kWh)"}),r.jsx("input",{type:"number",step:"0.001",value:y,onChange:R=>C(R.target.value),className:"input-field mt-1"})]})]})]})]}),r.jsxs("div",{className:"card",children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Annual Consumption: ",r.jsxs("span",{className:"text-primary-600 font-bold",children:[f.toLocaleString()," kWh"]})]}),r.jsx("input",{type:"range",min:"5000",max:"50000",step:"500",value:f,onChange:R=>x(Number(R.target.value)),className:"w-full mt-2 accent-primary-600"}),r.jsxs("div",{className:"flex justify-between text-xs text-gray-400",children:[r.jsx("span",{children:"5,000 kWh"}),r.jsx("span",{children:"50,000 kWh"})]})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Annual Cost Breakdown"}),r.jsx("div",{className:"h-10 flex rounded-lg overflow-hidden mb-4",children:[{value:A,color:"bg-blue-400",label:"Base"},{value:I,color:"bg-orange-400",label:"Work"},{value:_,color:"bg-red-400",label:"Levies"}].map(R=>r.jsx("div",{className:`${R.color} flex items-center justify-center text-white text-xs font-medium transition-all duration-300`,style:{width:`${Math.max(R.value/$*100,1)}%`},title:`${R.label}: EUR ${R.value.toFixed(2)}`,children:R.value/$*100>10?R.label:""},R.label))}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 rounded",children:[r.jsx("div",{className:"w-3 h-3 rounded-sm bg-blue-400"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Grundpreis"}),r.jsxs("p",{className:"text-xs text-gray-400",children:["EUR ",parseFloat(l).toFixed(2),"/year"]})]}),r.jsxs("span",{className:"font-bold text-sm",children:["EUR ",A.toFixed(2)]})]}),r.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 rounded",children:[r.jsx("div",{className:"w-3 h-3 rounded-sm bg-orange-400"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Arbeitspreis + Markup"}),r.jsxs("p",{className:"text-xs text-gray-400",children:[T.toFixed(2)," ct/kWh x ",f.toLocaleString()," kWh"]})]}),r.jsxs("span",{className:"font-bold text-sm",children:["EUR ",I.toFixed(2)]})]}),r.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 rounded",children:[r.jsx("div",{className:"w-3 h-3 rounded-sm bg-red-400"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Gas Levies"}),r.jsxs("p",{className:"text-xs text-gray-400",children:[U.toFixed(3)," ct/kWh x ",f.toLocaleString()," kWh (CO2 + storage)"]})]}),r.jsxs("span",{className:"font-bold text-sm",children:["EUR ",_.toFixed(2)]})]}),r.jsx("div",{className:"border-t border-gray-200 pt-2 mt-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm font-semibold text-gray-700",children:"Net Total (annual)"}),r.jsxs("span",{className:"text-lg font-bold text-gray-900",children:["EUR ",$.toFixed(2)]})]})})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed via Library"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Annual Net",value:V(w.amount_subtotal)}),r.jsx(K,{label:`Tax (${j}%)`,value:V(w.amount_tax),color:"amber"}),r.jsx(K,{label:"Annual Gross",value:V(w.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Monthly Gross",value:V(Math.round((w.amount_total??0)/12)),color:"blue"})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Per-kWh Price Composition"}),r.jsxs("div",{className:"space-y-2",children:[[{label:"Work Price",value:parseFloat(s),color:"bg-orange-200"},{label:"Markup",value:parseFloat(c),color:"bg-orange-400"},{label:"CO2 Levy",value:parseFloat(p),color:"bg-red-300"},{label:"Gas Storage",value:parseFloat(y),color:"bg-red-200"}].map(R=>{const M=parseFloat(s)+parseFloat(c)+parseFloat(p)+parseFloat(y);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-gray-500 w-24",children:R.label}),r.jsx("div",{className:"flex-1 bg-gray-100 rounded-full h-4 overflow-hidden",children:r.jsx("div",{className:`${R.color} h-full rounded-full`,style:{width:`${R.value/M*100}%`}})}),r.jsxs("span",{className:"text-xs font-medium w-16 text-right",children:[R.value.toFixed(3)," ct"]})]},R.label)}),r.jsx("div",{className:"border-t border-gray-200 pt-2 text-right",children:r.jsxs("span",{className:"text-sm font-bold text-gray-900",children:["Total: ",(parseFloat(s)+parseFloat(c)+parseFloat(p)+parseFloat(y)).toFixed(3)," ct/kWh"]})})]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +// Gas tariff: Grundpreis + Arbeitspreis (incl. levies) +const items = [ + { + quantity: 1, + _price: { + unit_amount_decimal: '${l}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: 'recurring', + billing_period: 'yearly', + tax: [{ rate: ${j}, type: 'VAT' }], + description: 'Grundpreis (Base Price)', + }, + taxes: [{ tax: { rate: ${j} } }], + }, + { + quantity: ${f}, // kWh consumption + _price: { + // Work price + markup + CO2 levy + gas storage levy + unit_amount_decimal: '${(parseFloat(s)+parseFloat(c)+parseFloat(p)+parseFloat(y)).toFixed(4)}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: 'recurring', + billing_period: 'yearly', + tax: [{ rate: ${j}, type: 'VAT' }], + description: 'Arbeitspreis (Work Price)', + }, + taxes: [{ tax: { rate: ${j} } }], + }, +]; + +const result = computeAggregatedAndPriceTotals(items); +// result.amount_total = ${V(w.amount_total)} (annual gross)`})})]})}const Vp=[{name:"Electricity Connection",unitAmountDecimal:"1850.00",quantity:1,type:"one_time"},{name:"Gas Connection",unitAmountDecimal:"1450.00",quantity:1,type:"one_time"},{name:"Water Connection",unitAmountDecimal:"2200.00",quantity:1,type:"one_time"},{name:"Construction Power Supply",unitAmountDecimal:"350.00",quantity:1,type:"one_time"},{name:"Meter Installation Fee",unitAmountDecimal:"12.50",quantity:1,type:"recurring",billingPeriod:"monthly"}];function Hp(){var A,T,U,I,_,$,R;const[l,u]=W.useState(Vp),[s,m]=W.useState(19),[c,h]=W.useState(15),[f,x]=W.useState("85.00"),p=c*parseFloat(f),S=W.useMemo(()=>{const M=l.map(L=>be({unitAmountDecimal:L.unitAmountDecimal,quantity:L.quantity,type:L.type,billingPeriod:L.billingPeriod,taxRate:s,isTaxInclusive:!1,description:L.name}));return M.push(be({unitAmountDecimal:p.toFixed(2),quantity:1,type:"one_time",taxRate:s,isTaxInclusive:!1,description:"Trench Work (Tiefbau)"})),Ve(M)},[l,s,p]),y=(M,L,H)=>{u(te=>te.map((Q,_e)=>_e===M?{...Q,[L]:H}:Q))},C=M=>{u(L=>L.map((H,te)=>te===M?{...H,quantity:H.quantity>0?0:1}:H))},j=l.filter(M=>M.type==="one_time"&&M.quantity>0).reduce((M,L)=>M+parseFloat(L.unitAmountDecimal)*L.quantity,0),v=l.filter(M=>M.type==="recurring"&&M.quantity>0).reduce((M,L)=>M+parseFloat(L.unitAmountDecimal)*L.quantity,0),w=j+p;return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"House Connection"}),r.jsx("p",{className:"section-desc",children:"Hausanschluss (house connection) pricing for new builds and renovations. Combines one-time connection fees, distance-based trench work, and recurring meter costs."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Connection Services"}),r.jsx("div",{className:"space-y-2",children:l.map((M,L)=>r.jsx("div",{className:`p-3 rounded-lg border transition-colors ${M.quantity>0?"bg-white border-primary-200":"bg-gray-50 border-gray-100 opacity-60"}`,children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>C(L),className:`w-5 h-5 rounded border-2 flex items-center justify-center text-xs transition-colors ${M.quantity>0?"bg-primary-600 border-primary-600 text-white":"border-gray-300"}`,children:M.quantity>0?"✓":""}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700",children:M.name}),r.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${M.type==="one_time"?"bg-blue-100 text-blue-700":"bg-green-100 text-green-700"}`,children:M.type==="one_time"?"One-time":`${M.billingPeriod}`})]}),r.jsx("div",{className:"w-28",children:r.jsx("input",{type:"number",step:"0.01",value:M.unitAmountDecimal,onChange:H=>y(L,"unitAmountDecimal",H.target.value),className:"input-field text-xs text-right",disabled:M.quantity===0})})]})},L))})]}),r.jsx("div",{className:"card",children:r.jsxs("div",{className:"p-3 bg-amber-50 rounded-lg",children:[r.jsx("h4",{className:"text-sm font-medium text-amber-800 mb-2",children:"Trench Work (Tiefbau)"}),r.jsxs("div",{children:[r.jsxs("label",{className:"text-sm font-medium text-gray-700",children:["Distance to grid: ",r.jsxs("span",{className:"text-amber-600 font-bold",children:[c," m"]})]}),r.jsx("input",{type:"range",min:"5",max:"100",step:"1",value:c,onChange:M=>h(Number(M.target.value)),className:"w-full mt-1 accent-amber-500"}),r.jsxs("div",{className:"flex justify-between text-xs text-gray-400",children:[r.jsx("span",{children:"5 m"}),r.jsx("span",{children:"100 m"})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-xs text-amber-600",children:"Rate per meter (EUR/m)"}),r.jsx("input",{type:"number",step:"0.01",value:f,onChange:M=>x(M.target.value),className:"input-field mt-1"})]}),r.jsx("div",{className:"flex items-end",children:r.jsxs("div",{className:"p-2 bg-amber-100 rounded text-center w-full",children:[r.jsx("p",{className:"text-xs text-amber-600",children:"Total Trench Cost"}),r.jsxs("p",{className:"font-bold text-amber-800",children:["EUR ",p.toFixed(2)]})]})})]})]})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Cost Overview"}),r.jsxs("div",{className:"space-y-3 mb-4",children:[l.filter(M=>M.quantity>0&&M.type==="one_time").map((M,L)=>{const H=parseFloat(M.unitAmountDecimal)*M.quantity;return r.jsxs("div",{className:"flex items-center justify-between p-2 bg-blue-50 rounded",children:[r.jsx("span",{className:"text-sm text-gray-700",children:M.name}),r.jsxs("span",{className:"font-semibold text-sm",children:["EUR ",H.toFixed(2)]})]},L)}),r.jsxs("div",{className:"flex items-center justify-between p-2 bg-amber-50 rounded",children:[r.jsxs("span",{className:"text-sm text-gray-700",children:["Trench Work (",c,"m x EUR ",parseFloat(f).toFixed(2),")"]}),r.jsxs("span",{className:"font-semibold text-sm",children:["EUR ",p.toFixed(2)]})]}),l.filter(M=>M.quantity>0&&M.type==="recurring").map((M,L)=>r.jsxs("div",{className:"flex items-center justify-between p-2 bg-green-50 rounded",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-sm text-gray-700",children:M.name}),r.jsxs("span",{className:"text-xs text-green-600 ml-2",children:["/",M.billingPeriod]})]}),r.jsxs("span",{className:"font-semibold text-sm",children:["EUR ",parseFloat(M.unitAmountDecimal).toFixed(2)]})]},L))]}),r.jsxs("div",{className:"border-t border-gray-200 pt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-gray-600",children:"One-time costs (net)"}),r.jsxs("span",{className:"font-bold text-gray-900",children:["EUR ",w.toFixed(2)]})]}),v>0&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-gray-600",children:"Recurring costs (net)"}),r.jsxs("span",{className:"font-bold text-gray-900",children:["EUR ",v.toFixed(2),"/month"]})]})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed via Library"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Total Net",value:V(S.amount_subtotal)}),r.jsx(K,{label:`Tax (${s}%)`,value:V(S.amount_tax),color:"amber"}),r.jsx(K,{label:"Total Gross",value:V(S.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Items",value:((A=S.items)==null?void 0:A.length)??0})]}),(((I=(U=(T=S.total_details)==null?void 0:T.breakdown)==null?void 0:U.recurrences)==null?void 0:I.length)??0)>0&&r.jsxs("div",{className:"mt-4",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700 mb-2",children:"By Recurrence:"}),(R=($=(_=S.total_details)==null?void 0:_.breakdown)==null?void 0:$.recurrences)==null?void 0:R.map((M,L)=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100 text-sm",children:[r.jsx("span",{className:M.type==="one_time"?"badge-blue":"badge-green",children:M.type==="one_time"?"One-time":M.billing_period}),r.jsx("span",{className:"font-medium",children:V(M.amount_total)})]},L))]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +// House connection: mix of one-time and recurring items +const items = [ +${l.filter(M=>M.quantity>0).map(M=>` { + quantity: ${M.quantity}, + _price: { + unit_amount_decimal: '${M.unitAmountDecimal}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: '${M.type}',${M.billingPeriod?` + billing_period: '${M.billingPeriod}',`:""} + tax: [{ rate: ${s}, type: 'VAT' }], + description: '${M.name}', + }, + taxes: [{ tax: { rate: ${s} } }], + },`).join(` +`)} + { + quantity: 1, + _price: { + unit_amount_decimal: '${p.toFixed(2)}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: 'one_time', + tax: [{ rate: ${s}, type: 'VAT' }], + description: 'Trench Work (${c}m x EUR ${parseFloat(f).toFixed(2)}/m)', + }, + taxes: [{ tax: { rate: ${s} } }], + }, +]; + +const result = computeAggregatedAndPriceTotals(items); +// result.amount_total = ${V(S.amount_total)}`})})]})}const Gp=[{name:"Solar Panel System (10 kWp)",category:"solar",price:"12500.00",quantity:1,type:"one_time",enabled:!0},{name:"Battery Storage (10 kWh)",category:"solar",price:"6800.00",quantity:1,type:"one_time",enabled:!0},{name:"Solar Installation",category:"solar",price:"3200.00",quantity:1,type:"one_time",enabled:!0},{name:"Solar Maintenance Contract",category:"solar",price:"29.90",quantity:1,type:"recurring",billingPeriod:"monthly",enabled:!0},{name:"Wallbox (11 kW)",category:"emobility",price:"899.00",quantity:1,type:"one_time",enabled:!1},{name:"Wallbox Installation",category:"emobility",price:"450.00",quantity:1,type:"one_time",enabled:!1},{name:"Charging Flat Rate",category:"emobility",price:"59.00",quantity:1,type:"recurring",billingPeriod:"monthly",enabled:!1},{name:"Heat Pump System",category:"heating",price:"15800.00",quantity:1,type:"one_time",enabled:!1},{name:"Heat Pump Installation",category:"heating",price:"4500.00",quantity:1,type:"one_time",enabled:!1},{name:"Heating Maintenance",category:"heating",price:"39.90",quantity:1,type:"recurring",billingPeriod:"monthly",enabled:!1},{name:"Smart Thermostat",category:"smarthome",price:"249.00",quantity:1,type:"one_time",enabled:!1},{name:"Energy Manager",category:"smarthome",price:"499.00",quantity:1,type:"one_time",enabled:!1}],tl={solar:{label:"Solar & Storage",color:"bg-yellow-400",bg:"bg-yellow-50",text:"text-yellow-700",icon:"☀️"},emobility:{label:"E-Mobility",color:"bg-blue-400",bg:"bg-blue-50",text:"text-blue-700",icon:"🚗"},heating:{label:"Heating",color:"bg-red-400",bg:"bg-red-50",text:"text-red-700",icon:"🌡️"},smarthome:{label:"Smart Home",color:"bg-green-400",bg:"bg-green-50",text:"text-green-700",icon:"🏠"}};function Qp(){var v,w,A,T,U,I;const[l,u]=W.useState(Gp),[s,m]=W.useState(19),c=_=>{u($=>$.map((R,M)=>M===_?{...R,enabled:!R.enabled}:R))},h=(_,$,R)=>{u(M=>M.map((L,H)=>H===_?{...L,[$]:R}:L))},f=_=>{u($=>{const M=$.filter(L=>L.category===_).every(L=>L.enabled);return $.map(L=>L.category===_?{...L,enabled:!M}:L)})},x=W.useMemo(()=>{const _=l.filter($=>$.enabled).map($=>be({unitAmountDecimal:$.price,quantity:$.quantity,type:$.type,billingPeriod:$.billingPeriod,taxRate:s,isTaxInclusive:!1,description:$.name}));return _.length===0?{amount_subtotal:0,amount_tax:0,amount_total:0,items:[],total_details:{breakdown:{recurrences:[]}}}:Ve(_)},[l,s]),p=l.filter(_=>_.enabled),S=p.filter(_=>_.type==="one_time").reduce((_,$)=>_+parseFloat($.price)*$.quantity,0),y=p.filter(_=>_.type==="recurring").reduce((_,$)=>_+parseFloat($.price)*$.quantity,0),C=["solar","emobility","heating","smarthome"],j=C.map(_=>{const $=p.filter(R=>R.category===_);return{category:_,...tl[_],oneTime:$.filter(R=>R.type==="one_time").reduce((R,M)=>R+parseFloat(M.price)*M.quantity,0),recurring:$.filter(R=>R.type==="recurring").reduce((R,M)=>R+parseFloat(M.price)*M.quantity,0),count:$.length}}).filter(_=>_.count>0);return r.jsxs("div",{children:[r.jsx("h1",{className:"section-title",children:"Non-Commodity Products"}),r.jsx("p",{className:"section-desc",children:"Products and services beyond the energy supply itself — solar panels, battery storage, wallboxes, heat pumps, and smart home devices. Combines one-time hardware and installation costs with recurring service and maintenance contracts."}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Product Categories"}),r.jsx("div",{className:"grid grid-cols-2 gap-2",children:C.map(_=>{const $=tl[_],R=l.filter(L=>L.category===_),M=R.filter(L=>L.enabled).length;return r.jsxs("button",{onClick:()=>f(_),className:`p-3 rounded-lg border text-left transition-colors ${M>0?`${$.bg} border-current ${$.text}`:"bg-gray-50 border-gray-200 text-gray-400"}`,children:[r.jsx("span",{className:"text-lg",children:$.icon}),r.jsx("p",{className:"text-sm font-medium mt-1",children:$.label}),r.jsxs("p",{className:"text-[10px] opacity-70",children:[M,"/",R.length," selected"]})]},_)})})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Products & Services"}),r.jsx("div",{className:"space-y-2 max-h-[400px] overflow-y-auto",children:l.map((_,$)=>{const R=tl[_.category];return r.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg border transition-colors ${_.enabled?`${R.bg} border-transparent`:"bg-gray-50 border-gray-100 opacity-50"}`,children:[r.jsx("button",{onClick:()=>c($),className:`w-4 h-4 rounded border-2 flex-shrink-0 flex items-center justify-center text-[10px] ${_.enabled?"bg-primary-600 border-primary-600 text-white":"border-gray-300"}`,children:_.enabled?"✓":""}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-xs font-medium text-gray-700 truncate",children:_.name}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`text-[10px] ${R.text}`,children:R.label}),r.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded ${_.type==="one_time"?"bg-blue-100 text-blue-600":"bg-green-100 text-green-600"}`,children:_.type==="one_time"?"One-time":_.billingPeriod})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"number",min:"1",value:_.quantity,onChange:M=>h($,"quantity",Math.max(1,Number(M.target.value))),className:"input-field w-12 text-xs text-center",disabled:!_.enabled}),r.jsx("input",{type:"number",step:"0.01",value:_.price,onChange:M=>h($,"price",M.target.value),className:"input-field w-24 text-xs text-right",disabled:!_.enabled})]})]},$)})})]}),r.jsxs("div",{className:"card",children:[r.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Tax Rate"}),r.jsxs("select",{value:s,onChange:_=>m(Number(_.target.value)),className:"select-field mt-1",children:[r.jsx("option",{value:0,children:"0% (Solar tax exemption)"}),r.jsx("option",{value:7,children:"7%"}),r.jsx("option",{value:19,children:"19%"})]})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Cost by Category"}),j.length===0?r.jsx("p",{className:"text-sm text-gray-400 text-center py-4",children:"No products selected"}):r.jsxs(r.Fragment,{children:[S>0&&r.jsxs("div",{className:"mb-4",children:[r.jsx("p",{className:"text-xs text-gray-500 mb-1",children:"One-time costs"}),r.jsx("div",{className:"h-8 flex rounded-lg overflow-hidden",children:j.filter(_=>_.oneTime>0).map(_=>r.jsx("div",{className:`${_.color} flex items-center justify-center text-white text-xs font-medium transition-all duration-300`,style:{width:`${_.oneTime/S*100}%`},title:`${_.label}: EUR ${_.oneTime.toFixed(2)}`,children:_.oneTime/S*100>15?_.icon:""},_.category))})]}),r.jsxs("div",{className:"space-y-2",children:[j.map(_=>r.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 rounded",children:[r.jsx("div",{className:`w-3 h-3 rounded-sm ${_.color}`}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("p",{className:"text-sm font-medium text-gray-700",children:[_.icon," ",_.label]}),r.jsxs("p",{className:"text-xs text-gray-400",children:[_.count," item(s)"]})]}),r.jsxs("div",{className:"text-right",children:[_.oneTime>0&&r.jsxs("p",{className:"text-sm font-bold",children:["EUR ",_.oneTime.toFixed(2)]}),_.recurring>0&&r.jsxs("p",{className:"text-xs text-green-600",children:["+ EUR ",_.recurring.toFixed(2),"/mo"]})]})]},_.category)),r.jsxs("div",{className:"border-t border-gray-200 pt-2 mt-2 space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-gray-600",children:"One-time total (net)"}),r.jsxs("span",{className:"font-bold text-gray-900",children:["EUR ",S.toFixed(2)]})]}),y>0&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-gray-600",children:"Monthly total (net)"}),r.jsxs("span",{className:"font-bold text-green-600",children:["EUR ",y.toFixed(2),"/mo"]})]})]})]})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Selected Bundle"}),r.jsxs("div",{className:"space-y-1.5",children:[p.map((_,$)=>r.jsxs("div",{className:"flex items-center justify-between text-sm py-1 border-b border-gray-50",children:[r.jsxs("span",{className:"text-gray-600 truncate flex-1 mr-2",children:[tl[_.category].icon," ",_.name,_.quantity>1&&r.jsxs("span",{className:"text-gray-400",children:[" x",_.quantity]})]}),r.jsxs("span",{className:"font-medium whitespace-nowrap",children:["EUR ",(parseFloat(_.price)*_.quantity).toFixed(2),_.type==="recurring"&&r.jsx("span",{className:"text-green-600 text-xs",children:"/mo"})]})]},$)),p.length===0&&r.jsx("p",{className:"text-sm text-gray-400 text-center py-2",children:"No products selected"})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Computed via Library"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(K,{label:"Total Net",value:V(x.amount_subtotal)}),r.jsx(K,{label:`Tax (${s}%)`,value:V(x.amount_tax),color:"amber"}),r.jsx(K,{label:"Total Gross",value:V(x.amount_total),highlight:!0,color:"green"}),r.jsx(K,{label:"Items",value:p.length})]}),(((A=(w=(v=x.total_details)==null?void 0:v.breakdown)==null?void 0:w.recurrences)==null?void 0:A.length)??0)>0&&r.jsxs("div",{className:"mt-4",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700 mb-2",children:"By Recurrence:"}),(I=(U=(T=x.total_details)==null?void 0:T.breakdown)==null?void 0:U.recurrences)==null?void 0:I.map((_,$)=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100 text-sm",children:[r.jsx("span",{className:_.type==="one_time"?"badge-blue":"badge-green",children:_.type==="one_time"?"One-time":_.billing_period}),r.jsx("span",{className:"font-medium",children:V(_.amount_total)})]},$))]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(Qe,{title:"Usage",code:`import { computeAggregatedAndPriceTotals } from '@epilot/pricing'; + +// Non-commodity bundle: hardware + services + maintenance +const items = [ +${p.slice(0,4).map(_=>` { + quantity: ${_.quantity}, + _price: { + unit_amount_decimal: '${_.price}', + unit_amount_currency: 'EUR', + pricing_model: 'per_unit', + is_tax_inclusive: false, + type: '${_.type}',${_.billingPeriod?` + billing_period: '${_.billingPeriod}',`:""} + tax: [{ rate: ${s}, type: 'VAT' }], + description: '${_.name}', + }, + taxes: [{ tax: { rate: ${s} } }], + },`).join(` +`)}${p.length>4?` + // ... ${p.length-4} more items`:""} +]; + +const result = computeAggregatedAndPriceTotals(items); +// result.amount_total = ${V(x.amount_total)} +// Recurrence breakdown available via result.total_details.breakdown.recurrences`})})]})}function Zc(l){return"group"in l}const Jc=[{id:"overview",label:"Overview",icon:"🏠",component:Ac},{group:"Energy & Utility Use Cases",items:[{id:"electricity",label:"Electricity",icon:"⚡",component:Wp},{id:"gas",label:"Gas",icon:"🔥",component:Bp},{id:"house-connection",label:"House Connection",icon:"🏡",component:Hp},{id:"non-commodity",label:"Non-Commodity",icon:"📋",component:Qp}]},{group:"Capabilities",items:[{id:"per-unit",label:"Per Unit",icon:"📦",component:kp},{id:"tiered-volume",label:"Tiered Volume",icon:"📊",component:Ap},{id:"tiered-graduated",label:"Tiered Graduated",icon:"📈",component:Tp},{id:"tiered-flatfee",label:"Tiered Flat Fee",icon:"🏷️",component:Fp},{id:"tax",label:"Tax Handling",icon:"🧾",component:Rp},{id:"discounts",label:"Discounts & Coupons",icon:"🎟️",component:Dp},{id:"composite",label:"Composite Pricing",icon:"🧩",component:Up},{id:"recurring",label:"Recurring Billing",icon:"🔄",component:Lp},{id:"currency",label:"Currency & Formatting",icon:"💱",component:Op},{id:"dynamic-tariff",label:"Dynamic Tariff",icon:"⚡",component:zp},{id:"getag",label:"GetAG Energy",icon:"🔌",component:qp}]}];function Ip(){const l=[];for(const u of Jc)Zc(u)?l.push(...u.items):l.push(u);return l}const wc=Ip();function Kp(){var f;const[l,u]=W.useState("overview"),[s,m]=W.useState(!0),c=((f=wc.find(x=>x.id===l))==null?void 0:f.component)??Ac,h=wc.find(x=>x.id===l);return r.jsxs("div",{className:"flex h-screen overflow-hidden",children:[r.jsxs("aside",{className:`${s?"w-64":"w-0 overflow-hidden"} flex-shrink-0 bg-white border-r border-gray-200 flex flex-col transition-all duration-200`,children:[r.jsxs("div",{className:"p-4 border-b border-gray-200",children:[r.jsx("h1",{className:"text-lg font-bold text-gray-900",children:"epilot Pricing"}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Pricing Playground"})]}),r.jsx("nav",{className:"flex-1 overflow-y-auto py-2",children:Jc.map(x=>Zc(x)?r.jsxs("div",{children:[r.jsx("div",{className:"px-4 pt-4 pb-1",children:r.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400",children:x.group})}),x.items.map(p=>r.jsxs("button",{onClick:()=>u(p.id),className:`w-full text-left px-4 pl-6 py-2.5 text-sm flex items-center gap-3 transition-colors ${l===p.id?"bg-primary-50 text-primary-700 font-medium border-r-2 border-primary-600":"text-gray-600 hover:bg-gray-50 hover:text-gray-900"}`,children:[r.jsx("span",{className:"text-base",children:p.icon}),p.label]},p.id))]},x.group):r.jsxs("button",{onClick:()=>u(x.id),className:`w-full text-left px-4 py-2.5 text-sm flex items-center gap-3 transition-colors ${l===x.id?"bg-primary-50 text-primary-700 font-medium border-r-2 border-primary-600":"text-gray-600 hover:bg-gray-50 hover:text-gray-900"}`,children:[r.jsx("span",{className:"text-base",children:x.icon}),x.label]},x.id))}),r.jsxs("div",{className:"p-4 border-t border-gray-200 text-xs text-gray-400",children:[r.jsx("p",{children:"@epilot/pricing v5.4.0"}),r.jsxs("p",{className:"mt-1",children:["Made with love by ",r.jsx("a",{href:"https://github.com/jpinho",target:"_blank",rel:"noopener noreferrer",className:"text-primary-600 hover:underline",children:"@jpinho"})]})]})]}),r.jsxs("main",{className:"flex-1 overflow-y-auto",children:[r.jsxs("div",{className:"sticky top-0 z-10 bg-white/80 backdrop-blur-sm border-b border-gray-200 px-6 py-3 flex items-center gap-3",children:[r.jsx("button",{onClick:()=>m(!s),className:"p-1.5 rounded-lg hover:bg-gray-100 text-gray-500",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r.jsxs("h2",{className:"text-sm font-semibold text-gray-700",children:[h==null?void 0:h.icon," ",h==null?void 0:h.label]})]}),r.jsx("div",{className:"p-6 max-w-6xl mx-auto",children:r.jsx(c,{onNavigate:u})})]})]})}of.createRoot(document.getElementById("root")).render(r.jsx(Jm.StrictMode,{children:r.jsx(Kp,{})})); diff --git a/static/pricing-playground/index.html b/static/pricing-playground/index.html new file mode 100644 index 00000000..0d836371 --- /dev/null +++ b/static/pricing-playground/index.html @@ -0,0 +1,14 @@ + + + + + + epilot Pricing Playground + + + + + +
+ +