@shadowclone/cli 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/PRIVACY.md +1 -1
  2. package/README.md +32 -29
  3. package/dist/_.._/web/client/index.html +30 -45
  4. package/dist/shadowclone.js +1198 -527
  5. package/dist/web/index-25g5ahxa.css +1 -0
  6. package/dist/web/index-s4mjwgw0.js +134 -0
  7. package/evals.md +117 -267
  8. package/package.json +10 -10
  9. package/plugins/shadowclone/.claude-plugin/plugin.json +1 -1
  10. package/plugins/shadowclone/.codex-plugin/plugin.json +1 -1
  11. package/plugins/shadowclone/plugin.json +1 -1
  12. package/skills/choose-by-consequence/SKILL.md +66 -0
  13. package/skills/design-deep-modules/SKILL.md +32 -13
  14. package/skills/diagnose-before-editing/SKILL.md +38 -15
  15. package/skills/plan-with-review-page/SKILL.md +73 -0
  16. package/skills/plan-with-review-page/assets/review-page.html +160 -0
  17. package/skills/plan-with-review-page/scripts/validate-page.mjs +158 -0
  18. package/skills/research-primary-sources/SKILL.md +32 -12
  19. package/skills/resolve-conflicts-by-intent/SKILL.md +34 -13
  20. package/skills/scope-confirmed-changes/SKILL.md +44 -12
  21. package/skills/shadowclone-work/SKILL.md +29 -20
  22. package/skills/tests-that-catch-bugs/SKILL.md +73 -0
  23. package/skills/typescript-type-safety/SKILL.md +32 -14
  24. package/skills/verify-and-review/SKILL.md +40 -14
  25. package/skills/verify-review-findings/SKILL.md +59 -0
  26. package/skills/write-plain-english/SKILL.md +58 -0
  27. package/skills/write-plain-english/scripts/check-ste.mjs +200 -0
  28. package/dist/web/index-dzztba9n.css +0 -1
  29. package/dist/web/index-s1e5043w.js +0 -134
  30. package/skills/prove-regression-tests/SKILL.md +0 -31
  31. package/skills/testing-first/SKILL.md +0 -33
  32. package/skills/testing-risk-based/SKILL.md +0 -32
@@ -0,0 +1 @@
1
+ :root{--buncss-light: ;--buncss-dark:initial;color-scheme:dark;color:#e5e4ed;--muted:#929bb3;--accent:#b6a2ee;--line:#303246;--surface:#171923;background:#090a10;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-size:15px}*{box-sizing:border-box}body{background:radial-gradient(at 50% 45%,#291d3c5c,#0000 65%);min-height:100vh;margin:0;padding:28px 24px}button,input,select,textarea{font:inherit}button,select{cursor:pointer}button{border:0}button:disabled{cursor:wait;opacity:.5}button,a,input,textarea,select{outline-offset:5px}:focus-visible{outline:2px solid var(--accent)}button,a{-webkit-tap-highlight-color:transparent}[hidden]{display:none!important}.frame{overflow:clip;background:#10121b;border:1px solid #373043;border-radius:20px;max-width:1680px;margin:0 auto;box-shadow:0 24px 100px #0008,0 0 100px #9b71d208}.masthead{border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items: center;padding:18px 32px}.brand{display:inline-flex;color:inherit;text-decoration:none;align-items: center;gap:9px;font-weight:650}.brand-mark{filter:drop-shadow(0 0 8px #c0a0ff33);width:28px;height:28px}.local-badge{letter-spacing:.12em;color:var(--muted);font-size:10px}.local-badge span{display:inline-block;background:#8dd0bd;border-radius:50%;width:6px;height:6px;margin-right:6px}main{padding:32px 36px 0}.eyebrow{letter-spacing:.22em;color:var(--accent);margin:0 0 12px;font-size:10px;font-weight:650}h1,h2{font-family:Georgia,Times New Roman,serif;font-weight:400}h1{letter-spacing:-.035em;margin:0 0 12px;font-size:clamp(30px,4vw,44px)}h2{letter-spacing:-.02em;margin:0;font-size:28px}.subtitle{color:var(--muted);margin:0;line-height:1.6}.toolbar{display:flex;align-items: end;gap:14px;margin-top:24px}.scope-field{display:grid;letter-spacing:.04em;color:var(--muted);gap:7px;font-size:10px}.scope-field select{appearance:none;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNCIgaGVpZ2h0PSIxNCIgdmlld0JveD0iMCAwIDE0IDE0IiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJtMyA1IDQgNCA0LTQiIHN0cm9rZT0iI2I3YWVjOSIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K);background-position:right 14px center;background-repeat:no-repeat;min-width:200px;padding-right:40px}input,select,textarea{color:#e5e4ed;border:1px solid var(--line);background-color:#12141f;border-radius:7px;padding:10px 12px;font-size:13px}textarea{resize:vertical;width:100%;line-height:1.6}input::placeholder,textarea::placeholder{color:#747c93}.search-field{flex:1}.search-field input{width:100%}.quiet-button{color:#bec3d4;background:0 0;border-radius:7px;padding:11px 12px;font-size:13px}.quiet-button:hover{color:#fff;background:#222533}.primary-button{color:#181323;background:linear-gradient(145deg,#c3acf5,#aa8dde);border:1px solid #dcc9ff4d;border-radius:8px;padding:14px 22px;transition:box-shadow .2s,transform .2s,background .2s;font-size:13px;font-weight:650;box-shadow:0 3px 20px #b997ec1f,inset 0 1px #f1e6ff30}.primary-button:hover{background:linear-gradient(145deg,#d3c0ff,#b79ae9);transform:translateY(-1px);box-shadow:0 0 26px #ba95f23b}.primary-button span{margin-left:16px}.scope-note{color:var(--muted);min-height:17px;margin:0;font-size:12px;line-height:1.6}.notice{color:#e1d4ab;background:#27231b;border:1px solid #796c44;border-radius:8px;margin-top:20px;padding:12px 16px;font-size:13px;line-height:1.6}.notice.success{color:#abdacb;background:#132722;border-color:#33594d}.visually-hidden{position:absolute;overflow:hidden;clip-path:inset(50%);width:1px;height:1px}.footer{display:flex;border-top:1px solid var(--line);position:sticky;z-index:4;backdrop-filter:blur(18px);background:#171824ed;justify-content:space-between;align-items: center;gap:20px;padding:20px 32px;bottom:0;box-shadow:0 -12px 30px #0b0c1326}.footer strong{font-size:14px;font-weight:600}.footer p{color:var(--muted);margin:8px 0 0;font-size:12px}.footer-actions{display:flex;align-items: center;gap:12px}@media (width<=720px){body{padding:12px}main{padding:26px 18px 0}.masthead,.footer{padding:18px}.toolbar{flex-wrap:wrap}.scope-field,.scope-field select{width:100%}.footer{align-items: flex-start}.footer-actions{flex-direction:column-reverse;align-items: flex-end}.local-badge{font-size:9px}}@media (prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}.workspace{display:grid;grid-template-columns:minmax(0,1fr)290px;align-items: start;gap:32px;margin:28px 0}.constellation{position:relative;overflow:hidden;background:radial-gradient(circle at 50% 100%,#29203a99,#11131c 68%);border:1px solid #2c2a3a;border-radius:16px;min-width:0;min-height:360px}.constellation-controls{position:absolute;z-index:3;display:flex;gap:6px;top:12px;right:12px}.constellation-controls .quiet-button{background:#151723e8;padding:7px 10px;font-size:11px}.constellation-status{position:absolute;z-index:4;color:#d4d7e3;text-align:center;background:#151723;border:1px solid #423a50;border-radius:12px;width:min(280px,85%);padding:18px;top:40%;left:50%;transform:translate(-50%,-50%)}.constellation-status p{margin:0 0 12px}.constellation-map{position:relative;z-index:1;display:block;width:100%;margin-top:36px}.map-link{fill:none;stroke:#76668f;stroke-width:1;opacity:.62}.map-link.sibling{stroke-dasharray:2 6;opacity:.4}.map-node{color:#b1a7c6;outline:none}.map-node-skill{cursor:pointer}.map-node-hit{fill:transparent;stroke:none;rx:12px}.map-node-gem,.map-node circle{fill:#171824;stroke:#645474;stroke-width:1;transition:fill .16s,stroke .16s,opacity .16s}.map-node text{fill:#d4d7e3;paint-order:stroke;stroke:#10121b;stroke-width:5px;stroke-linejoin:round;font:13px Inter,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif}.map-node-source text{fill:#cebaf5;letter-spacing:.02em;font-size:14px;font-weight:650}.map-node-category text{fill:#b9abd6;font-weight:600}.map-node-source .map-node-gem{fill:#211b2f;stroke:#a88cda}.map-node-category .map-node-gem{fill:#1b1a28;stroke:#8b75ae}.map-node-root circle{fill:#332647;stroke:#c1a5ee;stroke-width:1.5}.map-node-root image{pointer-events:none}.map-node-skill:hover .map-node-gem{fill:#382c4c;stroke:#d0b8ff;stroke-width:2}.map-node-skill:focus-visible .map-node-gem{fill:#382c4c;stroke:#d0b8ff;stroke-width:2}.map-node-skill.active .map-node-hit{stroke:#8dd0bd;stroke-width:1.5}.map-node-skill:focus-visible .map-node-hit{stroke:#8dd0bd;stroke-width:1.5}.map-node-skill.active text{fill:#f2eaff}.map-node.equipped .map-node-gem{fill:#544268;stroke:#ceb8ff;filter:drop-shadow(0 0 10px #b78cf766)}.map-node.search-miss{opacity:.16}.map-node-icon{display:grid;color:#c7b5ef;place-items: center;width:18px;height:18px}.map-node-icon svg{width:17px;height:17px}.constellation-list{position:relative;z-index:2;display:none;padding:56px 20px 20px}.list-view .constellation-map,.list-view .tree-hint{display:none}.list-view .constellation-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));align-content: start;gap:20px}.skill-list-group h3{color:#c9b2f1;letter-spacing:.08em;text-transform:uppercase;margin:0 0 9px;font-size:12px}.skill-list-item{display:block;color:#cfd3df;text-align:left;background:0 0;border-left:1px solid #423a50;width:100%;padding:8px 10px}.skill-list-item:hover,.skill-list-item:focus,.skill-list-item.equipped{color:#f2eaff;background:#241e30;border-left-color:#b999ed}.tree-hint{position:relative;z-index:2;color:var(--muted);text-align:center;pointer-events:none;margin:0 0 14px;font-size:11px}@media (width<=900px){.workspace{grid-template-columns:minmax(0,1fr)270px;gap:20px}}@media (width<=720px){.workspace{grid-template-columns:1fr}.constellation-map,.tree-hint{display:none}.constellation-list{display:grid;grid-template-columns:1fr;align-content: start;gap:20px}.constellation-controls{display:none}}.detail{position:sticky;background:linear-gradient(150deg,#1d1b2a,#151720 55%);border:1px solid #53446799;border-radius:14px;padding:24px;top:24px;box-shadow:0 12px 40px #0003,inset 0 1px #d2b9ff0a}.detail h2{font-size:26px;line-height:1.2}.detail-description{color:#a5afc5;display:-webkit-box;-webkit-line-clamp:3;overflow:hidden;-webkit-box-orient:vertical;margin:14px 0 24px;font-size:13px;line-height:1.7}.behavior{border-top:1px solid var(--line);border-bottom:1px solid var(--line);padding:21px 0}.behavior p:last-child{color:#c3c5d0;white-space:pre-line;margin:0;font-size:13px;line-height:1.7}.skill-status{color:#8fcaba;margin:18px 0;font-size:11px;line-height:1.6}.detail .primary-button{width:100%}.detail .editor{margin-top:20px}.detail summary{color:#bdb5d2;cursor:pointer;font-size:12px}.detail textarea{min-height:200px;margin-top:12px;font:11px/1.65 ui-monospace,monospace}.detail .quiet-button{width:100%;margin-top:8px}.owner-note{color:var(--muted);font-size:11px;line-height:1.6}.identity{display:flex;border-top:1px solid #292b3d;justify-content:space-between;align-items: center;gap:24px;padding:26px 0}.identity h2{font-size:26px}.identity p:last-child{color:var(--muted);max-width:580px;margin-bottom:0;font-size:12px;line-height:1.7}.requirements{border:1px solid var(--line);background:#141824;border-radius:10px;margin:0 0 22px;padding:18px}.requirements h3{color:#b6c4d4;margin:0 0 10px;font-size:12px}.requirements p{color:var(--muted);margin:7px 0 0;font-size:12px;line-height:1.6}dialog{color:#e5e4ed;background:#151720;border:1px solid #414258;border-radius:18px;width:min(780px,100vw - 40px);max-height:88vh;padding:28px;box-shadow:0 35px 120px #0008}dialog::backdrop{backdrop-filter:blur(4px);background:#06070be3}.dialog-heading{display:flex;justify-content:space-between;align-items: flex-start;gap:20px;margin-bottom:25px}.dialog-heading .quiet-button{margin-top:-8px}.dialog-actions{display:flex;justify-content:flex-end;gap:12px;margin-top:24px}#review-content{overflow:auto;max-height:52vh}.file-change{border:1px solid var(--line);border-radius:8px;margin:12px 0;padding:14px}.file-change summary{cursor:pointer;color:#c7b8e8;overflow-wrap:anywhere;font-size:12px}.file-change h4{text-transform:uppercase;letter-spacing:.12em;color:var(--muted);margin-bottom:8px;font-size:10px}.file-change pre{white-space:pre-wrap;overflow-wrap:anywhere;background:#0e1119;border-radius:5px;padding:14px;font:11px/1.6 ui-monospace,monospace}.file-change p,.review-message{color:#a3adc2;font-size:12px;line-height:1.7}.review-warning{color:#dac895;font-size:12px;line-height:1.7}form label{display:grid;color:#bbc3d7;gap:9px;margin-top:20px;font-size:12px}@media (width<=720px){.detail{position:static}.identity{display:block}dialog{padding:20px}}.bot-dialog{overflow-y:auto;width:min(48rem,100vw - 3rem);max-height:calc(100vh - 3rem)}.bot-dialog .field{display:grid;gap:.4rem;margin:1rem 0}.bot-dialog details{margin:.7rem 0}.bot-dialog pre{white-space:pre-wrap;overflow-wrap:anywhere}.bot-dialog .bot-consent{display:block;margin:1.3rem 0}.bot-dialog .bot-actions{display:block;margin:1rem 0}.voice-dialog{overflow-y:auto;width:min(48rem,100vw - 3rem);max-height:calc(100vh - 3rem)}.voice-dialog .voice-consent{display:block;margin:1rem 0}.voice-dialog .voice-file,.voice-dialog .voice-source{color:var(--muted);font-size:12px}.voice-dialog fieldset{display:grid;border:1px solid var(--line);border-radius:10px;gap:6px;margin:14px 0;padding:12px}.voice-dialog legend{color:#cebaf5;padding:0 6px;font-size:12px}.voice-dialog pre{font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;background:#141824;border-radius:8px;padding:12px}.constellation{isolation:isolate}.constellation:before{content:"";position:absolute;pointer-events:none;z-index:-1;filter:blur(15px);background:radial-gradient(at 53% 72%,#be85f13d 0%,#0000 42%),radial-gradient(at 28% 52%,#8060c32b 0%,#0000 48%),radial-gradient(at 74% 41%,#59699b1f 0%,#0000 42%),radial-gradient(at 53% 57%,#7c47822e 0%,#0000 65%);inset:30px -35px 5px}.tree-root img{filter:drop-shadow(0 0 7px #bca1f38c);width:31px;height:31px}.tree-root span:before{content:"";position:absolute;border:1px solid #b19bdf26;border-radius:50%;inset:-9px;box-shadow:0 0 35px #be85f12e}.tree-root span{box-shadow:0 0 22px #c7a1ff40,0 0 75px #a776de26}.skill-node:hover .node-gem,.skill-node.active .node-gem{box-shadow:0 0 18px #c7a8fa33,0 0 55px #9773d92b}.skill-node.equipped .node-gem{box-shadow:0 0 16px #c7a8fa38,0 0 40px #a776de38,inset 0 0 12px #c7a8fa0d}.skill-node.equipped .node-icon{filter:drop-shadow(0 0 4px #d6bfff66)}.skill-node.equipped:after{box-shadow:0 0 10px #ceadff99}.scope-meta{display:flex;justify-content:space-between;align-items: start;gap:16px;margin-top:12px}.library-note{text-align:right;color:var(--muted);max-width:270px;font-size:11px;line-height:1.6}.library-note summary{cursor:pointer;color:#a799c3}.library-note p{margin:8px 0}.library-note code{display:block;color:#c8b4f0;font-size:10px}@media (width<=720px){.scope-meta{display:block}.library-note{text-align:left;margin-top:8px}}.starfield{position:absolute;pointer-events:none;z-index:-1;overflow:hidden;width:100%;height:100%;inset:0}.star{fill:#e6d6ff;opacity:0;animation:star-twinkle var(--twinkle)ease-in-out var(--delay)infinite,star-drift var(--drift)ease-in-out var(--delay)infinite alternate}.star-rays{stroke:#eadbff;stroke-width:.55;opacity:.75}.shooting-star{stroke:#f4ecff;stroke-width:1.4;stroke-linecap:round;stroke-dasharray:var(--length)2000px;stroke-dashoffset:var(--length);animation:shooting-star var(--shoot)ease-in forwards}.starfield.paused .star,.starfield.paused .shooting-star{animation-play-state:paused}@keyframes star-twinkle{0%,to{opacity:calc(var(--brightness)*.25)}50%{opacity:var(--brightness)}}@keyframes star-drift{0%{translate:0}to{translate:var(--drift-x)var(--drift-y)}}@keyframes shooting-star{0%{opacity:0}15%{opacity:.9}to{opacity:0;stroke-dashoffset:calc(-1*var(--travel))}}@media (prefers-reduced-motion:reduce){.star{animation:none;opacity:calc(var(--brightness)*.7);translate:none}.shooting-star{display:none}}.build-panel{position:sticky;display:grid;overflow:auto;scrollbar-width:thin;scrollbar-color:#4d3d65 transparent;gap:16px;max-height:calc(100dvh - 140px);margin:-3px;padding:3px;top:20px}.build-panel .identity{display:block;background:linear-gradient(145deg,#221c30,#14151f 80%);border:1px solid #44364f;border-radius:14px;padding:22px}.build-panel .identity h2{font-size:25px}.build-panel #identity-description{color:var(--muted);font-size:12px;line-height:1.65}.identity[data-naming=waiting] #identity-title,.identity[data-naming=loading] #identity-title{color:#8f84a8}.identity[data-naming=loading] #identity-description{animation:1.4s ease-in-out infinite naming-pulse}.identity[data-naming=failed] #identity-description{color:#f0b6b6}@keyframes naming-pulse{50%{opacity:.45}}.abilities{display:grid;list-style:none;gap:8px;margin:14px 0 0;padding:0}.abilities:empty{display:none}.abilities li{color:#cfd3df;font-size:12px;line-height:1.5}.abilities strong{display:block;color:#cebaf5;letter-spacing:.04em;font-size:11px}.build-panel .tradeoff{color:#d9c79a;margin:12px 0 0;font-size:12px;line-height:1.5}.naming-controls{display:flex;flex-wrap:wrap;align-items: center;gap:8px;margin-top:16px}.naming-controls .naming-source{color:var(--muted);flex:100%;margin:0;font-size:11px}.naming-controls .naming-source:empty{display:none}.naming-controls .quiet-button{padding:7px 10px;font-size:11px}@media (prefers-reduced-motion:reduce){.identity[data-naming=loading] #identity-description{animation:none}}.build-panel .detail{position:static}@media (width<=720px){.build-panel{position:static;overflow:visible;max-height:none}}
@@ -0,0 +1,134 @@
1
+ function Be(e){let t=Object.values(e).filter((n)=>typeof n==="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Gt(e,t="|"){return e.map((r)=>Ht(r)).join(t)}function Fe(e,t){if(typeof t==="bigint")return t.toString();return t}class cn{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function st(e){return new cn(e)}function un(e){return e===null||e===void 0}function at(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ln(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-n)<o)return 0;return r-n}function ee(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ct(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ue(e){return ct(e._zod.def)??e._zod.def.shape}function dn(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return ee(this,t,n),n},enumerable:!0,configurable:!0})}function pn(e,t,r){if(t in e)ee(e,t,r);else e[t]=r}function ve(e,t,r,n){let o=ue(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)dn(e,i,()=>{let a=t._zod.def.shape[i];return n?n(a,i):a});else pn(e,i,n?n(s.value,i):s.value)}}function $c(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)dn(e,r,()=>t[r]);else pn(e,r,n.value)}}function K(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function fn(e){return JSON.stringify(e)}function mn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Kt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function je(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var hn=st(()=>{if(V.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function we(e){if(je(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(je(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Wt(e){if(we(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var gn=new Set(["string","number","symbol"]);function Ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oe(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function v(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Ht(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function yn(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var ut=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Yt={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Sc(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return ve(i,e,lt(e,t)),oe(e,K(r,{shape:i,checks:[]}))}function lt(e,t){let r=ue(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(t[o])n.push(o)}return n}function Pc(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(lt(e,t)),s={};return ve(s,e,Reflect.ownKeys(ue(e)).filter((a)=>!i.has(a))),oe(e,K(r,{shape:s,checks:[]}))}function Zc(e,t){if(!we(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=ue(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return oe(e,K(e._zod.def,{shape:bn(e,t)}))}function bn(e,t){let r={};return ve(r,e,Reflect.ownKeys(ue(e))),$c(r,t),r}function Ic(e,t){if(!we(t))throw Error("Invalid input to safeExtend: expected a plain object");return oe(e,K(e._zod.def,{shape:bn(e,t)}))}function Oc(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ve(r,e,Reflect.ownKeys(ue(e))),ve(r,t,Reflect.ownKeys(ue(t)));let n=K(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return oe(e,n)}function xn(e,t,r,n="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(lt(t,r)):void 0,c={};return ve(c,t,Reflect.ownKeys(ue(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),oe(t,K(t._zod.def,{shape:c,checks:[]}))}function Ec(e,t,r){let n=r?new Set(lt(t,r)):void 0,o={};return ve(o,t,Reflect.ownKeys(ue(t)),(i,s)=>n&&!n.has(s)?i:new e({type:"nonoptional",innerType:i})),oe(t,K(t._zod.def,{shape:o}))}function ie(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function vn(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function he(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function De(e){return typeof e==="string"?e:e?.message}function Xt(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function se(e,t,r){var n;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(n=e).schema??(n.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:De(e.inst?._zod.def?.error?.(e))??De(i?.(e))??De(t?.error?.(e))??De(r.customError?.(e))??De(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=s,t?.reportInput)a.input=e.input;return a}var Cc=/[\uD800-\uDBFF]/;function dt(e){let t=e.length;if(!Cc.test(e))return t;let r=t;for(let n=0;n<t-1;n++)if((e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320)r--,n++;return r}function pt(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function wn(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function _e(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function _n(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else Ac(e,r,n.value)}}function le(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function ft(e,t,r){return le(e,t,r,!1)}function kn(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return le(this,r,n(this))},set(o){le(this,r,o)}})}return t}function Ac(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:le(this,t,r.bind(this))},set(n){le(this,t,n)}})}function Nc(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Jt,me=!1,Tc={configurable:!0,get(){me=!0;return}};function P(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&Jt!==e._zod){Jt=void 0;return}Jt=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Tc);let o=me;me=!1;try{let i=r(this);if(me)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i});return me=me||o,i}catch(i){throw delete this[t],me=me||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Rc(e,t,r,n){let o=Nc(e,t);if(!o)return;Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:i})}})}var Mc="~constantCatch";function zn(e){let t=()=>e;return t[Mc]=!0,t}var $n;var Qt={value:void 0,enumerable:!1},Sn="captureStackTrace"in Error?Error:null;function Lc(e){let t=Sn;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return Sn=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function f(e,t,r,n){let o={};function i(p){this.def=p,this.constr=d,this.traits=new Set}i.prototype=o;let s=r,a=s&&new WeakSet;function c(p,h){if(!p._zod){Qt.value=new i(h);try{Object.defineProperty(p,"_zod",Qt)}finally{Qt.value=void 0}}else if(p._zod.traits.has(e))return;if(p._zod.traits.add(e),t(p,h),a){let x=Object.getPrototypeOf(p),w=p._zod.constr.prototype,S=x;while(S&&S!==w)S=Object.getPrototypeOf(S);let z=S??x;if(!a.has(z))a.add(z),_n(z,s)}let m=d.prototype;for(let x in m){if(!Object.prototype.hasOwnProperty.call(m,x))continue;if(!(x in p))p[x]=m[x].bind(p)}}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(p){let h=n?.Parent?Lc(l):this;c(h,p);let m=h._zod.deferred;if(m){for(let w of m)w();h._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(h);return h}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(p)=>{if(n?.Parent&&p instanceof n.Parent)return!0;return p?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class ae extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ue extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}($n=globalThis).__zod_globalConfig??($n.__zod_globalConfig={});var V=globalThis.__zod_globalConfig;function W(e){if(e)Object.assign(V,e);return V}function Dc(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Fe,2)),e.message}function jc(e){this._zod.message=e}var Bc={get:Dc,set:jc,enumerable:!0,configurable:!0},tr={value:void 0,enumerable:!1},Pn=new WeakSet([Object.prototype,Error.prototype]),Zn=(e,t)=>{e.name="$ZodError",tr.value=t,Object.defineProperty(e,"issues",tr),tr.value=void 0,Object.defineProperty(e,"message",Bc);let r=Object.getPrototypeOf(e);if(!Pn.has(r))Pn.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}})},In=f("$ZodError",Zn),Ed=f("$ZodError",Zn,void 0,{Parent:Error});function Fc(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function On(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)Fc(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function En(e,t=(r)=>r.message){let r={_errors:[]},n=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>n({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;while(u<a.length){let l=a[u],d=u===a.length-1;if(l==="_errors"){if(d)c._errors.push(t(s));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=c[l];if(d)p._errors.push(t(s));c=p,u++}}}};return n(e),r}function mt(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ht=(e)=>{let t=(r,n,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new ae;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>se(u,s,W())));throw Kt(c,i?.callee??t),c}return a.value};return t};var gt=(e)=>{let t=async(r,n,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>se(u,s,W())));throw Kt(c,i?.callee??t),c}return a.value};return t};var yt=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new ae;return i.issues.length?Cn(e,i.issues,o):{success:!0,data:i.value}};function Cn(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>se(o,r,W()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var bt=(e)=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?Cn(e,i.issues,o):{success:!0,data:i.value}};var Uc=Symbol.for("zod.compile.invalid"),qc=Symbol.for("zod.compile.fallback"),rr=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Uc)return!0;if(n.definite===!0&&r===void 0)return!1}return Vc(e,t,r)};function Vc(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)n[qc]=!0,i=o({value:t,issues:[]},n);else i=e._zod.run({value:t,issues:[]},n);if(i instanceof Promise)throw new ae;return i.issues.length===0}var nr=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);if(o instanceof Promise)o=await o;return o.issues.length===0},An=(e)=>{let t=ht(e),r=(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(n,o,a,mt(r,s))};return r};var Nn=(e)=>{let t=ht(e),r=(n,o,i,s)=>t(n,o,i,mt(r,s));return r};var Tn=(e)=>{let t=gt(e),r=async(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(n,o,a,mt(r,s))};return r};var Rn=(e)=>{let t=gt(e),r=async(n,o,i,s)=>await t(n,o,i,mt(r,s));return r};var Mn=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return yt(e)(t,r,o)};var Ln=(e)=>(t,r,n)=>yt(e)(t,r,n);var Dn=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return bt(e)(t,r,o)};var jn=(e)=>async(t,r,n)=>bt(e)(t,r,n);var Bn=/^[cC][0-9a-z]{6,}$/,Fn=/^[0-9a-z]+$/,Un=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,qn=/^[0-9a-vA-V]{20}$/,Vn=/^[A-Za-z0-9]{27}$/,Jn=/^[a-zA-Z0-9_-]{21}$/;function Gn(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Kn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Wn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ir=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Hn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Jc="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Yn(){return new RegExp(Jc,"u")}var Xn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Qn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var eo=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,to=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ro=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,no=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var oo=/^https?$/,io=/^\+[1-9]\d{6,14}$/;var so="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Gc(e){return new RegExp(`^${e}$`)}var ao=Gc(so);function or(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function co(e){return new RegExp(`^${or(e)}$`)}function uo(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${or({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${or({precision:e.precision})}`:r;return new RegExp(`^${so}T(?:${n})$`)}var lo=/^[\s\S]{0,}$/;var sr=/^-?\d+$/,qe=/^-?\d+(?:\.\d+)?$/,po=/^(?:true|false)$/i;var fo=/^[^A-Z]*$/,mo=/^[^a-z]*$/;var j=f("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var ar=(e)=>{let t=e.value;return!un(t)&&t.length!==void 0},xt={number:"number",bigint:"bigint",object:"date"},cr=f("$ZodCheckLessThan",(e,t)=>{j.init(e,t);let r=xt[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:xt[typeof n.value]??r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ur=f("$ZodCheckGreaterThan",(e,t)=>{j.init(e,t);let r=xt[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:xt[typeof n.value]??r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ho=f("$ZodCheckMultipleOf",(e,t)=>{j.init(e,t),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):ln(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),go=f("$ZodCheckNumberFormat",(e,t)=>{j.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=ut[t.format];e._zod.check=(s)=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(a<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var yo=f("$ZodCheckMaxLength",(e,t)=>{var r;j.init(e,t),(r=e._zod.def).when??(r.when=ar),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>t.maximum?dt(o):i)<=t.maximum)return;let a=pt(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),bo=f("$ZodCheckMinLength",(e,t)=>{var r;j.init(e,t),(r=e._zod.def).when??(r.when=ar),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>=t.minimum&&i<t.minimum*2?dt(o):i)>=t.minimum)return;let a=pt(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),xo=f("$ZodCheckLengthEquals",(e,t)=>{var r;j.init(e,t),(r=e._zod.def).when??(r.when=ar),e._zod.check=(n)=>{let o=n.value,i=o.length,s=typeof o==="string"&&i>=t.length&&i<=t.length*2?dt(o):i;if(s===t.length)return;let a=pt(o),c=s>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Je=f("$ZodCheckStringFormat",(e,t)=>{var r,n;if(j.init(e,t),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),vo=f("$ZodCheckRegex",(e,t)=>{Je.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),wo=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=fo),Je.init(e,t)}),_o=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=mo),Je.init(e,t)}),ko=f("$ZodCheckIncludes",(e,t)=>{j.init(e,t);let r=Ze(t.includes),n=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),zo=f("$ZodCheckStartsWith",(e,t)=>{j.init(e,t);let r=new RegExp(`^${Ze(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$o=f("$ZodCheckEndsWith",(e,t)=>{j.init(e,t);let r=new RegExp(`.*${Ze(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var So=f("$ZodCheckOverwrite",(e,t)=>{j.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class lr{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
2
+ `).filter((i)=>i),n=Math.min(...r.map((i)=>i.length-i.trimStart().length)),o=r.map((i)=>i.slice(n)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
3
+ ${t.join(`
4
+ `)}
5
+ };`)(...Object.values(this.closed))}}var Zo={major:4,minor:6,patch:5};var N=f("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Zo;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=ie(a),d;for(let p of c){if(p._zod.def.when){if(vn(a))continue;if(!p._zod.def.when(a))continue}else if(l)continue;let h=a.issues.length,m=p._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new ae;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await m,a.issues.length===h)return;if(Xt(a.issues,h,e),!l)l=ie(a,h)});else{if(a.issues.length===h)continue;if(Xt(a.issues,h,e),!l)l=ie(a,h)}}if(d)return d.then(()=>a);return a},s=(a,c,u)=>{if(ie(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ae;return l.then((d)=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((d)=>s(d,a,c));return s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ae;return u.then((l)=>i(l,o,c))}return i(u,o,c)}}},{get "~standard"(){return ft(this,"~standard",pr(this))},set "~standard"(e){le(this,"~standard",e)}}),Do=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>se(r,t,W()))}:{value:e.value};async function Kc(e,t){let r={async:!0};return Do(await e._zod.run({value:t,issues:[]},r),r)}function pr(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Do(n,r)}catch(n){}return Kc(e,t)},vendor:"zod",version:1}}var kt=f("$ZodString",(e,t)=>{N.init(e,t),e._zod.pattern=t.pattern??lo,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),C=f("$ZodStringFormat",(e,t)=>{Je.init(e,t),kt.init(e,t)}),jo=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Wn),C.init(e,t)}),Bo=f("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ir(n))}else t.pattern??(t.pattern=ir());C.init(e,t)}),Fo=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Hn),C.init(e,t)}),Uo=1,wt=2;function qo(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Wc(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return qo(e)||wt;return Hc(e,t)}function Hc(e,t){if(!t.normalize&&t.protocol?.source===oo.source&&!/^https?:\/\//i.test(e))return Uo;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??wt}return new URL(e)}catch{return wt}}var Yc=/[\t\n\r]/g;function Io(e){return e.replace(Yc,"")}function Xc(e,t){return t.lastIndex=0,t.test(e.hostname)}function Qc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Vo=f("$ZodURL",(e,t)=>{C.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=Wc(n,t);if(o===Uo){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===wt){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Io(n);return}if(t.hostname&&!Xc(o,t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!Qc(o,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?o.href:Io(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Jo=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Yn()),C.init(e,t)}),Go=f("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Jn:Gn(t.length)),C.init(e,t)}),Ko=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Bn),C.init(e,t)}),Wo=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Fn),C.init(e,t)}),Ho=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Un),C.init(e,t)}),Yo=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=qn),C.init(e,t)}),Xo=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Vn),C.init(e,t)}),Qo=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=uo(t)),C.init(e,t)}),ei=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ao),C.init(e,t)}),ti=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=co(t)),C.init(e,t)}),ri=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Kn),C.init(e,t)}),ni=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Xn),C.init(e,t)}),eu=/^[0-9a-fA-F:.]+$/;function oi(e){if(!eu.test(e))return!1;return qo(`http://[${e}]`)}var ii=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Qn),C.init(e,t),e._zod.check=(r)=>{if(!oi(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var si=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=eo),C.init(e,t)});function tu(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);if(`${o}`!==n)return!1;if(o<0||o>128)return!1;return oi(r)}var ai=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=to),C.init(e,t),e._zod.check=(r)=>{if(!tu(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function ci(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var fr=/^[0-9a-zA-Z+/]*={0,2}$/,ui=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=fr),C.init(e,t),e._zod.check=(r)=>{if(ci(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),zt=/^[A-Za-z0-9_-]*$/;function ru(e){if(!zt.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return ci(r)}var li=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=zt),C.init(e,t),e._zod.check=(r)=>{if(ru(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),di=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=io),C.init(e,t)});function nu(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var pi=f("$ZodJWT",(e,t)=>{C.init(e,t),e._zod.check=(r)=>{if(nu(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var mr=f("$ZodNumber",(e,t)=>{N.init(e,t),e._zod.pattern=qe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let o=r.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),fi=f("$ZodNumberFormat",(e,t)=>{go.init(e,t),mr.init(e,t)}),mi=f("$ZodBoolean",(e,t)=>{N.init(e,t),e._zod.pattern=po,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let o=r.value;if(typeof o==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var hi=f("$ZodUnknown",(e,t)=>{N.init(e,t),e._zod.parse=(r)=>r}),gi=f("$ZodNever",(e,t)=>{N.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Oo(e,t,r){if(e.issues.length)t.issues.push(...he(r,e.issues));t.value[r]=e.value}var yi=f("$ZodArray",(e,t)=>{N.init(e,t);let r=V.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=r?r.alloc(e,n,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){let u=i[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((d)=>Oo(d,n,c)));else if(Oo(l,n,c),a&&l.issues.length!==0&&ie(l))break}if(s.length)return Promise.all(s).then(()=>n);return n}});function _t(e,t,r,n,o,i){let s=r in n,a=i==="optional";if(!s&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...he(r,e.issues))}if(!s&&o===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s||o==="defaulted"&&!a)t.value[r]=void 0}else t.value[r]=e.value}var ou=[];function bi(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:ou,o=n.length?[...t,...n]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=yn(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function xi(e,t,r,n,o,i,s){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:d,optout:p}=u,h=0;for(let m in t){if(s&&r.issues.length!==h){if(ie(r,h))break;h=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(l==="never")a.push(m);continue}if(l==="never"){a.push(m);continue}let x=u.run({value:t[m],issues:[]},n);if(x instanceof Promise)e.push(x.then((w)=>_t(w,r,m,t,d,p)));else _t(x,r,m,t,d,p)}if(a.length)r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var iu=f("$ZodObject",(e,t)=>{N.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=st(()=>bi(t));P(e,"propValues",(u)=>{let l=u.def.shape,d={};for(let p in l){let h=l[p]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(d,p))ee(d,p,new Set);for(let m of h.values)d[p].add(m);if(h.optin!==void 0)d[p].add(void 0)}}return d});let i=je,s=t.catchall,a,c=V.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!i(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let p=[],h=a.shape,m=l?.abortEarly,x=u.issues.length;for(let w of a.allKeys){if(m&&u.issues.length!==x){if(ie(u,x))break;x=u.issues.length}if(w==="__proto__")continue;let S=h[w],z=S._zod.optin,A=S._zod.optout,B=S._zod.run({value:d[w],issues:[]},l);if(B instanceof Promise)p.push(B.then((I)=>_t(I,u,w,d,z,A)));else _t(B,u,w,d,z,A)}if(!s)return p.length?Promise.all(p).then(()=>u):u;return xi(p,d,u,l,o.value,e,m===!0)}}),vi=f("$ZodObjectJIT",(e,t)=>{iu.init(e,t);let r=e._zod.parse,n=st(()=>bi(t)),o=V.memoizer,i=(h)=>{let m=n.value,x=m.symbolKeys,w=new lr(["payload","ctx"],{shape:h,inst:e,memo:o,syms:x}),S=(I)=>`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`,z=(I,k)=>`
6
+ let ${I}_ab = false;
7
+ for (let i = 0; i < ${I}.issues.length; i++) {
8
+ const iss = ${I}.issues[i];
9
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
10
+ payload.issues.push(iss);
11
+ if (iss.continue !== true) ${I}_ab = true;
12
+ }
13
+ if (${I}_ab && ctx && ctx.abortEarly) {
14
+ payload.value = newResult;
15
+ return payload;
16
+ }`;w.write("const input = payload.value;");let A=Object.create(null),B=0;for(let I of m.allKeys)A[I]=`key_${B++}`;w.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let I of m.allKeys){if(I==="__proto__")continue;let k=A[I],E=typeof I==="symbol"?`syms[${x.indexOf(I)}]`:fn(I),q=`${E} in input`,be=h[I],Y=be?._zod?.optin,xe=Y!==void 0,it=be?._zod?.optout==="optional";if(w.write(`const ${k} = ${S(E)};`),xe&&it){let Le=Y==="optional"?`${k}_present`:`${k}.value !== undefined || ${k}_present`;w.write(`
17
+ const ${k}_present = ${q};
18
+ if (!${k}.issues.length || ${k}_present) {
19
+ if (${k}.issues.length) {${z(k,E)}
20
+ }
21
+
22
+ if (${Le}) {
23
+ newResult[${E}] = ${k}.value;
24
+ }
25
+ }
26
+
27
+ `)}else if(!xe)w.write(`
28
+ const ${k}_present = ${q};
29
+ if (${k}.issues.length) {${z(k,E)}
30
+ }
31
+ if (!${k}_present && !${k}.issues.length) {
32
+ payload.issues.push({
33
+ code: "invalid_type",
34
+ expected: "nonoptional",
35
+ input: undefined,
36
+ path: [${E}]
37
+ });
38
+ if (ctx && ctx.abortEarly) {
39
+ payload.value = newResult;
40
+ return payload;
41
+ }
42
+ }
43
+
44
+ if (${k}_present) {
45
+ newResult[${E}] = ${k}.value;
46
+ }
47
+
48
+ `);else if(w.write(`
49
+ if (${k}.issues.length) {${z(k,E)}
50
+ }
51
+ `),Y==="defaulted")w.write(`newResult[${E}] = ${k}.value;`);else w.write(`
52
+ if (${k}.value !== undefined || ${q}) {
53
+ newResult[${E}] = ${k}.value;
54
+ }
55
+ `)}return w.write("payload.value = newResult;"),w.write("return payload;"),w.compile()},s,a=je,c=!V.jitless,l=c&&hn.value,d=t.catchall,p;e._zod.parse=(h,m)=>{p??(p=n.value);let x=h.value;if(!a(x))return h.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),h;if(c&&l&&m?.async===!1&&m.jitless!==!0){if(!s)s=i(t.shape);if(h=s(h,m),!d)return h;return xi([],x,h,m,p,e,m?.abortEarly===!0)}return r(h,m)}});function Eo(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter((i)=>!ie(i));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>se(s,n,W())))}),t}var wi=f("$ZodUnion",(e,t)=>{N.init(e,t),P(e,"optin",(n)=>n.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),P(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),P(e,"values",(n)=>{if(n.def.options.every((o)=>o._zod.values))return new Set(n.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),P(e,"pattern",(n)=>{if(n.def.options.every((o)=>o._zod.pattern)){let o=n.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>at(i.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return Eo(s,n,e,o);return Promise.all(s).then((a)=>Eo(a,n,e,o))}});var _i=f("$ZodIntersection",(e,t)=>{N.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Co(r,c,u));return Co(r,i,s)}});function dr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(we(e)&&we(t)){let r=Object.keys(t),n=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of n){if(i==="__proto__")continue;let s=dr(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],s=dr(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Co(e,t,r){let n=new Map,o,i=new Map,s=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let p=String(u.path[0]);if(!i.has(p))i.set(p,u);d=[p]}else return!1;for(let p of d){if(!n.has(p))n.set(p,{});n.get(p)[l]=!0}return!0};for(let u of t.issues)if(!s(u,"l"))e.issues.push(u);for(let u of r.issues)if(!s(u,"r"))e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&i.has(l))e.issues.push(i.get(l))}let c=dr(t.value,r.value);if(!c.valid){if(ie(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var ki=f("$ZodRecord",(e,t)=>{N.init(e,t);let r=V.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!we(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((m)=>se(m,o,W())),input:l,path:[l],inst:e});continue}let p=d.value;if(p==="__proto__")continue;let h=t.valueType._zod.run({value:i[l],issues:[]},o);if(h instanceof Promise)s.push(h.then((m)=>{if(m.issues.length)n.issues.push(...he(l,m.issues));n.value[p]=m.value}));else{if(h.issues.length)n.issues.push(...he(l,h.issues));n.value[p]=h.value}}let u;for(let l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=i[l]}else u=u??[],u.push(l);if(u&&u.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&qe.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)l=m}if(l.issues.length){if(t.mode==="loose")n.value[u]=i[u];else if(a)c=c??[],c.push(u);else n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((m)=>se(m,o,W())),input:u,path:[u],inst:e});continue}let p=l.value;if(p==="__proto__")continue;let h=t.valueType._zod.run({value:i[u],issues:[]},o);if(h instanceof Promise)s.push(h.then((m)=>{if(m.issues.length)n.issues.push(...he(u,m.issues));n.value[p]=m.value}));else{if(h.issues.length)n.issues.push(...he(u,h.issues));n.value[p]=h.value}}if(c&&c.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>n);return n}});var zi=f("$ZodEnum",(e,t)=>{N.init(e,t);let r=Be(t.entries),n=new Set(r);e._zod.values=n,P(e,"pattern",(o)=>{let i=Be(o.def.entries).filter((s)=>gn.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>Ze(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(n.has(s))return o;return o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}});var $i=f("$ZodTransform",(e,t)=>{N.init(e,t),e._zod.optin="optional",V.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ue(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(r.value=s,r));if(o instanceof Promise)throw new ae;return r.value=o,r}});function Ao(e,t){return e.value=t.issues.length?void 0:t.value,e}var hr=f("$ZodOptional",(e,t)=>{N.init(e,t),P(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",P(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),P(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${at(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((i)=>Ao(r,i));return Ao(r,o)}return t.innerType._zod.run(r,n)}}),Si=f("$ZodExactOptional",(e,t)=>{hr.init(e,t),P(e,"values",(r)=>r.def.innerType._zod.values),P(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Pi=f("$ZodNullable",(e,t)=>{N.init(e,t),P(e,"optin",(r)=>r.def.innerType._zod.optin),P(e,"optout",(r)=>r.def.innerType._zod.optout),P(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${at(n.source)}|null)$`):void 0}),P(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),Zi=f("$ZodDefault",(e,t)=>{N.init(e,t),e._zod.optin="defaulted",P(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>No(i,t));return No(o,t)}});function No(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Ii=f("$ZodPrefault",(e,t)=>{N.init(e,t),e._zod.optin="defaulted",P(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),Oi=f("$ZodNonOptional",(e,t)=>{N.init(e,t),P(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>To(i,e));return To(o,e)}});function To(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Ro(e,t,r,n){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>se(o,n,W()))},input:e.value}),e}var Ei=f("$ZodCatch",(e,t)=>{N.init(e,t),P(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),P(e,"optout",(r)=>r.def.innerType._zod.optout),P(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((i)=>Ro(r,i,t,n));return Ro(r,o,t,n)}});var Ci=f("$ZodPipe",(e,t)=>{N.init(e,t),P(e,"values",(r)=>r.def.in._zod.values),P(e,"optin",(r)=>r.def.in._zod.optin),P(e,"optout",(r)=>r.def.out._zod.optout),P(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let i=t.out._zod.run(r,n);if(i instanceof Promise)return i.then((s)=>vt(s,t.in,n));return vt(i,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>vt(i,t.out,n));return vt(o,t.out,n)}});function vt(e,t,r){if(e.issues.some((n)=>n.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var Ai=f("$ZodReadonly",(e,t)=>{N.init(e,t),P(e,"propValues",(r)=>r.def.innerType._zod.propValues),P(e,"values",(r)=>r.def.innerType._zod.values),P(e,"optin",(r)=>r.def.innerType?._zod?.optin),P(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(Mo);return Mo(o)}});function Mo(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Ni=f("$ZodCustom",(e,t)=>{j.init(e,t),N.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((i)=>Lo(i,r,n,e));Lo(o,r,n,e);return}});function Lo(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(_e(o))}}class Ri extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var yr="~memo",Ti=[];function Mi(e){return e!==null&&typeof e==="object"}function gr(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Li=new WeakMap,Ge=0,Pt=1,Ke=2;function Zt(e,t,r){let n=Li.get(e);if(n!==void 0)return n?Ke:Ge;if(t.has(e))return Ke;t.add(e);let o=Ge,i=(l)=>{if(o!==Ke&&l?._zod){let d=Zt(l,t,r);if(d>o)o=d}},s=(l,d)=>{let p=Ge;for(let h of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,h);if(d&&!m.enumerable)continue;let x=m.get?Pt:m.value?._zod?Zt(m.value,t,r):Ge;if(x>p)p=x}return p},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=ct(c);a(l?s(l,!0):Pt),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?Zt(l,t,!1):Pt);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let p=d.value;if(!p||typeof p!=="object")continue;if(p._zod)i(p);else if(Array.isArray(p))for(let h of p)i(h)}}return t.delete(e),su(e,o)}function su(e,t){if(t!==Pt)Li.set(e,t===Ke);return t}function au(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var $t,St=[],cu={alloc(e,t,r){let n=$t;if(!n)return r;$t=void 0;let o={value:r,issues:null};return n.set(t.value,o),St.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,i)=>{if(i.direction!=="backward"&&uu(i,o.value))throw new Ri;return r(o,i)};if(e._zod.parse=n,e._zod.run===r)e._zod.run=n})},attach(e){var t;let r,n=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,u)=>{if(r===void 0){let S=Zt(e,new Set,!1);if(S===Ge){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,u)}if(S===Ke||n)r=!0;else n=!0}let l=c.value;if(!Mi(l))return s(c,u);let d=u[yr];if(!d)d={buckets:new WeakMap,backEdges:void 0},u[yr]=d;let p;if(o===u)p=i;else p=au(d,e),o=u,i=p;let h=p.get(l);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...gr(h.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value);return c}$t=p;let m=St.length,x=s(c,u);$t=void 0;let w=St.length>m?St.pop():void 0;if(x instanceof Promise)return x.then((S)=>{if(w)w.issues=S.issues.length?gr(S.issues):Ti;return S});if(w)w.issues=x.issues.length?gr(x.issues):Ti;return x};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function Di(){return cu}function uu(e,t){let r=e[yr]?.backEdges;return r!==void 0&&Mi(t)&&r.has(t)}var lu=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return n[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=wn(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${Ht(i.values[0])}`;return`Invalid option: expected one of ${Gt(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${r[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Gt(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function br(){return{localeError:lu()}}var ji;class Bi{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function du(){return new Bi}(ji=globalThis).__zod_globalRegistry??(ji.__zod_globalRegistry=du());var ke=globalThis.__zod_globalRegistry;function Fi(e){if(e.checks)e.checks=[...e.checks];return e}function Ui(e,t){return new e(Fi({type:"string",...v(t)}))}function qi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...v(t)})}function Vi(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...v(t)})}function xr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...v(t)})}function Ji(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...v(t)})}function Gi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...v(t)})}function Ki(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...v(t)})}function vr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...v(t)})}function Wi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...v(t)})}function Hi(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...v(t)})}function Yi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...v(t)})}function Xi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...v(t)})}function Qi(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...v(t)})}function es(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...v(t)})}function ts(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...v(t)})}function rs(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...v(t)})}function ns(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...v(t)})}function os(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...v(t)})}function is(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...v(t)})}function ss(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...v(t)})}function as(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...v(t)})}function cs(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...v(t)})}function us(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...v(t)})}function ls(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...v(t)})}function ds(e,t){return new e({type:"string",format:"date",check:"string_format",...v(t)})}function ps(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...v(t)})}function fs(e,t){return new e({type:"string",format:"duration",check:"string_format",...v(t)})}function ms(e,t){return new e(Fi({type:"number",checks:[],...v(t)}))}function hs(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...v(t)})}function gs(e,t){return new e({type:"boolean",...v(t)})}function ys(e){return new e({type:"unknown"})}function bs(e,t){return new e({type:"never",...v(t)})}function It(e,t){return new cr({check:"less_than",...v(t),value:e,inclusive:!1})}function We(e,t){return new cr({check:"less_than",...v(t),value:e,inclusive:!0})}function Ot(e,t){return new ur({check:"greater_than",...v(t),value:e,inclusive:!1})}function He(e,t){return new ur({check:"greater_than",...v(t),value:e,inclusive:!0})}function Et(e,t){return new ho({check:"multiple_of",...v(t),value:e})}function Ct(e,t){return new yo({check:"max_length",...v(t),maximum:e})}function Ie(e,t){return new bo({check:"min_length",...v(t),minimum:e})}function At(e,t){return new xo({check:"length_equals",...v(t),length:e})}function wr(e,t){return new vo({check:"string_format",format:"regex",...v(t),pattern:e})}function _r(e){return new wo({check:"string_format",format:"lowercase",...v(e)})}function kr(e){return new _o({check:"string_format",format:"uppercase",...v(e)})}function zr(e,t){return new ko({check:"string_format",format:"includes",...v(t),includes:e})}function $r(e,t){return new zo({check:"string_format",format:"starts_with",...v(t),prefix:e})}function Sr(e,t){return new $o({check:"string_format",format:"ends_with",...v(t),suffix:e})}function ge(e){return new So({check:"overwrite",tx:e})}function Pr(e){return ge((t)=>t.normalize(e))}function Zr(){return ge((e)=>e.trim())}function Ir(){return ge((e)=>e.toLowerCase())}function Or(){return ge((e)=>e.toUpperCase())}function Er(){return ge((e)=>mn(e))}function xs(e,t,r){return new e({type:"array",element:t,...v(r)})}function vs(e,t,r){return new e({type:"custom",check:"custom",fn:t,...v(r)})}function ws(e,t){let r=pu((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(_e(o,n.value,r._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=n.value;i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(_e(i))}},e(n.value,n)),t);return r}function pu(e,t){let r=new j({check:"custom",...v(t)});return r._zod.check=e,r}function Ye(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))ee(e,n,r[n]);return e}function Ar(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??ke,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ze(e,t,r,n,o){let i=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(r,i),!0}function L(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let p=s.schema,h=t.processors[o.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,p,l)}let d=e._zod.parent;if(d){if(!s.ref)s.ref=d;L(d,t,l),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Ye(s.schema,c);if(t.io==="input"&&F(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(n=s.schema).default??(n.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function _s(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Nr(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=n.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,s[0])}}let o=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,p=e.external.uri??((m)=>m);if(d)return{ref:p(d)};let h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${p("__shared")}#/${a}/${_s(h)}`}}let c="#",u=`${c}/${a}/`;if(s[1]===r&&!s[1].schema.id)return{ref:c};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+_s(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=o(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
56
+
57
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function $s(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!=="object")return;$s(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let i=n.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!r.includes(s))r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Ss=new Set(["type","properties","required","additionalProperties"]),ks=["oneOf","anyOf"];function zs(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Cr(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Ss.has(s))return null;t.push(i)}let r={},n=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;let a=[];for(let u of t){let l=u.properties?.[s]??zs(u);if(l===null||l===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:Cr(a)??{allOf:a};ee(r,s,c)}for(let s of i.required??[])n.add(s)}let o={type:"object",properties:r};if(n.size)o.required=[...n];if(t.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of t){let a=zs(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function fu(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Ss)if(o in e)return;let r=t.filter((o)=>ks.some((i)=>Array.isArray(o[i]))),n=null;if(!r.length)n=Cr(t);else{let o=r[0],i=ks.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=t.filter((c)=>c!==o),a=o[i].map((c)=>Cr([...s,c]));if(a.some((c)=>!c))return;n={[i]:a}}if(!n)return;delete e.allOf,Ye(e,n)}function Tr(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let h=e.seen.get(d),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(m);else Ye(u,m);if(Ye(u,l),a._zod.parent===d)for(let w in u){if(w==="$ref"||w==="allOf")continue;if(!(w in l))delete u[w]}if(m.$ref&&h.def)for(let w in u){if(w==="$ref"||w==="allOf")continue;if(w in h.def&&JSON.stringify(u[w])===JSON.stringify(h.def[w]))delete u[w]}}let p=a._zod.parent;if(p&&p!==d){n(p);let h=e.seen.get(p);if(h?.schema.$ref){if(u.$ref=h.schema.$ref,h.def)for(let m in u){if(m==="$ref"||m==="allOf")continue;if(m in h.def&&JSON.stringify(u[m])===JSON.stringify(h.def[m]))delete u[m]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())$s(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);if(d)d.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])fu(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Ye(o,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;ee(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Xe(t,"input",e.processors),output:Xe(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function F(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return F(n.element,r);if(n.type==="set")return F(n.valueType,r);if(n.type==="lazy")return F(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return F(n.innerType,r);if(n.type==="intersection")return F(n.left,r)||F(n.right,r);if(n.type==="record"||n.type==="map")return F(n.keyType,r)||F(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return F(n.in,r)||F(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(F(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(F(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(F(o,r))return!0;if(n.rest&&F(n.rest,r))return!0;return!1}return!1}var Ps=(e,t={})=>(r)=>{let n=Ar({...r,processors:t});return L(e,n),Nr(n,e),Tr(n,e)},Xe=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:i}=n??{},s=Ar({...o??{},target:i,io:t,processors:r});return L(e,s),Nr(s,e),Tr(s,e)};var Oe=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},Ee=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Zs=(e,t)=>{Oe(e,"minimum",t),Ee(e,"maximum",t)},Cs=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},As=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Ns=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Ts=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Is=(e,t)=>Oe(e,"minimum",t.minimum),Os=(e,t)=>Ee(e,"maximum",t.maximum),Es=(e)=>(t,r)=>{Ts(t,r.format);let[n,o]=e[r.format];Oe(t,"minimum",n),Ee(t,"maximum",o)},mu={greater_than:(e,t)=>Oe(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ee(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Cs(e,t.value),number_format:Es(ut),bigint_format:Es(Yt),min_length:Is,max_length:Os,length_equals:(e,t)=>Zs(e,t.length),min_size:Is,max_size:Os,size_equals:(e,t)=>Zs(e,t.size),string_format:(e,t)=>{if(Ts(e,t.format),t.pattern)As(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>Ns(e,t.mime)};function X(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of n)mu[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Oe(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Oe(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Ee(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Ee(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)Cs(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)Ns(t,o.mime);for(let i of o.patterns??[])As(t,i);return t}var hu={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},gu=new Map([[fr,ro],[zt,no]]),Rs=(e)=>gu.get(e)??e,Ms=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=X(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=hu[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let d=[...c].map(Rs);if(d.length===1)o.pattern=d[0].source;else if(d.length>1)o.allOf=[...d.map((p)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))]}},Ls=(e,t,r,n)=>{let o=r,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=X(e);o.type=l?"integer":"number";let d=typeof u==="number"&&u>=(i??Number.NEGATIVE_INFINITY),p=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(h)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof i==="number")o.minimum=i;if(p)if(h)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let m=new Set;for(let S of a)if(Number.isFinite(S)&&S!==0)m.add(Math.abs(S));else ze(e,t,o,n,`A multipleOf divisor of ${S} cannot be represented in JSON Schema`);let[x,...w]=m;if(x!==void 0)o.multipleOf=x;if(w.length)o.allOf=[...o.allOf??[],...w.map((S)=>({multipleOf:S}))]}},Ds=(e,t,r,n)=>{r.type="boolean"};var js=(e,t,r,n)=>{r.not={}};var Bs=(e,t,r,n)=>{};var Fs=(e,t,r,n)=>{let o=e._zod.def,i=Be(o.entries);if(i.length===0){r.not={};return}if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i};var Us=(e,t,r,n)=>{ze(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var qs=(e,t,r,n)=>{ze(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Vs=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:a}=X(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=L(i.element,t,{...n,path:[...n.path,"items"]})};function Nt(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Nt(t.out);if(t.type==="catch")return Nt(t.innerType);return e._zod.optin}var Js=(e,t,r,n)=>{let o=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&ze(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in s)ee(o.properties,u,L(s[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(s)){let l=i.shape[u];if(t.io==="input"?Nt(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=L(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},Gs=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>L(a,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},Ks=(e,t,r,n)=>{let o=e._zod.def,i=L(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=L(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c,t.intersections.push(c)};function Rr(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let x=Rr(e,m,r);return x===m?t:x}for(let m of["anyOf","oneOf"]){let x=t[m];if(!Array.isArray(x))continue;let w=x.map((S)=>Rr(e,S,r));if(w.some((S,z)=>S!==x[z]))t={...t,[m]:w}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((m)=>m==="number"||m==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((m)=>typeof m==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:p,...h}=t;if(h.enum)h.enum=h.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof h.const==="number")h.const=String(h.const);if(!o)return h;if(h.type="string",!i)h.pattern=(n.includes("number")?qe:sr).source;return h}var Mr=new WeakMap;function yu(e){let t=new Map;for(let n of e.seen.values())if(n.def&&!t.has(n.schema))t.set(n.schema,n);let r=new Map;for(let n of Mr.get(e)??[]){let o=e.seen.get(n),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=Rr(t,i,new Set);if(s!==i)r.set(i,s)}if(!r.size)return;for(let n of e.seen.values())for(let o of[n.schema,n.def]){let i=o&&r.get(o.propertyNames);if(i)o.propertyNames=i}}var Ws=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,a=X(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=L(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)ee(o.patternProperties,Rs(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=L(i.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=Mr.get(t);if(!l)l=[],Mr.set(t,l),t.deferred.push(()=>yu(t));l.push(e)}o.additionalProperties=L(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=s._zod.values,u=t.io==="input"&&Nt(i.valueType)!==void 0;if(c&&!i.partial&&!u){let l=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(l.length>0)o.required=l.map(String)}},Hs=(e,t,r,n)=>{let o=e._zod.def,i=L(o.innerType,t,n),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},Ys=(e,t,r,n)=>{let o=e._zod.def;L(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Lr=Symbol();function Xs(e,t,r,n,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return ze(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),Lr}var Qs=(e,t,r,n)=>{let o=e._zod.def;L(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s=Xs(o.defaultValue,e,t,r,n);if(s!==Lr)r.default=s},ea=(e,t,r,n)=>{let o=e._zod.def;L(o.innerType,t,n);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=Xs(o.defaultValue,e,t,r,n);if(s!==Lr)r._prefault=s},ta=(e,t,r,n)=>{let o=e._zod.def;L(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{ze(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},ra=(e,t,r,n)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;L(s,t,n);let a=t.seen.get(e);a.ref=s},na=(e,t,r,n)=>{let o=e._zod.def;L(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0};var Dr=(e,t,r,n)=>{let o=e._zod.def;L(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType};var oa=new WeakSet([Object.prototype,Error.prototype]);function Tt(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var $u=(e,t)=>{In.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(oa.has(r))return;oa.add(r),Tt(r,"format",(n)=>(o)=>En(n,o)),Tt(r,"flatten",(n)=>(o)=>On(n,o)),Tt(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Fe,2)}),Tt(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Fe,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var H=f("ZodError",$u,void 0,{Parent:Error});var ia=ht(H),sa=gt(H),aa=yt(H),ca=bt(H),ua=An(H),la=Nn(H),da=Tn(H),pa=Rn(H),fa=Mn(H),ma=Ln(H),ha=Dn(H),ga=jn(H);function Pu(){if(!V.localeError)W(br())}function Rt(){if(!V.memoizer)W({memoizer:Di()})}var M=f("ZodType",(e,t)=>(Pu(),N.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(K(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return oe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(vl(e,t))},superRefine(e,t){return this.check(wl(e,t))},overwrite(e){return this.check(ge(e))},optional(){return va(this)},exactOptional(){return al(this)},nullable(){return wa(this)},nullish(){return va(wa(this))},nonoptional(e){return fl(this,e)},array(){return D(this)},or(e){return rl([this,e])},and(e){return ol(this,e)},transform(e){return _a(this,sl(e))},default(e){return ll(this,e)},prefault(e){return pl(this,e)},catch(e){return hl(this,e)},pipe(e){return _a(this,e)},readonly(){return bl(this)},describe(e){let t=this.clone();return ke.add(t,{description:e}),t},meta(...e){if(e.length===0)return ke.get(this);let t=this.clone();return ke.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return ft(this,"~standard",{...pr(this),jsonSchema:{input:Xe(this,"input"),output:Xe(this,"output")}})},set "~standard"(e){le(this,"~standard",e)},parse:function e(t,r){return ia(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await sa(this,t,r,{callee:e})},safeParse(e,t){return aa(this,e,t)},async safeParseAsync(e,t){return ca(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){le(this,"spa",e)},validate(e,t){return rr(this,e,t)},validateAsync(e,t){return nr(this,e,t)},encode:function e(t,r){return ua(this,t,r,{callee:e})},decode:function e(t,r){return la(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await da(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await pa(this,t,r,{callee:e})},safeEncode(e,t){return fa(this,e,t)},safeDecode(e,t){return ma(this,e,t)},async safeEncodeAsync(e,t){return ha(this,e,t)},async safeDecodeAsync(e,t){return ga(this,e,t)},toJSONSchema(e){return Ps(this,{})(e)},get description(){return ke.get(this)?.description},get _def(){return this._zod.def}}),ka=f("_ZodString",(e,t)=>{kt.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ms(e,r,n,o)},kn({format:(e)=>X(e).format??null,minLength:(e)=>X(e).minimum??null,maxLength:(e)=>X(e).maximum??null},{regex(...e){return this.check(wr(...e))},includes(...e){return this.check(zr(...e))},startsWith(...e){return this.check($r(...e))},endsWith(...e){return this.check(Sr(...e))},min(...e){return this.check(Ie(...e))},max(...e){return this.check(Ct(...e))},length(...e){return this.check(At(...e))},nonempty(...e){return this.check(Ie(1,...e))},lowercase(e){return this.check(_r(e))},uppercase(e){return this.check(kr(e))},trim(){return this.check(Zr())},normalize(...e){return this.check(Pr(...e))},toLowerCase(){return this.check(Ir())},toUpperCase(){return this.check(Or())},slugify(){return this.check(Er())}})),Zu=f("ZodString",(e,t)=>{kt.init(e,t),ka.init(e,t)},{email(e){return this.check(qi(Au,e))},url(e){return this.check(vr(za,e))},jwt(e){return this.check(us(Wu,e))},emoji(e){return this.check(Wi(Tu,e))},guid(e){return this.check(Vi(Nu,e))},uuid(e){return this.check(xr(Qe,e))},uuidv4(e){return this.check(Ji(Qe,e))},uuidv6(e){return this.check(Gi(Qe,e))},uuidv7(e){return this.check(Ki(Qe,e))},nanoid(e){return this.check(Hi(Ru,e))},cuid(e){return this.check(Yi(Mu,e))},cuid2(e){return this.check(Xi(Lu,e))},ulid(e){return this.check(Qi(Du,e))},base64(e){return this.check(ss(Ju,e))},base64url(e){return this.check(as(Gu,e))},xid(e){return this.check(es(ju,e))},ksuid(e){return this.check(ts(Bu,e))},ipv4(e){return this.check(rs(Fu,e))},ipv6(e){return this.check(ns(Uu,e))},cidrv4(e){return this.check(os(qu,e))},cidrv6(e){return this.check(is(Vu,e))},e164(e){return this.check(cs(Ku,e))},datetime(e){return this.check(ls(Iu,e))},date(e){return this.check(ds(Ou,e))},time(e){return this.check(ps(Eu,e))},duration(e){return this.check(fs(Cu,e))}});function y(e){return Ui(Zu,e)}var T=f("ZodStringFormat",(e,t)=>{C.init(e,t),ka.init(e,t)}),Iu=f("ZodISODateTime",(e,t)=>{Qo.init(e,t),T.init(e,t)}),Ou=f("ZodISODate",(e,t)=>{ei.init(e,t),T.init(e,t)}),Eu=f("ZodISOTime",(e,t)=>{ti.init(e,t),T.init(e,t)}),Cu=f("ZodISODuration",(e,t)=>{ri.init(e,t),T.init(e,t)}),Au=f("ZodEmail",(e,t)=>{Fo.init(e,t),T.init(e,t)});var Nu=f("ZodGUID",(e,t)=>{jo.init(e,t),T.init(e,t)});var Qe=f("ZodUUID",(e,t)=>{Bo.init(e,t),T.init(e,t)});function Mt(e){return xr(Qe,e)}var za=f("ZodURL",(e,t)=>{Vo.init(e,t),T.init(e,t)});function Fr(e){return vr(za,e)}var Tu=f("ZodEmoji",(e,t)=>{Jo.init(e,t),T.init(e,t)});var Ru=f("ZodNanoID",(e,t)=>{Go.init(e,t),T.init(e,t)});var Mu=f("ZodCUID",(e,t)=>{Ko.init(e,t),T.init(e,t)});var Lu=f("ZodCUID2",(e,t)=>{Wo.init(e,t),T.init(e,t)});var Du=f("ZodULID",(e,t)=>{Ho.init(e,t),T.init(e,t)});var ju=f("ZodXID",(e,t)=>{Yo.init(e,t),T.init(e,t)});var Bu=f("ZodKSUID",(e,t)=>{Xo.init(e,t),T.init(e,t)});var Fu=f("ZodIPv4",(e,t)=>{ni.init(e,t),T.init(e,t)});var Uu=f("ZodIPv6",(e,t)=>{ii.init(e,t),T.init(e,t)});var qu=f("ZodCIDRv4",(e,t)=>{si.init(e,t),T.init(e,t)});var Vu=f("ZodCIDRv6",(e,t)=>{ai.init(e,t),T.init(e,t)});var Ju=f("ZodBase64",(e,t)=>{ui.init(e,t),T.init(e,t)});var Gu=f("ZodBase64URL",(e,t)=>{li.init(e,t),T.init(e,t)});var Ku=f("ZodE164",(e,t)=>{di.init(e,t),T.init(e,t)});var Wu=f("ZodJWT",(e,t)=>{pi.init(e,t),T.init(e,t)});var $a=f("ZodNumber",(e,t)=>{mr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ls(e,r,n,o),e.isFinite=!0},kn({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=X(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=X(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=X(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>X(e).format??null},{gt(e,t){return this.check(Ot(e,t))},gte(e,t){return this.check(He(e,t))},min(e,t){return this.check(He(e,t))},lt(e,t){return this.check(It(e,t))},lte(e,t){return this.check(We(e,t))},max(e,t){return this.check(We(e,t))},int(e){return this.check(ya(e))},safe(e){return this.check(ya(e))},positive(e){return this.check(Ot(0,e))},nonnegative(e){return this.check(He(0,e))},negative(e){return this.check(It(0,e))},nonpositive(e){return this.check(We(0,e))},multipleOf(e,t){return this.check(Et(e,t))},step(e,t){return this.check(Et(e,t))},finite(){return this}}));function Ur(e){return ms($a,e)}var Hu=f("ZodNumberFormat",(e,t)=>{fi.init(e,t),$a.init(e,t)});function ya(e){return hs(Hu,e)}var Yu=f("ZodBoolean",(e,t)=>{mi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ds(e,r,n,o)});function de(e){return gs(Yu,e)}var Xu=f("ZodUnknown",(e,t)=>{hi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bs(e,r,n,o)});function ba(){return ys(Xu)}var Qu=f("ZodNever",(e,t)=>{gi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>js(e,r,n,o)});function Sa(e){return bs(Qu,e)}var el=f("ZodArray",(e,t)=>{Rt(),yi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vs(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Ie(e,t))},nonempty(e){return this.check(Ie(1,e))},max(e,t){return this.check(Ct(e,t))},length(e,t){return this.check(At(e,t))},unwrap(){return this.element}});function D(e,t){return xs(el,e,t)}var Pa=f("ZodObject",(e,t)=>{Rt(),vi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Js(e,r,n,o),Rc(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return Ce(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(K(this._zod.def,{catchall:e}))},passthrough(){return this.clone(K(this._zod.def,{catchall:ba()}))},loose(){return this.clone(K(this._zod.def,{catchall:ba()}))},strict(){return this.clone(K(this._zod.def,{catchall:Sa()}))},strip(){return this.clone(K(this._zod.def,{catchall:void 0}))},extend(e){return Zc(this,e)},safeExtend(e){return Ic(this,e)},merge(e){return Oc(this,e)},pick(e){return Sc(this,e)},omit(e){return Pc(this,e)},partial(...e){return xn(Za,this,e[0])},exactPartial(...e){return xn(Ia,this,e[0],"exactPartial")},required(...e){return Ec(Oa,this,e[0])}});function ye(e,t){let r={type:"object",shape:e??{},...v(t)};return new Pa(r)}function O(e,t){return new Pa({type:"object",shape:e,catchall:Sa(),...v(t)})}var tl=f("ZodUnion",(e,t)=>{wi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gs(e,r,n,o),e.options=t.options});function rl(e,t){return new tl({type:"union",options:e,...v(t)})}var nl=f("ZodIntersection",(e,t)=>{_i.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ks(e,r,n,o)});function ol(e,t){return new nl({type:"intersection",left:e,right:t})}var xa=f("ZodRecord",(e,t)=>{Rt(),ki.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ws(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Lt(e,t,r){if(!t||!t._zod)return new xa({type:"record",keyType:y(),valueType:e,...v(t)});return new xa({type:"record",keyType:e,valueType:t,...v(r)})}var Br=f("ZodEnum",(e,t)=>{zi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Fs(e,n,o,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let i={};for(let s of n)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Br({...t,checks:[],...v(o),entries:i})},e.exclude=(n,o)=>{let i={...t.entries};for(let s of n)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Br({...t,checks:[],...v(o),entries:i})}});function Ce(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new Br({type:"enum",entries:r,...v(t)})}var il=f("ZodTransform",(e,t)=>{Rt(),$i.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qs(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ue(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(_e(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=r.value;s.inst??(s.inst=e),r.issues.push(_e(s))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((i)=>(r.value=i,r));return r.value=o,r}});function sl(e){return new il({type:"transform",transform:e})}var Za=f("ZodOptional",(e,t)=>{hr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function va(e){return new Za({type:"optional",innerType:e})}var Ia=f("ZodExactOptional",(e,t)=>{Si.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function al(e){return new Ia({type:"optional",innerType:e})}var cl=f("ZodNullable",(e,t)=>{Pi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function wa(e){return new cl({type:"nullable",innerType:e})}var ul=f("ZodDefault",(e,t)=>{Zi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ll(e,t){return new ul({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Wt(t)}})}var dl=f("ZodPrefault",(e,t)=>{Ii.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ea(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function pl(e,t){return new dl({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Wt(t)}})}var Oa=f("ZodNonOptional",(e,t)=>{Oi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ys(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function fl(e,t){return new Oa({type:"nonoptional",innerType:e,...v(t)})}var ml=f("ZodCatch",(e,t)=>{Ei.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ta(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function hl(e,t){return new ml({type:"catch",innerType:e,catchValue:typeof t==="function"?t:zn(t)})}var gl=f("ZodPipe",(e,t)=>{Ci.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ra(e,r,n,o),e.in=t.in,e.out=t.out});function _a(e,t){return new gl({type:"pipe",in:e,out:t})}var yl=f("ZodReadonly",(e,t)=>{Ai.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>na(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function bl(e){return new yl({type:"readonly",innerType:e})}var xl=f("ZodCustom",(e,t)=>{Ni.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Us(e,r,n,o)});function vl(e,t={}){return vs(xl,e,t)}function wl(e,t){return ws(e,t)}var Ae=Ce(["global","private","shared"]),_l=y().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(48),Ne=O({name:_l,description:y().trim().min(1).max(300),body:y().trim().min(1).max(24000)}),qr=O({scope:Ae,choices:Lt(y().max(128),de()),edits:Lt(y().max(128),y().min(1).max(48000)).default({}),custom:D(Ne).max(40).default([])}),im=qr.extend({directory:y(),id:y()});var kl=O({id:y(),title:y(),parentId:y().nullable()}),zl=O({id:y(),itemIds:D(y()).min(1),parentId:y(),relatedHubIds:D(y()).max(2)}),Vr=O({hubs:D(kl),leaves:D(zl)});var $l=O({id:y(),name:y(),title:y(),description:y(),text:y(),kind:Ce(["preference","skill"]),category:y().nullable(),section:y().nullable(),axis:y().nullable(),owner:Ce(["packaged","managed","user","provider"])}),Ea=O({scope:Ae,input:qr,inherited:Lt(y(),de()),locked:Lt(y(),de()),items:D($l),constellation:Vr,requirements:D(y()),libraryEnabled:de(),migrationRequired:de(),revisionId:y().nullable()}),Ca=O({id:Mt(),changes:D(O({path:y(),before:y().nullable(),after:y().nullable(),internal:de()})),warnings:D(y())}),Jr=O({revisionId:y().nullable()});var Gr=window.location.hash.slice(1),Sl=Gr||sessionStorage.getItem("shadowclone-session")||"";if(Gr)sessionStorage.setItem("shadowclone-session",Gr),history.replaceState(null,"",`${location.pathname}${location.search}`);async function Z(e){let t=await fetch(e.path,{method:e.body===void 0?"GET":"POST",headers:{Authorization:`Bearer ${Sl}`,"Content-Type":"application/json"},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:e.signal}),r=await t.json();if(!t.ok){let n=ye({error:y()}).safeParse(r);throw Error(n.success?n.data.error:"The local editor could not complete this action.")}return e.schema.parse(r)}var Pl=[["testing",["test","tests","testing","regression","coverage","tdd","e2e","playwright"]],["review",["review","reviews","reviewer","feedback","findings","audit"]],["debugging",["debug","debugging","diagnose","bug","bugs","incident","triage","flaky"]],["version-control",["git","merge","rebase","branch","commit","commits","conflict","worktree"]],["pull-requests",["pr","prs","pull"]],["writing",["write","writing","docs","documentation","prose","readme","voice"]],["planning",["plan","planning","architecture","roadmap"]],["typescript",["typescript","types","type"]],["frontend",["ui","css","react","frontend","browser","web","page","design"]],["data",["sql","database","data","schema","migration"]],["delivery",["deploy","release","ci","pipeline"]],["security",["security","secret","secrets","auth","permissions"]],["research",["research","search","investigate","sources"]]];function Zl(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)}function Il(e){return e.split("-").map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}function Ol(e){if(e.category)return e.category;let t=new Set(Zl(`${e.name} ${e.title} ${e.description}`)),[r]=Pl.map(([n,o],i)=>({category:n,index:i,hits:o.filter((s)=>t.has(s)).length})).filter((n)=>n.hits>0).sort((n,o)=>o.hits-n.hits||n.index-o.index);return r?.category??"more"}function Aa(e){let r=Ol(e.item),n=`category:custom:${r}`,o=[...e.constellation.hubs];if(!o.some((i)=>i.id==="source:custom"))o.push({id:"source:custom",title:"Your custom skills",parentId:null});if(!o.some((i)=>i.id===n))o.push({id:n,title:r==="more"?"More skills":Il(r),parentId:"source:custom"});return{hubs:o,leaves:[...e.constellation.leaves,{id:`skill:${e.item.id}`,itemIds:[e.item.id],parentId:n,relatedHubIds:[]}]}}function _(e){let t=document.getElementById(e);if(t===null)throw Error("The editor is missing a required control");return t}function Kr(e){let t=document.querySelector(`#${e}`);if(!(t instanceof SVGSVGElement))throw Error("Expected an SVG canvas");return t}function J(e){let t=_(e);if(!(t instanceof HTMLInputElement))throw Error("Expected an input control");return t}function ce(e){let t=_(e);if(!(t instanceof HTMLSelectElement))throw Error("Expected a selection control");return t}function pe(e){let t=_(e);if(!(t instanceof HTMLTextAreaElement))throw Error("Expected a text editor");return t}function Te(e){let t=_(e);if(!(t instanceof HTMLDialogElement))throw Error("Expected an editor dialog");return t}function g(e){let t=document.createElement(e.tag);if(e.className)t.className=e.className;if(e.text!==void 0)t.textContent=e.text;return t}function Q(e){let t=_("notice");t.textContent=e.message,t.classList.toggle("success",e.success===!0),t.hidden=e.message.length===0}function fe(e){Q({message:e instanceof Error?e.message:"The action failed."})}var b={view:null,input:{scope:"global",choices:{},edits:{},custom:[]},activeId:"",search:"",dirty:!1};function G(e){let t=b.view?.locked[e.id];if(t!==void 0)return t;let r=b.input.choices[e.id];if(r!==void 0)return r;if(e.id.startsWith("custom:")&&b.input.custom.some((n)=>e.id===`custom:${n.name}`))return!0;return b.view?.inherited[e.id]===!0}function et(e){if(b.view?.locked[e.id]!==void 0)return;let t=!G(e);if(b.input.choices[e.id]=t,t&&e.axis){for(let r of b.view?.items??[])if(r.axis===e.axis&&r.id!==e.id)b.input.choices[r.id]=!1,delete b.input.edits[r.id]}if(!t)delete b.input.edits[e.id];b.dirty=!0}function Wr(e){_("custom-status").textContent="",J("custom-name").value=e?`my-${e.name}`.slice(0,48):"",J("custom-description").value=e?`Use alongside ${e.name} for my working preferences.`:"",pe("custom-body").value=e?`# Personal guidance for ${e.title}
58
+
59
+ `:"",Te("custom-dialog").showModal()}function Na(){let e=Ne.parse({name:J("custom-name").value,description:J("custom-description").value,body:pe("custom-body").value}),t=`custom:${e.name}`;if(b.view?.items.some((r)=>r.name===e.name))throw Error("Choose a name that does not replace an existing skill.");if(b.input.custom.push(e),b.input.choices[t]=!0,b.dirty=!0,b.activeId=t,b.view?.items.push({id:t,name:e.name,title:e.name.replaceAll("-"," "),description:e.description,text:`---
60
+ name: ${e.name}
61
+ description: ${JSON.stringify(e.description)}
62
+ ---
63
+
64
+ ${e.body}
65
+ `,kind:"skill",category:null,section:null,axis:null,owner:"managed"}),b.view)b.view.constellation=Aa({constellation:b.view.constellation,item:{id:t,name:e.name,title:e.name.replaceAll("-"," "),description:e.description,category:null}});Te("custom-dialog").close(),J("custom-name").value="",pe("custom-body").value=""}var Hr={"design-deep-modules":{title:"Deep modules",summary:"Keep interfaces small and useful. Put complexity behind a clear boundary so callers have less to understand."},"typescript-type-safety":{title:"Explicit types",summary:"Represent valid states in the type system. Narrow uncertain values and keep unsafe assertions out of the implementation."},"verify-review-findings":{title:"Check review findings",summary:"Check each review comment against the code at the pull request head, and report a verdict before any change or reply."},"plan-with-review-page":{title:"Plan first",summary:"Read the code, ask one round of decisions with a recommendation, and share one plan with a review page before any edit."},"write-plain-english":{title:"Plain English",summary:"Write short sentences with one idea each and no dashes, in the user's voice. A checker reports long sentences and dashes."},"choose-by-consequence":{title:"Fail loudly",summary:"Compare each shortcut by what it does to the user's files and output. Pick the option that fails loudly and keeps counts true."},"scope-confirmed-changes":{title:"Reproduce, then fix",summary:"Reproduce the bug before any fix, then run the same reproduction after it. Keep the change to confirmed behavior."},"diagnose-before-editing":{title:"Find the cause",summary:"Reproduce the failure, make it smaller, and test one cause at a time until one cause predicts the symptom."},"tests-that-catch-bugs":{title:"Tests that catch bugs",summary:"Write a few tests that each name the bug they catch, check what the user sees, and fail when the fix is removed."},"verify-and-review":{title:"Verify the real outcome",summary:"Run what the user runs, read every count and exit code, and label each claim as measured, inferred, or not verified."},"research-primary-sources":{title:"Go to the source",summary:"Check authoritative documentation and original evidence when a technical decision depends on facts that need verification."},"planning-first":{title:"Plan the change",summary:"Establish the approach before implementation so the scope, decisions, and intended outcome are clear."},"planning-when-costly":{title:"Plan when it matters",summary:"Move directly on straightforward tasks. Pause for a plan when the cost, uncertainty, or consequences call for one."},"questions-autonomous":{title:"Keep moving",summary:"Use judgment to resolve routine choices. Ask when missing information changes the outcome or an action needs authorization."},"questions-early":{title:"Ask early",summary:"Resolve meaningful uncertainty with the user before investing in an implementation built on the wrong assumption."},"resolve-conflicts-by-intent":{title:"Preserve intent",summary:"Understand what both sides of a merge are trying to achieve. Resolve the conflict and verify the combined behavior."},"dependencies-existing":{title:"Know your tools",summary:"Look for a solution in the existing stack before adding another dependency."},"dependencies-mature":{title:"Choose proven tools",summary:"Use established, focused packages when they provide substantial reusable logic and justify the dependency."},"refactor-boundaries":{title:"Improve boundaries",summary:"Make a refactor when it improves responsibilities and simplifies the change. Keep its purpose connected to the task."},"refactor-preserve":{title:"Respect the structure",summary:"Work within the current structure and preserve unrelated code while making the requested change."}};function $e(e){return Hr[e.id]?.title??e.title}function Ta(e){let t=Hr[e.item.id];if(t&&e.editedText===void 0&&e.item.owner==="packaged")return t.summary;let r=(e.editedText??e.item.text).replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/,"").split(`
66
+ `).filter((n)=>n.trim()&&!n.startsWith("#")&&!n.startsWith("```")).slice(0,2).join(" ").replace(/\*\*/g,"");return r.length>320?`${r.slice(0,317).trimEnd()}…`:r}function El(e){let t=g({tag:"details",className:"editor"});t.append(g({tag:"summary",text:"Edit instructions"}));let r=g({tag:"textarea"});r.value=b.input.edits[e.item.id]??e.item.text,r.maxLength=48000,r.setAttribute("aria-label",`Instructions for ${e.item.title}`);let n=g({tag:"button",className:"quiet-button",text:"Save to draft"});return n.addEventListener("click",()=>{if(!G(e.item))et(e.item);b.input.edits[e.item.id]=r.value,b.input.choices[e.item.id]=!0,b.dirty=!0,Q({message:"Instructions added to your draft. Review the changes before applying.",success:!0}),e.rerender()}),t.append(r,n),t}function Ra(e){let t=_("detail"),r=b.view?.items.find((a)=>a.id===b.activeId);if(t.replaceChildren(),!r){t.append(g({tag:"h2",text:"Choose a skill."})),t.append(g({tag:"p",className:"detail-description",text:"Inspect a star to see what it teaches your agent."}));return}t.append(g({tag:"p",className:"eyebrow",text:`${(r.category??"CUSTOM").replaceAll("-"," ").toUpperCase()} / ${r.kind.toUpperCase()}`}),g({tag:"h2",text:$e(r)}),g({tag:"p",className:"detail-description",text:r.description}));let n=g({tag:"div",className:"behavior"});n.append(g({tag:"p",className:"eyebrow",text:"YOUR AGENT WILL"}),g({tag:"p",text:Ta({item:r,editedText:b.input.edits[r.id]})})),t.append(n);let o=r.owner==="provider",i=b.view?.locked[r.id]!==void 0;if(t.append(g({tag:"p",className:"skill-status",text:i?"◇ Shared requirement":o?"◇ Managed by its provider":"◇ Workflow guidance"})),i){t.append(g({tag:"p",className:"owner-note",text:"This choice belongs to the shared repository build. Switch to shared scope to propose a reviewed change."}));return}let s=g({tag:"button",className:"primary-button",text:o?"Create a local companion":G(r)?"Unequip skill":"Equip skill"});if(s.addEventListener("click",()=>{if(o){e.companion(r);return}et(r),e.rerender()}),t.append(s),o)t.append(g({tag:"p",className:"owner-note",text:"Enable or disable this package in its harness. A companion adds your own instructions without changing the package."}));else t.append(El({item:r,rerender:e.rerender}))}var Cl=O({title:y().min(1).max(48),profile:y().min(1).max(420),abilities:D(O({skill:y().min(1).max(120),text:y().min(1).max(200)})).min(1).max(3),tradeoff:y().min(1).max(240)}),Ma=O({name:Cl,destination:y()});function La(e){let t=new Map,r={status:"empty"},n=null,o=null,i=null,s=(u)=>{r=u,e.onChange(u)},a=()=>{if(o)e.cancel(o.handle);o=null,i?.abort(),i=null},c=()=>{let u=n;if(o=null,!u?.key)return;let l=u.key,d=new AbortController;i?.abort(),i=d,s({status:"loading"}),e.fetchName({input:structuredClone(u.input),signal:d.signal}).then((p)=>{if(t.set(l,p),!d.signal.aborted&&n?.key===l)s({status:"ready",result:p})}).catch((p)=>{if(!d.signal.aborted&&n?.key===l)s({status:"failed",error:p instanceof Error?p.message:"The build could not be named."})}).finally(()=>{if(i===d)i=null})};return{state:()=>r,update(u){let l=n;if(n=u,!u.enabled){if(a(),r.status!=="off")s({status:"off"});return}if(l?.key===u.key&&l.enabled&&r.status!=="off")return;if(a(),u.key===null){s({status:"empty"});return}let d=t.get(u.key);if(d){s({status:"ready",result:d});return}if(!u.changed){s({status:"unnamed"});return}s({status:"waiting"}),o={handle:e.schedule({run:c,delayMilliseconds:5000})}},retry(){a(),c()}}}var Yr="shadowclone-build-naming";function Da(){try{return localStorage.getItem(Yr)!=="off"}catch{return!0}}function Al(e){try{if(e)localStorage.removeItem(Yr);else localStorage.setItem(Yr,"off")}catch{return}}var Nl={empty:"Choose the instincts you want your agent to bring to work.",off:"Build naming is off. Turn it on to name your build with your fast model.",unnamed:"Name this build now, or change a skill and it gets a name 5 seconds later.",waiting:"Your build gets a name 5 seconds after your last change.",loading:"Naming your build…"};function ja(e){let t=_("identity"),r=_("abilities"),n=_("tradeoff"),o=e.status==="ready"?e.result:null;t.dataset.naming=e.status,t.setAttribute("aria-busy",String(e.status==="loading")),_("identity-title").textContent=o?.name.title??"An open canvas",_("identity-description").textContent=e.status==="ready"?e.result.name.profile:e.status==="failed"?e.error:Nl[e.status],r.replaceChildren(...(o?.name.abilities??[]).map((a)=>{let c=g({tag:"li"});return c.append(g({tag:"strong",text:a.skill}),g({tag:"span",text:a.text})),c})),n.hidden=!o,n.textContent=o?`Tradeoff: ${o.name.tradeoff}`:"",_("naming-source").textContent=o?`Named by ${o.destination}`:"";let i=_("retry-name");i.hidden=e.status!=="failed"&&e.status!=="unnamed",i.textContent=e.status==="unnamed"?"Name my build":"Retry";let s=_("toggle-naming");s.textContent=e.status==="off"?"Turn naming on":"Turn naming off",s.setAttribute("aria-pressed",String(e.status!=="off"))}var Xr=La({schedule:({run:e,delayMilliseconds:t})=>window.setTimeout(e,t),cancel:(e)=>window.clearTimeout(e),fetchName:({input:e,signal:t})=>Z({path:"/api/build-name",schema:Ma,body:e,signal:t}),onChange:ja});function Ba(){return b.view?.items.filter((e)=>e.owner!=="provider"&&G(e))??[]}function Fa(){let e=Ba();Xr.update({key:e.length?JSON.stringify([b.input.scope,e.map((t)=>t.id).sort(),b.input.custom]):null,input:b.input,enabled:Da(),changed:b.dirty})}function Ua(){_("retry-name").addEventListener("click",()=>Xr.retry()),_("toggle-naming").addEventListener("click",()=>{Al(!Da()),Fa()}),ja(Xr.state())}function qa(){let e=Ba();_("equipped-count").textContent=`${e.length} ${e.length===1?"skill":"skills"} equipped${b.dirty?" · unsaved changes":""}`,Fa();let t=_("requirements");if(t.replaceChildren(),t.hidden=!b.view?.requirements.length,b.view?.requirements.length){t.append(g({tag:"h3",text:"◇ Repository requirements"}));for(let r of b.view.requirements)t.append(g({tag:"p",text:r}))}}var Dt=null;async function Va(){if(b.view===null)throw Error("Wait for your skills to load before reviewing the build.");let e=await Z({path:"/api/preview",schema:Ca,body:b.input});Dt=e;let t=_("review-content");t.replaceChildren(),t.append(g({tag:"p",className:"review-message",text:`${e.changes.length} local files will change. Review the instructions and destinations below.`}));for(let r of e.warnings)t.append(g({tag:"p",className:"review-warning",text:r}));for(let r of e.changes){let n=g({tag:"details",className:"file-change"});if(n.append(g({tag:"summary",text:r.path})),r.internal)n.append(g({tag:"p",text:"Local configuration or supporting resource. Its previous version is retained for undo."}));else n.append(g({tag:"h4",text:"Before"}),g({tag:"pre",text:r.before??"New file"}),g({tag:"h4",text:"After"}),g({tag:"pre",text:r.after??"Remove managed file"}));t.append(n)}Te("review-dialog").showModal()}async function Ja(){if(Dt===null)throw Error("Review your build before applying it.");await Z({path:"/api/apply",schema:Jr,body:{previewId:Dt.id}}),Dt=null,Te("review-dialog").close(),Q({message:"Build equipped. Start a fresh agent session to use your updated skills.",success:!0})}async function Ga(){let e=b.view?.revisionId;if(!e||!window.confirm("Restore the files from before the last apply? Later edits will be preserved if they conflict."))return;await Z({path:"/api/undo",schema:Jr,body:{revisionId:e}}),Q({message:"Restored the previous build.",success:!0})}function Tl(e){let t=e.map((r)=>b.view?.items.find((n)=>n.id===r)).filter((r)=>r!==void 0);return t.find(G)??t[0]}function Rl(e){return`${$e(e)} ${e.description}`.toLowerCase().includes(b.search.toLowerCase())}function Ka(e){let t=_("constellation-list");t.replaceChildren();let r=new Map(e.constellation.hubs.map((n)=>[n.id,n.parentId]));for(let n of e.constellation.hubs.filter((o)=>o.parentId===null)){let o=g({tag:"section",className:"skill-list-group"});o.append(g({tag:"h3",text:n.title}));for(let i of e.constellation.leaves.filter((s)=>{let a=s.parentId;while(a){if(a===n.id)return!0;a=r.get(a)??null}return!1})){let s=Tl(i.itemIds);if(!s||!Rl(s))continue;let a=g({tag:"button",className:"skill-list-item",text:$e(s)});a.classList.toggle("equipped",G(s)),a.addEventListener("click",()=>e.inspect(s.id)),o.append(a)}if(o.childElementCount>1)t.append(o)}}var R={padding:32,rootX:56,sourceX:176,categoryX:296,cellWidth:120,cellHeight:96,groupGap:12,sourceGap:28,labelWidth:108,jitterX:4,jitterY:5};function Wa(e){let t=2166136261;for(let r of e.key)t=Math.imul(t^(r.codePointAt(0)??0),16777619);return(t>>>0)/4294967295*e.range*2-e.range}function Qr(e){let t=e-R.categoryX-R.padding+R.cellWidth/2;return Math.max(2,Math.floor(t/R.cellWidth))}function jt(e){return{id:`${e.from.id}:${e.to.id}`,sourceX:e.from.x,sourceY:e.from.y,targetX:e.to.x,targetY:e.to.y,sibling:e.sibling??!1}}function Ml(e){let t=[],r=e.cells;for(let n of e.blocks){if(r+1+n.columns>e.cells)t.push([]),r=0;t.at(-1)?.push(n),r+=1+n.columns}return t}function Ha(e){let t=Qr(e.width),{hubs:r,leaves:n}=e.constellation,o=[],i=[],s=[],a=R.padding;for(let d of r.filter((p)=>p.parentId===null)){let p=[],h=[],m=r.filter((z)=>z.parentId===d.id).map((z)=>{let A=n.filter((B)=>B.parentId===z.id);return{category:z,members:A,columns:Math.max(1,Math.min(A.length,t-1))}});for(let z of Ml({blocks:m,cells:t})){let A=0,B=1,I=null;for(let k of z){let E=R.categoryX+A*R.cellWidth,q={id:k.category.id,title:k.category.title,itemIds:[],kind:"category",parentId:d.id,x:E,y:a+R.cellHeight/2},be=q;if(p.push(q),I)i.push(jt({from:I,to:q,sibling:!0}));else h.push(q);for(let[Y,xe]of k.members.entries()){let it=Y%k.columns,Le={id:xe.id,title:"",itemIds:xe.itemIds,kind:"skill",parentId:k.category.id,x:E+(it+1)*R.cellWidth+Wa({key:xe.id,range:R.jitterX}),y:a+Math.floor(Y/k.columns)*R.cellHeight+R.cellHeight/2+Wa({key:`${xe.id}:y`,range:R.jitterY})};i.push(jt({from:it===0?q:be,to:Le})),o.push(Le),be=Le}B=Math.max(B,Math.ceil(k.members.length/k.columns)),A+=1+k.columns,I=q}a+=B*R.cellHeight+R.groupGap}let x=p[0],w=p.at(-1),S={id:d.id,title:d.title,itemIds:[],kind:"source",parentId:"constellation-root",x:R.sourceX,y:x&&w?(x.y+w.y)/2:a+R.cellHeight/2};s.push(S),o.push(S,...p),i.push(...h.map((z)=>jt({from:S,to:z}))),a+=R.sourceGap}let c=s[0],u=s.at(-1),l={id:"constellation-root",title:"Shadowclone",itemIds:[],kind:"root",parentId:null,x:R.rootX,y:c&&u?(c.y+u.y)/2:R.padding+R.cellHeight/2};return i.push(...s.map((d)=>jt({from:l,to:d}))),{nodes:[l,...o],links:i,height:Math.max(a+R.padding,R.cellHeight*2)}}var Ll={modules:"M4 4h6v6H4ZM14 4h6v6h-6ZM4 14h6v6H4ZM14 14h6v6h-6Z",code:"m8 5-6 7 6 7m8-14 6 7-6 7m-3-16-2 18",focus:"M8 3H4v4m12-4h4v4M4 17v4h4m12-4v4h-4M8 9h8v6H8Z",bug:"M9 5 7 2m8 3 2-3M8 9V7a4 4 0 0 1 8 0v2M6 9h12v6a6 6 0 0 1-12 0Zm6 0v12M2 10h4m12 0h4M2 15h4m12 0h4M4 21l3-3m10 0 3 3",flask:"M9 3h6m-5 0v7l-6 9q-1 2 2 2h12q3 0 2-2l-6-9V3M7 15h10",check:"m2 12 5 5L19 5M12 17l10-10",route:"M7 5h10a3 3 0 0 1 0 6H7a3 3 0 0 0 0 6h10M7 2a3 3 0 1 0 0 6 3 3 0 0 0 0-6m10 12a3 3 0 1 0 0 6 3 3 0 0 0 0-6",compass:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20m-3 7 8-2-2 8-8 2Z",flag:"M5 22V3q4-3 8 0t7 0v10q-3 3-7 0t-8 0",merge:"M6 2v8q0 5 6 5h6m-4-4 4 4-4 4M6 18v4M18 2v5",layers:"m12 2 10 6-10 6L2 8Zm-9 11 9 5 9-5M3 17l9 5 9-5",link:"m9 15 6-6m-7 4-2 2a4 4 0 0 0 6 6l3-3m1-5 2-2a4 4 0 0 0-6-6L9 8",shield:"m12 2 8 3v7q0 6-8 10-8-4-8-10V5Zm-4 9 3 3 5-6",question:"M8 7a4 4 0 1 1 6 4q-2 1-2 4m0 4v1M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",spark:"m12 2 3 7 7 3-7 3-3 7-3-7-7-3 7-3Z",search:"M10 3a7 7 0 1 0 0 14 7 7 0 0 0 0-14m5 12 6 6"},Dl={"design-deep-modules":"modules","typescript-type-safety":"code","scope-confirmed-changes":"focus","choose-by-consequence":"compass","write-plain-english":"spark","plan-with-review-page":"route","verify-review-findings":"search","refactor-boundaries":"layers","refactor-preserve":"shield","dependencies-existing":"link","dependencies-mature":"layers","diagnose-before-editing":"bug","tests-that-catch-bugs":"flask","research-primary-sources":"search","verify-and-review":"check","planning-first":"route","planning-when-costly":"compass","questions-autonomous":"flag","questions-early":"question","resolve-conflicts-by-intent":"merge"};function Ya(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.25"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true"),r.setAttribute("d",Ll[e]),t.append(r),t}function Xa(e){return Ya(Dl[e.id]??"spark")}function Qa(e){let t=e.toLowerCase(),n=Object.entries({engineering:"code",architecture:"modules",typescript:"code",workflow:"route",dependenc:"layers",testing:"flask",communication:"question",debugging:"bug",planning:"compass",research:"search",review:"check",setup:"spark"}).find(([o])=>t.includes(o))?.[1]??"compass";return Ya(n)}var jl="http://www.w3.org/2000/svg",Bt=()=>{return},ec="",tc=new Map,en=new Map;function ne(e){return document.createElementNS(jl,e)}function tt(e){let t=e.itemIds.map((r)=>tc.get(r)).filter((r)=>r!==void 0);return t.find(G)??t[0]}function Ft(e){let t=tt(e);return t?$e(t):e.title}function Bl(e){let t=tt(e);return!b.search||`${Ft(e)} ${t?.description??""}`.toLowerCase().includes(b.search.toLowerCase())}function Fl(e){let t=[""];for(let r of e.split(/\s+/)){let n=t.at(-1)??"";if(n&&n.length+r.length>=16)t.push(r);else t[t.length-1]=`${n} ${r}`.trim()}return t.slice(0,2).map((r,n)=>`${r.slice(0,17)}${n===1&&t.length>2||r.length>17?"…":""}`)}function Ul(e){let{node:t}=e,r=tt(t),n=ne("g"),o=t.kind==="skill"?26:t.kind==="root"?0:32,i=ne("text");if(n.setAttribute("class",`map-node map-node-${t.kind}`),n.setAttribute("transform",`translate(${t.x} ${t.y})`),t.kind==="skill"){let a=ne("rect");for(let[c,u]of Object.entries({x:"-26",y:"-26",width:"52",height:"52",class:"map-node-hit"}))a.setAttribute(c,u);n.append(a),n.setAttribute("role","button"),n.setAttribute("tabindex","0")}if(t.kind==="root"){let a=ne("circle");a.setAttribute("r","26"),n.append(a)}else{let a=ne("rect");for(let[c,u]of Object.entries({x:String(-o/2),y:String(-o/2),width:String(o),height:String(o),rx:"6",transform:"rotate(45)",class:"map-node-gem"}))a.setAttribute(c,u);n.append(a)}i.setAttribute("text-anchor","middle");for(let[a,c]of Fl(Ft(t)).entries()){let u=ne("tspan");u.setAttribute("x","0"),u.setAttribute("y",String((t.kind==="skill"?34:44)+a*16)),u.textContent=c,i.append(u)}let s=ne("title");if(s.textContent=Ft(t),n.append(s,i),t.kind==="root"){let a=document.querySelector(".brand-mark");if(a instanceof HTMLImageElement){let c=ne("image");for(let[u,l]of Object.entries({href:a.src,x:"-16",y:"-16",width:"32",height:"32"}))c.setAttribute(u,l);n.append(c)}}else{let a=ne("foreignObject"),c=g({tag:"span",className:"map-node-icon"});for(let[u,l]of Object.entries({x:"-9",y:"-9",width:"18",height:"18"}))a.setAttribute(u,l);c.append(r?Xa(r):Qa(t.title)),a.append(c),n.append(a)}if(t.kind==="skill"&&r){let a=()=>Bt(tt(t)??r);n.addEventListener("click",a),n.addEventListener("keydown",(c)=>{if(c.key==="Enter"||c.key===" ")c.preventDefault(),a()}),en.set(t.id,{node:t,element:n})}e.group.append(n)}function ql(e){if(!e.sibling)return`M${e.sourceX} ${e.sourceY}L${e.targetX} ${e.targetY}`;let t=(e.sourceX+e.targetX)/2;return`M${e.sourceX} ${e.sourceY-18}Q${t} ${e.sourceY-60} ${e.targetX} ${e.targetY-18}`}function Vl(){for(let{node:e,element:t}of en.values()){let r=tt(e),n=r?G(r):!1;t.classList.toggle("equipped",n),t.classList.toggle("active",r?.id===b.activeId),t.classList.toggle("search-miss",!Bl(e)),t.setAttribute("aria-pressed",String(n)),t.setAttribute("aria-label",`${Ft(e)}${r?.owner==="provider"?", managed by its plugin":n?", equipped":""}`)}}function tn(e){Bt=e.choose;let t=Kr("constellation-map"),r=b.view;if(!r)return;Ka({constellation:r.constellation,inspect:(i)=>{let s=r.items.find((a)=>a.id===i);if(s)Bt(s)}});let n=t.getBoundingClientRect().width;if(n<=0)return;tc=new Map(r.items.map((i)=>[i.id,i]));let o=JSON.stringify([Qr(n),r.constellation]);if(o!==ec){let i=Ha({constellation:r.constellation,width:n}),s=ne("g");ec=o,en.clear(),t.setAttribute("viewBox",`0 0 ${Math.round(n)} ${Math.round(i.height)}`),t.style.height=`${Math.round(i.height)}px`,t.replaceChildren(s);for(let a of i.links){let c=ne("path");c.setAttribute("class",a.sibling?"map-link sibling":"map-link"),c.setAttribute("d",ql(a)),s.append(c)}for(let a of i.nodes)Ul({group:s,node:a})}Vl()}function rc(){let e=Kr("constellation-map"),t=0;new ResizeObserver(()=>{let n=e.getBoundingClientRect().width;if(Math.round(n)!==Math.round(t))t=n,tn({choose:Bt})}).observe(e);let r=_("toggle-constellation-view");r.addEventListener("click",()=>{let n=_("constellation").classList.toggle("list-view");r.setAttribute("aria-pressed",String(n))})}var rn={squarePixelsPerStar:9000,maximumStars:600,attemptsPerStar:30};function nc(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let r=Math.imul(t^t>>>15,t|1);return r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}function oc(e){return Math.min(rn.maximumStars,Math.round(Math.max(0,e.width)*Math.max(0,e.height)/rn.squarePixelsPerStar))}function Jl(e){let t=Math.max(1,oc(e));return Math.sqrt(e.width*e.height/t)*0.55}function U(e){return e.low+e.random()*(e.high-e.low)}function Gl(e){let{random:t}=e,r=t()<0.08,n=t()*Math.PI*2,o=U({random:t,low:4,high:14});return{id:e.id,x:e.x,y:e.y,radius:r?U({random:t,low:1.4,high:1.9}):U({random:t,low:0.5,high:1.2}),brightness:U({random:t,low:0.35,high:1}),twinkleSeconds:U({random:t,low:3.5,high:14}),delaySeconds:-U({random:t,low:0,high:14}),driftX:Math.cos(n)*o,driftY:Math.sin(n)*o,driftSeconds:U({random:t,low:18,high:60}),sparkle:r}}function ic(e){let t=oc(e),r=Jl(e),n=e.existing.filter((l)=>l.x>=0&&l.x<=e.width&&l.y>=0&&l.y<=e.height).slice(0,t),o=[...n],i=r/Math.SQRT2,s=new Map,a=(l)=>`${Math.floor(l.x/i)}:${Math.floor(l.y/i)}`,c=(l)=>{let d=Math.floor(l.x/i),p=Math.floor(l.y/i);for(let h=-2;h<=2;h+=1)for(let m=-2;m<=2;m+=1){let x=s.get(`${d+h}:${p+m}`);if(x&&Math.hypot(x.x-l.x,x.y-l.y)<r)return!0}return!1},u=Math.max(0,...o.map((l)=>l.id+1));for(let l of n)s.set(a(l),l);for(let l=0;o.length<t&&l<t*rn.attemptsPerStar;l+=1){let d={x:e.random()*e.width,y:e.random()*e.height};if(c(d))continue;let p=Gl({id:u,...d,random:e.random});u+=1,o.push(p),s.set(a(p),p)}return o}function sc(e){if(e.reducedMotion||e.width<=0||e.height<=0)return null;let{random:t}=e;return{waitMilliseconds:U({random:t,low:9000,high:28000}),star:{x:U({random:t,low:e.width*0.1,high:e.width*0.9}),y:U({random:t,low:0,high:Math.min(e.height*0.5,600)}),angle:t()<0.5?U({random:t,low:20,high:40}):U({random:t,low:140,high:160}),length:U({random:t,low:70,high:140}),travel:U({random:t,low:220,high:380}),seconds:U({random:t,low:0.7,high:1.3})}}}var Ut="http://www.w3.org/2000/svg";function ac(e){for(let[t,r]of Object.entries(e.properties))e.element.style.setProperty(t,r)}function Kl(e){let t=document.createElementNS(Ut,"g"),r=document.createElementNS(Ut,"circle");if(t.setAttribute("class",e.sparkle?"star sparkle":"star"),t.setAttribute("transform",`translate(${e.x.toFixed(1)} ${e.y.toFixed(1)})`),r.setAttribute("r",e.radius.toFixed(2)),ac({element:t,properties:{"--brightness":e.brightness.toFixed(2),"--twinkle":`${e.twinkleSeconds.toFixed(2)}s`,"--delay":`${e.delaySeconds.toFixed(2)}s`,"--drift-x":`${e.driftX.toFixed(1)}px`,"--drift-y":`${e.driftY.toFixed(1)}px`,"--drift":`${e.driftSeconds.toFixed(1)}s`}}),t.append(r),e.sparkle){let n=document.createElementNS(Ut,"path");n.setAttribute("d","M-4 0h8M0 -4v8"),n.setAttribute("class","star-rays"),t.append(n)}return t}function cc(){let e=_("starfield"),t=nc(crypto.getRandomValues(new Uint32Array(1))[0]??Date.now()),r=window.matchMedia("(prefers-reduced-motion: reduce)"),n=new Map,o=[],i={width:0,height:0},s=!1,a=()=>{let l=e.getBoundingClientRect(),d=Math.max(1,Math.round(l.width)),p=Math.max(1,Math.round(l.height));if(d===i.width&&p===i.height)return;i={width:d,height:p},e.setAttribute("viewBox",`0 0 ${d} ${p}`),o=ic({width:d,height:p,existing:o,random:t});let h=new Set(o.map((m)=>m.id));for(let[m,x]of n)if(!h.has(m))x.remove(),n.delete(m);for(let m of o){if(n.has(m.id))continue;let x=Kl(m);n.set(m.id,x),e.append(x)}},c=()=>{let l=s?null:sc({...i,random:t,reducedMotion:r.matches});if(!l)return;s=!0,window.setTimeout(()=>{if(s=!1,!document.hidden&&!r.matches){let d=document.createElementNS(Ut,"line");d.setAttribute("class","shooting-star"),d.setAttribute("x2",l.star.travel.toFixed(0)),d.setAttribute("transform",`translate(${l.star.x.toFixed(0)} ${l.star.y.toFixed(0)}) rotate(${l.star.angle.toFixed(0)})`),ac({element:d,properties:{"--shoot":`${l.star.seconds.toFixed(2)}s`,"--length":`${l.star.length.toFixed(0)}px`,"--travel":`${l.star.travel.toFixed(0)}px`}}),d.addEventListener("animationend",()=>d.remove()),e.append(d)}c()},l.waitMilliseconds)},u=()=>{e.classList.toggle("paused",document.hidden)};document.addEventListener("visibilitychange",u),r.addEventListener("change",c),new ResizeObserver(a).observe(e),a(),u(),c()}var lh=O({name:y().trim().max(48),description:y().trim().max(300),body:y().trim().min(1).max(24000)}),uc=O({id:Mt(),destination:y(),payload:y(),limits:y(),cached:Ne.nullable()}),lc=O({skill:Ne});function qt(e){let t=!1,r=(n)=>{let o=e.getBoundingClientRect();return n.target===e&&(n.clientX<o.left||n.clientX>o.right||n.clientY<o.top||n.clientY>o.bottom)};e.addEventListener("pointerdown",(n)=>{t=r(n)}),e.addEventListener("click",(n)=>{if(t&&r(n))e.close();t=!1})}function dc(e){let t=g({tag:"dialog"}),r=g({tag:"div",className:"dialog-heading"}),n=g({tag:"button",className:"quiet-button",text:"✕"}),o=g({tag:"details",className:"file-change"}),i=g({tag:"div",className:"dialog-actions"}),s=g({tag:"p",className:"review-message"}),a=g({tag:"button",className:"quiet-button",text:"Keep editing"}),c=g({tag:"button",className:"primary-button",text:e.confirm}),u=new AbortController;t.setAttribute("aria-label",e.title),n.setAttribute("aria-label","Close model request"),s.setAttribute("role","status"),n.addEventListener("click",()=>t.close()),qt(t),r.append(g({tag:"h2",text:e.title}),n),o.append(g({tag:"summary",text:"Exact payload sent to the model"}),g({tag:"pre",text:e.review.payload})),a.addEventListener("click",()=>t.close()),t.addEventListener("close",()=>{u.abort(),t.remove()});async function l(){if(c.disabled)return;c.disabled=!0,c.textContent="Generating…",a.textContent="Cancel generation",s.textContent="Your model is working. You can cancel and keep your original draft.";try{let d=await Z({path:e.path,schema:e.schema,body:{previewId:e.review.id},signal:u.signal});if(!u.signal.aborted)e.accept(d),t.close()}catch(d){if(u.signal.aborted)return;s.className="review-warning",s.textContent=d instanceof Error?d.message:"Generation failed. Your draft is unchanged.",c.textContent="Request ended",a.textContent="Back to editing"}}c.addEventListener("click",()=>{l().catch(()=>{s.textContent="Generation failed. Return to editing to try again."})}),i.append(a,c),t.append(r,g({tag:"p",className:"review-message",text:`Destination: ${e.review.destination}`}),g({tag:"p",className:"review-message",text:e.review.limits}),g({tag:"p",className:"review-message",text:e.explanation}),o,s,i),document.body.append(t),t.showModal()}function Se(e){_("custom-status").textContent=e}async function Wl(){let e=pe("custom-body").value;if(!e.trim()){Se("Describe what your agent should do, then use AI to shape it into a skill."),pe("custom-body").focus();return}let t=await Z({path:"/api/skill/preview",schema:uc,body:{name:J("custom-name").value,description:J("custom-description").value,body:e}});dc({review:t,title:"Draft your skill with AI.",explanation:"Only the form fields below are sent. The result fills this form for you to edit; adding and applying it remain your choice.",confirm:"Send and draft",path:"/api/skill/generate",schema:lc,accept:({skill:r})=>{J("custom-name").value=r.name,J("custom-description").value=r.description,pe("custom-body").value=r.body,Se("AI draft ready. Edit the instructions before adding the skill to your build."),pe("custom-body").focus()}})}function pc(){let e=_("custom-ai");if(!(e instanceof HTMLButtonElement))return;e.addEventListener("click",()=>{if(e.disabled)return;e.disabled=!0,Se("Preparing your model request…"),Wl().catch((t)=>{Se(t instanceof Error?t.message:"Could not prepare an AI draft. Your text is unchanged.")}).finally(()=>{if(e.disabled=!1,_("custom-status").textContent==="Preparing your model request…")Se("")})})}var nn=!1;async function Re(e){if(nn)return;nn=!0;let t=document.querySelectorAll("button, input, select, textarea"),r=Array.from(t,(n)=>({control:n,disabled:n.disabled}));for(let{control:n}of r)n.disabled=!0;try{await e()}finally{for(let{control:n,disabled:o}of r)n.disabled=o;nn=!1}}function Pe(e){_(e.id).addEventListener("click",()=>Re(e.action).catch(fe))}function fc(){let e=document.createElement("template");e.innerHTML=`
67
+ <dialog id="review-dialog" aria-labelledby="review-title">
68
+ <div class="dialog-heading">
69
+ <div>
70
+ <p class="eyebrow">READY TO EQUIP</p>
71
+ <h2 id="review-title">Review your changes.</h2>
72
+ </div>
73
+ <button class="close-dialog quiet-button" aria-label="Close review">
74
+ ✕
75
+ </button>
76
+ </div>
77
+ <div id="review-content"></div>
78
+ <div class="dialog-actions">
79
+ <button class="close-dialog quiet-button">Keep editing</button>
80
+ <button id="apply" class="primary-button">Apply build</button>
81
+ </div>
82
+ </dialog>
83
+
84
+ <dialog id="custom-dialog" aria-labelledby="custom-title">
85
+ <div class="dialog-heading">
86
+ <h2 id="custom-title">Create a skill.</h2>
87
+ <button
88
+ class="close-dialog quiet-button"
89
+ aria-label="Close skill editor"
90
+ >
91
+ ✕
92
+ </button>
93
+ </div>
94
+ <form id="custom-form">
95
+ <label>
96
+ Skill name
97
+ <input
98
+ id="custom-name"
99
+ pattern="[a-z0-9]+(-[a-z0-9]+)*"
100
+ maxlength="48"
101
+ placeholder="review-with-evidence"
102
+ required
103
+ >
104
+ </label>
105
+ <label>
106
+ When should your agent use it?
107
+ <input
108
+ id="custom-description"
109
+ maxlength="300"
110
+ placeholder="Use when reviewing an implementation."
111
+ required
112
+ >
113
+ </label>
114
+ <label>
115
+ What should your agent do?
116
+ <textarea
117
+ id="custom-body"
118
+ rows="9"
119
+ maxlength="24000"
120
+ placeholder="Describe the decisions, steps, and evidence you expect."
121
+ required
122
+ ></textarea>
123
+ </label>
124
+ <p id="custom-status" class="review-message" role="status"></p>
125
+ <div class="dialog-actions">
126
+ <button id="custom-ai" type="button" class="quiet-button">✦ Use AI</button>
127
+ <button type="submit" class="primary-button">
128
+ Add to your build
129
+ </button>
130
+ </div>
131
+ </form>
132
+ </dialog>
133
+ `,document.body.append(e.content);for(let t of document.querySelectorAll("dialog"))qt(t)}var Hl=O({engine:Ce(["claude-code","codex","cursor-agent","pi"]),model:y().min(1).optional(),name:y()}),mc=O({choices:D(Hl),selected:ye({engine:y().optional(),model:y().optional()})});function hc(){let e=null;Pe({id:"load-models",action:async()=>{e=await Z({path:"/api/learning-models",schema:mc});let t=ce("learning-model"),r=g({tag:"option",text:"Choose a configured model"});if(r.value="",r.disabled=!0,r.selected=!e.choices.some((n)=>n.engine===e?.selected.engine&&n.model===e?.selected.model),t.replaceChildren(r,...e.choices.map((n,o)=>{let i=g({tag:"option",text:n.name});return i.value=String(o),i.selected=n.engine===e?.selected.engine&&n.model===e?.selected.model,i})),e.choices.length===0)Q({message:"Configure a model in your coding harness, then refresh models."})}}),ce("learning-model").addEventListener("change",()=>{let t=ce("learning-model").value;if(t==="")return;let r=e?.choices[Number(t)];if(!r)return;Re(async()=>{await Z({path:"/api/learning-model",schema:ye({saved:de()}),body:{engine:r.engine,model:r.model}}),Q({message:"Saved your learning model. Session learning follows the session model unless overridden.",success:!0})}).catch(fe)})}var Th=O({repository:y().regex(/^[\w.-]+\/[\w.-]+$/),name:y().trim().min(1).max(100),skills:D(y().regex(/^[a-z0-9-]+$/)).min(1).max(40)}),gc=ye({id:Mt(),repository:y(),repositoryId:Ur(),owner:y(),appOwner:y(),fingerprint:y(),bytes:Ur(),files:D(ye({path:y(),content:y()}))}),on=ye({repository:y().nullable(),skills:D(y()).default([]),app:ye({name:y(),installUrl:Fr()}).nullable(),pullUrl:Fr().nullable()}),yc=ye({action:Fr(),manifest:y()}),Yl=O({previewId:Mt()}),Rh=Yl.extend({token:y().trim().regex(/^sk-ant-oat01-[A-Za-z0-9_-]{20,500}$/)});function rt(e){let t=g({tag:"label",className:"field"}),r=g({tag:"input"});return r.value=e.value??"",r.type=e.type??"text",r.required=!0,t.append(g({tag:"span",text:e.label}),r),{label:t,input:r}}function Me(e){let t=g({tag:"button",className:"quiet-button bot-actions",text:e.text});return t.type="button",t.addEventListener("click",()=>{t.disabled=!0,e.status.textContent="Working…",e.action().catch((r)=>{e.status.textContent=r instanceof Error?r.message:"Setup failed."}).finally(()=>{t.disabled=!1})}),t}function bc(e){let{container:t,status:r,preview:n}=e;t.replaceChildren(),t.append(g({tag:"p",text:`Repository: ${n.repository} (ID ${n.repositoryId}). App owner: ${n.appOwner}. Requester: ${n.owner}. Guidance: ${n.bytes} encoded bytes.`})),t.append(g({tag:"p",text:"Review every file below. Approval uploads this exact bundle to a GitHub environment for Claude subscription runs. It also adds a ruleset so only people with write access can update the default branch. The default-branch workflow and code executed with credentials remain trusted."}));for(let s of n.files){let a=g({tag:"details"}),c=Uint8Array.from(atob(s.content),(l)=>l.charCodeAt(0)),u;try{u=new TextDecoder("utf-8",{fatal:!0}).decode(c)}catch{u=`Binary resource (${c.length} bytes), shown as base64:
134
+ ${s.content}`}a.append(g({tag:"summary",text:s.path}),g({tag:"pre",text:u})),t.append(a)}let o=g({tag:"input"}),i=g({tag:"label",className:"bot-consent"});o.type="checkbox",i.append(o,document.createTextNode("I reviewed the exact guidance and authorize its cloud use.")),t.append(i),t.append(Me({text:"Approve guidance and register my GitHub App",status:r,action:async()=>{if(!o.checked)throw Error("Review the files and select the approval checkbox.");let s=await Z({path:"/api/bot/manifest",body:{previewId:n.id},schema:yc}),a=g({tag:"form"}),c=g({tag:"input"});a.action=s.action,a.method="post",c.type="hidden",c.name="manifest",c.value=s.manifest,a.append(c),t.append(a),sessionStorage.setItem("shadowclone-bot-preview",n.id),a.submit()}})),r.textContent="Review the selected guidance before continuing."}function xc(){let e=g({tag:"dialog"});e.className="bot-dialog";let t=g({tag:"h2",text:"Your personal GitHub clone"}),r=g({tag:"div"}),n=g({tag:"p"}),o=g({tag:"button",className:"quiet-button",text:"Close"});t.id="bot-title",e.setAttribute("aria-labelledby",t.id),n.setAttribute("role","status"),o.addEventListener("click",()=>e.close()),e.append(t,r,n,o),document.body.append(e);async function i(){let a=await Z({path:"/api/bot/state",schema:on});if(r.replaceChildren(),a.pullUrl){let d=g({tag:"a",text:"Review the setup PR"});d.href=a.pullUrl,d.target="_blank",d.rel="noreferrer",r.append(d),n.textContent="The clone starts after you merge its setup PR. Create one small issue to verify the installation.";return}if(a.app){let d=g({tag:"a",text:`Install ${a.app.name} on GitHub`}),p=rt({label:"Claude subscription token",type:"password"}),h=g({tag:"input"}),m=g({tag:"label",className:"bot-consent"});d.href=a.app.installUrl,d.target="_blank",d.rel="noreferrer",p.input.autocomplete="off",h.type="checkbox",m.append(h,document.createTextNode("I authorize this repository to use my Claude subscription and the reviewed guidance.")),r.append(d,g({tag:"p",text:`Choose Only select repositories. Include ${a.repository}. Return to this tab after installation. All repositories is rejected.`}),g({tag:"p",text:"Run claude setup-token in your terminal. Use Safari for your personal Claude sign-in. Paste the resulting token below."}),p.label,m,Me({text:"Verify installation and create the setup PR",status:n,action:async()=>{let x=sessionStorage.getItem("shadowclone-bot-preview");if(!x||!h.checked)throw Error("Approve subscription use after reviewing the guidance.");let w=p.input.value.trim();p.input.value="",await Z({path:"/api/bot/activate",body:{previewId:x,token:w},schema:on}),await i()}})),n.textContent="GitHub controls account and organization installation approval.";return}let c=rt({label:"Repository (owner/repository)",value:new URLSearchParams(location.search).get("repository")??a.repository??""}),u=rt({label:"Clone name",value:"my-shadowclone"}),l=rt({label:"Selected skill names, separated by commas",value:a.skills.length?a.skills.join(", "):"shadowclone-work"});r.append(g({tag:"p",text:"Create a GitHub App that you own and name. Only selected repositories receive access. Owner issues start work; @shadowclone requests changes. You review and merge each PR."}),c.label,u.label,l.label,Me({text:"Preview the exact guidance",status:n,action:async()=>{let d=await Z({path:"/api/bot/preview",schema:gc,body:{repository:c.input.value.trim(),name:u.input.value.trim(),skills:l.input.value.split(",").map((p)=>p.trim()).filter(Boolean)}});bc({container:r,status:n,preview:d})}})),n.textContent="Start in this repository checkout with gh auth login and an active Shadowclone skills environment."}let s=Me({text:"GitHub clone",status:n,action:async()=>{e.showModal(),await i()}});if(document.querySelector(".toolbar")?.append(s),new URLSearchParams(location.search).get("bot")==="github")s.click()}var sn=y().min(1).max(200),Xl=O({traits:D(sn).min(3).max(8),do:D(sn).min(2).max(8),dont:D(sn).min(2).max(8)}),Ql=O({pullRequest:y().min(1).max(1500),reviewComment:y().min(1).max(700),commitMessage:y().min(1).max(200)}),vc=O({profile:Xl,samples:Ql});var Vt=O({consent:de(),allowed:de(),voiceFile:O({path:y(),state:Ce(["missing","file","link"]),target:y().nullable()})}),an=O({draft:vc,destination:y(),sourceCount:Ur().int().optional()}),wc=O({path:y()});var ed={pullRequest:"Invented pull request",reviewComment:"Invented review comment",commitMessage:"Invented commit message"},_c={traits:"Traits",do:"Do",dont:"Do not"};function kc(){let e=g({tag:"dialog"}),t=g({tag:"h2",text:"Your writing voice"}),r=g({tag:"p",text:"Shadowclone can read your own pull requests, review comments, and commit messages through your gh login, and ask your model to describe how you write. You see only that description and invented examples, never your writing itself."}),n=g({tag:"p",className:"voice-file"}),o=g({tag:"label",className:"voice-consent"}),i=g({tag:"input"}),s=g({tag:"button",className:"primary-button",text:"Read my writing and describe my voice"}),a=g({tag:"div",className:"voice-result"}),c=g({tag:"p",className:"review-message"}),u=g({tag:"button",className:"quiet-button",text:"Close"}),l=null,d=null,p=!1;e.className="voice-dialog",t.id="voice-title",e.setAttribute("aria-labelledby",t.id),c.setAttribute("role","status"),i.type="checkbox",i.id="voice-consent",o.append(i," Let Shadowclone read my GitHub writing for this"),e.append(t,r,n,o,s,a,c,u),document.body.append(e);let h=async(z)=>{c.textContent=z.message,e.setAttribute("aria-busy","true");try{await z.action()}catch(A){c.textContent=A instanceof Error?A.message:"The voice request failed."}finally{e.setAttribute("aria-busy","false"),m()}},m=()=>{let z=l?.voiceFile.state!=="missing";i.checked=l?.consent??!1,i.disabled=!l?.allowed,s.disabled=!l?.consent,n.textContent=!l?"":!l.allowed?"Your managed policy does not allow Shadowclone to read GitHub writing.":z?`${l.voiceFile.path} already exists${l.voiceFile.target?` as a link to ${l.voiceFile.target}`:""}. Shadowclone will not change it.`:`Saving writes ${l.voiceFile.path}.`;for(let A of a.querySelectorAll("[data-action=save]"))A.disabled=z;for(let A of a.querySelectorAll("[data-action=rewrite]"))A.disabled=!p},x=()=>{let z=(A)=>[...a.querySelectorAll(`input[data-list=${A}]`)].map((B)=>B.value.trim()).filter(Boolean);return{traits:z("traits"),do:z("do"),dont:z("dont")}},w=(z)=>{if(a.replaceChildren(),p=!1,!d)return;a.append(g({tag:"p",className:"voice-source",text:`Described by ${z.destination}${z.sourceCount?` from ${z.sourceCount} pieces of your writing`:""}. Edit any line, then rewrite the samples.`}));for(let E of["traits","do","dont"]){let q=g({tag:"fieldset"});q.append(g({tag:"legend",text:_c[E]}));for(let be of d.profile[E]){let Y=g({tag:"input"});Y.value=be,Y.dataset.list=E,Y.setAttribute("aria-label",`${_c[E]} line`),Y.addEventListener("input",()=>{p=!0,m()}),q.append(Y)}a.append(q)}for(let E of["pullRequest","reviewComment","commitMessage"])a.append(g({tag:"h3",text:ed[E]}),g({tag:"pre",text:d.samples[E]}));let A=g({tag:"div",className:"dialog-actions"}),B=g({tag:"button",className:"quiet-button",text:"Discard"}),I=g({tag:"button",className:"quiet-button",text:"Rewrite the samples"}),k=g({tag:"button",className:"primary-button",text:"Save my voice"});I.dataset.action="rewrite",k.dataset.action="save",B.addEventListener("click",()=>{d=null,a.replaceChildren(),c.textContent="Discarded. Nothing was saved."}),I.addEventListener("click",()=>h({message:"Rewriting the samples with your fast model…",action:async()=>{let E=await Z({path:"/api/voice/rewrite",schema:an,body:{profile:x()}});d=E.draft,w({destination:E.destination}),c.textContent="The samples now follow your edits."}})),k.addEventListener("click",()=>h({message:"Saving…",action:async()=>{if(!d)return;let E=await Z({path:"/api/voice/save",schema:wc,body:{...d,profile:x()}});l=await Z({path:"/api/voice/status",schema:Vt,body:{}}),c.textContent=`Saved ${E.path}.`}})),A.append(B,I,k),a.append(A),m()};i.addEventListener("change",()=>h({message:i.checked?"Saving your consent…":"Turning reading off…",action:async()=>{l=await Z({path:"/api/voice/consent",schema:Vt,body:{enabled:i.checked}}),c.textContent=l.consent?"Shadowclone may read your GitHub writing.":"Reading is off. Collected writing was discarded."}})),s.addEventListener("click",()=>h({message:"Reading your writing and asking your model. This can take a minute…",action:async()=>{let z=await Z({path:"/api/voice/capture",schema:an,body:{}});d=z.draft,w(z),c.textContent="Review the description and the invented examples."}})),u.addEventListener("click",()=>e.close());let S=g({tag:"button",className:"quiet-button",text:"My voice"});S.addEventListener("click",()=>{e.showModal(),h({message:"",action:async()=>{l=await Z({path:"/api/voice/status",schema:Vt,body:{}})}}).catch(fe)}),document.querySelector(".toolbar")?.append(S)}fc();hc();xc();kc();function nt(){tn({choose:(e)=>{if(b.activeId=e.id,e.owner!=="provider")et(e);nt()}}),Ra({rerender:nt,companion:Wr}),qa(),_("undo").hidden=b.view?.revisionId===null}async function td(e){let t=await Z({path:`/api/build?scope=${e}`,schema:Ea});if(b.view=t,b.input=structuredClone(t.input),b.dirty=!1,!t.items.some((n)=>n.id===b.activeId))b.activeId=t.items.find(G)?.id??t.items[0]?.id??"";ce("scope").value=e;let r={global:"Your personal build follows you across coding agents.",private:"Only this repository. Stored privately on your machine; shared requirements stay in force.",shared:"A portable build for this repository. Review every file before sharing it with your team."};if(_("scope-note").textContent=r[e],_("library-note").hidden=t.libraryEnabled,t.migrationRequired)Q({message:"Your existing profile needs its reviewed skills migration before this build can be applied. You can explore the editor now."});nt()}async function ot(e){let t=_("constellation-status"),r=_("retry-build");if(!r.hidden)Q({message:""});t.hidden=!1,r.hidden=!0,_("constellation-status-text").textContent="Loading your skills…",_("constellation").setAttribute("aria-busy","true");try{await td(e),t.hidden=!0}catch(n){throw _("constellation-status-text").textContent="Your skills couldn't be loaded. Retry to reconnect to the local editor.",r.hidden=!1,ce("scope").value=b.input.scope,n}finally{_("constellation").setAttribute("aria-busy","false")}}Pe({id:"retry-build",action:()=>ot(b.input.scope)});Pe({id:"review",action:Va});Pe({id:"apply",action:async()=>{await Ja(),await ot(b.input.scope)}});Pe({id:"undo",action:async()=>{await Ga(),await ot(b.input.scope)}});_("new-skill").addEventListener("click",()=>Wr());_("custom-form").addEventListener("submit",(e)=>{e.preventDefault();try{Na(),nt()}catch(t){Se(t instanceof Error?t.message:"The skill could not be added.")}});J("search").addEventListener("input",()=>{b.search=J("search").value,nt()});ce("scope").addEventListener("change",()=>{if(b.dirty&&!window.confirm("Discard the draft and switch build scope?")){ce("scope").value=b.input.scope;return}let e=Ae.parse(ce("scope").value);Re(()=>ot(e)).catch(fe)});for(let e of document.querySelectorAll(".close-dialog"))e.addEventListener("click",()=>e.closest("dialog")?.close());window.addEventListener("beforeunload",(e)=>{if(b.dirty)e.preventDefault()});var zc=Ae.safeParse(new URLSearchParams(location.search).get("scope")??"global");cc();rc();Ua();pc();Re(()=>ot(zc.success?zc.data:"global")).catch(fe);