@roxyapi/ui 0.19.4 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/AGENTS.md +10 -7
  2. package/README.md +9 -6
  3. package/components-catalog.json +166 -114
  4. package/dist/cdn/components/arudha-padas.js +313 -0
  5. package/dist/cdn/components/arudha-padas.js.map +7 -0
  6. package/dist/cdn/components/chara-karakas.js +313 -0
  7. package/dist/cdn/components/chara-karakas.js.map +7 -0
  8. package/dist/cdn/components/dasha-timeline.js +4 -4
  9. package/dist/cdn/components/dasha-timeline.js.map +4 -4
  10. package/dist/cdn/components/endpoint-form.js +1 -1
  11. package/dist/cdn/components/endpoint-form.js.map +1 -1
  12. package/dist/cdn/components/kp-chart.js +4 -4
  13. package/dist/cdn/components/kp-chart.js.map +4 -4
  14. package/dist/cdn/components/kp-ruling-planets.js +3 -3
  15. package/dist/cdn/components/kp-ruling-planets.js.map +4 -4
  16. package/dist/cdn/components/reference-card.js +3 -3
  17. package/dist/cdn/components/reference-card.js.map +2 -2
  18. package/dist/cdn/components/upagraha-table.js +313 -0
  19. package/dist/cdn/components/upagraha-table.js.map +7 -0
  20. package/dist/cdn/components/vedic-planets-table.js +2 -2
  21. package/dist/cdn/components/vedic-planets-table.js.map +2 -2
  22. package/dist/cdn/components/yoga-list.js +4 -4
  23. package/dist/cdn/components/yoga-list.js.map +3 -3
  24. package/dist/cdn/roxy-ui.js +78 -78
  25. package/dist/cdn/roxy-ui.js.map +4 -4
  26. package/dist/cdn/widgets.js +1 -1
  27. package/dist/components/arudha-padas.d.ts +22 -0
  28. package/dist/components/arudha-padas.d.ts.map +1 -0
  29. package/dist/components/arudha-padas.js +2 -0
  30. package/dist/components/arudha-padas.js.map +7 -0
  31. package/dist/components/chara-karakas.d.ts +22 -0
  32. package/dist/components/chara-karakas.d.ts.map +1 -0
  33. package/dist/components/chara-karakas.js +2 -0
  34. package/dist/components/chara-karakas.js.map +7 -0
  35. package/dist/components/dasha-timeline.d.ts +18 -13
  36. package/dist/components/dasha-timeline.d.ts.map +1 -1
  37. package/dist/components/dasha-timeline.js +1 -1
  38. package/dist/components/dasha-timeline.js.map +4 -4
  39. package/dist/components/endpoint-form.js +1 -1
  40. package/dist/components/endpoint-form.js.map +1 -1
  41. package/dist/components/kp-chart.d.ts +7 -0
  42. package/dist/components/kp-chart.d.ts.map +1 -1
  43. package/dist/components/kp-chart.js +1 -1
  44. package/dist/components/kp-chart.js.map +4 -4
  45. package/dist/components/kp-ruling-planets.d.ts +6 -0
  46. package/dist/components/kp-ruling-planets.d.ts.map +1 -1
  47. package/dist/components/kp-ruling-planets.js +1 -1
  48. package/dist/components/kp-ruling-planets.js.map +4 -4
  49. package/dist/components/reference-card.d.ts +2 -2
  50. package/dist/components/reference-card.d.ts.map +1 -1
  51. package/dist/components/reference-card.js +1 -1
  52. package/dist/components/reference-card.js.map +2 -2
  53. package/dist/components/upagraha-table.d.ts +22 -0
  54. package/dist/components/upagraha-table.d.ts.map +1 -0
  55. package/dist/components/upagraha-table.js +2 -0
  56. package/dist/components/upagraha-table.js.map +7 -0
  57. package/dist/components/vedic-planets-table.d.ts +10 -1
  58. package/dist/components/vedic-planets-table.d.ts.map +1 -1
  59. package/dist/components/vedic-planets-table.js +1 -1
  60. package/dist/components/vedic-planets-table.js.map +2 -2
  61. package/dist/components/yoga-list.d.ts +13 -2
  62. package/dist/components/yoga-list.d.ts.map +1 -1
  63. package/dist/components/yoga-list.js +1 -1
  64. package/dist/components/yoga-list.js.map +3 -3
  65. package/dist/generated/endpoint-bindings.d.ts.map +1 -1
  66. package/dist/index.cjs +46 -46
  67. package/dist/index.cjs.map +4 -4
  68. package/dist/index.d.ts +3 -0
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +51 -51
  71. package/dist/index.js.map +4 -4
  72. package/dist/manifest.d.ts.map +1 -1
  73. package/dist/manifest.json +3 -0
  74. package/dist/schemas/get--astrology-horoscope-sign-daily.json +1 -1
  75. package/dist/schemas/get--astrology-horoscope-sign-monthly.json +1 -1
  76. package/dist/schemas/get--astrology-horoscope-sign-weekly.json +1 -1
  77. package/dist/schemas/get--astrology-moon-phase-current.json +1 -1
  78. package/dist/schemas/get--vedic-astrology-avasthas-id.json +1 -0
  79. package/dist/schemas/get--vedic-astrology-avasthas.json +1 -0
  80. package/dist/schemas/get--vedic-astrology-kp-ayanamsa.json +1 -1
  81. package/dist/schemas/get--vedic-astrology-yoga-id.json +1 -1
  82. package/dist/schemas/post--vedic-astrology-arudha.json +1 -0
  83. package/dist/schemas/post--vedic-astrology-birth-chart.json +1 -1
  84. package/dist/schemas/post--vedic-astrology-chara-karakas.json +1 -0
  85. package/dist/schemas/post--vedic-astrology-dasha-current.json +1 -1
  86. package/dist/schemas/post--vedic-astrology-dasha-major.json +1 -1
  87. package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha-antardasha-pratyantardasha-sookshma.json +1 -0
  88. package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha-antardasha-pratyantardasha.json +1 -1
  89. package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha-antardasha.json +1 -1
  90. package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha.json +1 -1
  91. package/dist/schemas/post--vedic-astrology-kp-chart.json +1 -1
  92. package/dist/schemas/post--vedic-astrology-kp-cusps.json +1 -1
  93. package/dist/schemas/post--vedic-astrology-kp-ruling-planets-interval.json +1 -1
  94. package/dist/schemas/post--vedic-astrology-kp-ruling-planets.json +1 -1
  95. package/dist/types/index.d.ts +1 -1
  96. package/dist/types/index.d.ts.map +1 -1
  97. package/dist/types/types.gen.d.ts +3228 -934
  98. package/dist/types/types.gen.d.ts.map +1 -1
  99. package/dist/utils/house-themes.d.ts +19 -0
  100. package/dist/utils/house-themes.d.ts.map +1 -0
  101. package/dist/version.d.ts +1 -1
  102. package/package.json +1 -1
  103. package/src/components/arudha-padas.ts +230 -0
  104. package/src/components/chara-karakas.ts +241 -0
  105. package/src/components/dasha-timeline.ts +129 -28
  106. package/src/components/kp-chart.ts +40 -5
  107. package/src/components/kp-ruling-planets.ts +29 -6
  108. package/src/components/reference-card.ts +3 -1
  109. package/src/components/upagraha-table.ts +182 -0
  110. package/src/components/vedic-planets-table.ts +34 -4
  111. package/src/components/yoga-list.ts +144 -20
  112. package/src/generated/endpoint-bindings.ts +13 -0
  113. package/src/index.ts +3 -0
  114. package/src/manifest.ts +48 -7
  115. package/src/types/index.ts +1 -1
  116. package/src/types/types.gen.ts +3133 -809
  117. package/src/utils/house-themes.ts +36 -0
  118. package/src/version.ts +1 -1
@@ -1,2 +1,2 @@
1
- var _=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var p=(n,i,e,r)=>{for(var t=r>1?void 0:r?G(i,e):i,o=n.length-1,a;o>=0;o--)(a=n[o])&&(t=(r?a(i,e,t):a(t))||t);return r&&t&&_(i,e,t),t};import{css as Q,html as c,LitElement as J,nothing as g}from"lit";import{customElement as Z,property as h,state as y}from"lit/decorators.js";import{ifDefined as A}from"lit/directives/if-defined.js";var O={Aries:"\u2648",Taurus:"\u2649",Gemini:"\u264A",Cancer:"\u264B",Leo:"\u264C",Virgo:"\u264D",Libra:"\u264E",Scorpio:"\u264F",Sagittarius:"\u2650",Capricorn:"\u2651",Aquarius:"\u2652",Pisces:"\u2653"};var L=["Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius","Capricorn","Aquarius","Pisces"];import{css as B}from"lit";var q=B`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;import{css as H,html as j}from"lit";function $(){return j`<svg class="roxy-chevron" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`}var R=H`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;function M(n){return n?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():""}function m(n){return n.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([a-z])([0-9])/g,"$1 $2").replace(/^\w/,i=>i.toUpperCase())}var V=12,b=["latitude","longitude","timezone"],U=L.map(n=>n.toLowerCase());function v(n,i){if(n){if("$ref"in n&&n.$ref){let e=n.$ref.split("/").pop();return e?i[e]:void 0}return n}}function E(n){let i=n.anyOf??n.oneOf;return!i||i.length===0?n:i.find(e=>Array.isArray(e.enum))??i.find(e=>e.type&&e.type!=="null")??i[0]??n}function K(n){let i=E(n);return Array.isArray(i.enum)?i.enum.length<=V?"tiles":"select":i.type==="boolean"?"toggle":i.format==="date"?"date":i.format==="time"?"time":i.format==="date-time"?"datetime":i.type==="integer"||i.type==="number"?"number":i.type==="string"?"text":i.type==="array"?"array":null}function T(n){if(n.length!==12)return!1;let i=new Set(n.map(e=>e.toLowerCase()));return U.every(e=>i.has(e))}function w(n,i,e){let r=E(i);return{key:e.key,name:n,group:e.group,inQuery:e.inQuery,kind:K(i)??"text",required:e.required,description:r.description??i.description,enum:r.enum,min:r.minimum,max:r.maximum,default:i.default??r.default,example:i.example??r.example}}function C(n,i,e){let r=[],t=!1,o=n.requestBody?.content?.["application/json"]?.schema,a=v(o,i);if(a?.properties){let s=new Set(a.required??[]);for(let[d,l]of Object.entries(a.properties)){let f=v(l,i)??{};if(f.type==="object"&&f.properties){let x=new Set(f.required??[]);for(let[S,P]of Object.entries(f.properties)){let N=v(P,i)??{};r.push(w(S,N,{key:`${d}.${S}`,group:d,required:s.has(d)&&x.has(S)}))}}else r.push(w(d,f,{key:d,required:s.has(d)}))}}for(let s of n.parameters??[]){if(s.in!=="path"&&s.in!=="query")continue;if(s.name==="lang"&&s.in==="query"){t=!0;continue}let d=v(s.schema,i)??{};r.push(w(s.name,d,{key:s.name,required:!!s.required,inQuery:s.in==="query"}))}return{title:Y(n.summary,e),fields:r,hasLang:t}}function Y(n,i){let e=n?.split(" - ")[0]?.trim();return e||m(i.split("/").pop()??"")}function z(n){let i=n.toLowerCase();return/compat|synastry|guna|connection|penta|composite/.test(i)?"Compare":/\bcast\b|\/draw|iching|hexagram|tarot/.test(i)?"Cast":/horoscope|dream|angel|nakshatra|crystal|meaning|reference/.test(i)?"Get reading":"Generate"}function D(n,i){let e=i.replace(/^\//,"").replace(/[{}]/g,"").replace(/\//g,"-");return`${n.toLowerCase()}--${e}.json`}var F="0.19.4";var I="https://roxyapi.com/api/v2/openapi.json",W=`https://cdn.jsdelivr.net/npm/@roxyapi/ui@${F}/dist/schemas`,k=new Map;function Se(){k.clear()}async function X(n){let i=k.get(n);return i||(i=fetch(n).then(async e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}).catch(e=>{throw k.delete(n),e}),k.set(n,i)),i}function ee(){return globalThis.crypto?.randomUUID?.()??Math.random().toString(36).slice(2)}function re(n){let i=n.trim();if(!i)return[];try{let e=JSON.parse(i);if(Array.isArray(e))return e}catch{}return i.split(",").map(e=>e.trim()).filter(Boolean)}var u=class extends J{constructor(){super(...arguments);this.endpoint="vedic-astrology/birth-chart";this.method="POST";this.specUrl="";this.submitLabel="";this.fields=[];this.formTitle="";this.hasLang=!1;this.values={};this.loaded=!1;this.specError=null;this.validationErrors=[];this.retryLoadSchema=()=>{this.loaded=!1,this.specError=null,this.loadSchema()};this.onSubmit=e=>{e.preventDefault(),this.submit()}}connectedCallback(){super.connectedCallback(),this.loadSchema()}async loadSchema(){this.specError=null;try{this.applyModel(await this.resolveModel())}catch(e){let r=e instanceof Error?e.message:String(e);this.specError=r,this.loaded=!0,this.dispatchEvent(new CustomEvent("roxy-spec-error",{detail:{url:this.specUrl||I,message:r},bubbles:!0,composed:!0}))}}async resolveModel(){return this.specUrl?this.modelFromSpec(this.specUrl):await this.tryLoadSlice()??this.modelFromSpec(I)}async modelFromSpec(e){let r=await X(e),t=`/${this.endpoint.replace(/^\//,"")}`,o=r.paths?.[t]?.[this.method.toLowerCase()];if(!o)throw new Error(`Endpoint ${this.method} ${t} not found in OpenAPI spec`);return C(o,r.components?.schemas??{},this.endpoint)}async tryLoadSlice(){try{let e=await fetch(`${W}/${D(this.method,this.endpoint)}`);return e.ok?await e.json():null}catch{return null}}applyModel(e){this.fields=e.fields,this.formTitle=e.title,this.hasLang=e.hasLang;let r={};for(let t of e.fields){t.default!==void 0&&(r[t.key]=t.default);let o=t.group?this.initialValues?.[t.group]?.[t.name]:this.initialValues?.[t.name];o!==void 0&&(r[t.key]=o)}this.values=r,this.loaded=!0}setValue(e,r){this.values={...this.values,[e]:r}}roleOf(e){return e.name==="seed"?"seed":(e.name==="limit"||e.name==="offset")&&!e.required?"hidden-default":b.includes(e.name)&&this.groupHasLocation(e.group)?"location":"normal"}isRendered(e){return this.roleOf(e)==="normal"}groupKeys(){let e=[];for(let r of this.fields)e.includes(r.group)||e.push(r.group);return e}groupHasLocation(e){let r=this.fields.filter(t=>t.group===e);return b.every(t=>r.some(o=>o.name===t))}locationRequired(e){let r=this.fields.filter(t=>t.group===e);return b.some(t=>r.some(o=>o.name===t&&o.required))}groupIsRequired(e){return this.groupHasLocation(e)||this.fields.some(r=>r.group===e&&r.required)}get singleEnumField(){if(this.groupKeys().some(t=>this.groupHasLocation(t))||this.groupKeys().some(t=>t!==void 0))return null;let e=this.fields.filter(t=>t.required&&this.isRendered(t)),r=e[0];return e.length!==1||!r?null:r.kind==="tiles"||r.kind==="select"?r:null}effectiveSubmitLabel(){return this.submitLabel||z(this.endpoint)}effectiveLang(){return this.lang||void 0}onLocationFor(e){let r=e?`${e}.`:"";return t=>{let o=t.detail;o&&(this.values={...this.values,[`${r}latitude`]:o.latitude,[`${r}longitude`]:o.longitude,[`${r}timezone`]:o.timezone??o.utcOffset})}}selectTile(e,r){this.setValue(e.key,r),this.singleEnumField?.key===e.key&&this.submit()}onTilesKeyDown(e){return r=>{let t=e.enum??[];if(t.length===0)return;let o=t.indexOf(this.values[e.key]),a;if(r.key==="Home")a=0;else if(r.key==="End")a=t.length-1;else if(r.key==="ArrowRight"||r.key==="ArrowDown")a=o===-1?0:(o+1)%t.length;else if(r.key==="ArrowLeft"||r.key==="ArrowUp")a=o===-1?t.length-1:(o-1+t.length)%t.length;else return;r.preventDefault();let s=t[a];if(s===void 0)return;this.selectTile(e,s);let d=r.currentTarget;requestAnimationFrame(()=>d.querySelector(`[data-tile='${a}']`)?.focus())}}submit(){let e=this.collectMissing();if(e.keys.length>0){this.validationErrors=e.labels,this.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{missing:e.keys},bubbles:!0,composed:!0}));return}this.validationErrors=[];let r={};for(let a of this.fields){let s=this.values[a.key];if(a.name==="seed"&&(s===void 0||s==="")&&(s=ee()),!(s===void 0||s===""))if(a.kind==="array"&&typeof s=="string"&&(s=re(s)),a.group){let d=r[a.group]??{};d[a.name]=s,r[a.group]=d}else r[a.name]=s}let t=this.fields.filter(a=>a.inQuery).map(a=>a.name),o=this.effectiveLang();this.hasLang&&o&&(r.lang=o,t.push("lang")),this.dispatchEvent(new CustomEvent("roxy-submit",{detail:{endpoint:this.endpoint,values:r,queryKeys:t,sticky:this.singleEnumField!=null},bubbles:!0,composed:!0}))}collectMissing(){let e=[],r=[],t=new Set;for(let o of this.fields){if(!o.required)continue;let a=this.roleOf(o)==="location";if(!this.isRendered(o)&&!a)continue;let s=this.values[o.key];if(!(s!==void 0&&s!=="")){if(e.push(o.key),a){t.add(o.group);continue}r.push(o.group?`${m(o.group)} ${m(o.name)}`:m(o.name))}}for(let o of t)r.push(o?`${m(o)} location`:"Birth location");return{keys:e,labels:r}}reqMark(e){return e.required?c`<span class="req" aria-hidden="true">*</span>`:g}description(e){if(!e.description)return g;if(e.description.length<=120)return c`<small class="help">${e.description}</small>`;let r=e.description.split(". ")[0]??e.description;return c`<details class="help-details"><summary><span class="help-lead">${r}</span>${$()}</summary><small class="help help-full">${e.description}</small></details>`}renderTiles(e){let r=`roxy-form-${e.key}-label`,t=!!e.enum&&T(e.enum),o=e.enum??[],a=o.indexOf(this.values[e.key]),s=a===-1?0:a;return c`<div class="field tiles-field"><span class="label" id="${r}">${m(e.name)}${this.reqMark(e)}</span><div class="tiles" role="radiogroup" aria-labelledby="${r}" @keydown="${this.onTilesKeyDown(e)}">${o.map((d,l)=>{let f=this.values[e.key]===d,x=t?O[M(d)]:void 0;return c`<button type="button" class="tile" role="radio" data-tile="${l}" aria-checked="${f?"true":"false"}" tabindex="${l===s?"0":"-1"}" @click="${()=>this.selectTile(e,d)}">${x?c`<span class="tile-glyph" aria-hidden="true">${x}</span>`:g} <span class="tile-label">${m(d)}</span></button>`})}</div>${this.description(e)}</div>`}renderSelect(e){let r=`roxy-form-${e.key}`;return c`<div class="field"><label for="${r}">${m(e.name)}${this.reqMark(e)}</label> <select id="${r}" ?required="${e.required}" @change="${t=>this.setValue(e.key,t.target.value)}"><option value="">Choose</option>${(e.enum??[]).map(t=>c`<option value="${t}" ?selected="${this.values[e.key]===t}">${m(t)}</option>`)}</select> ${this.description(e)}</div>`}renderToggle(e){let r=`roxy-form-${e.key}`,t=this.values[e.key]===!0;return c`<div class="field"><div class="toggle-row"><button type="button" id="${r}" class="toggle" role="switch" aria-checked="${t?"true":"false"}" @click="${()=>this.setValue(e.key,!t)}"><span class="knob"></span></button> <label class="toggle-label" for="${r}">${m(e.name)}${this.reqMark(e)}</label></div>${this.description(e)}</div>`}renderInput(e){let r=`roxy-form-${e.key}`,t=e.kind==="datetime"?"datetime-local":e.kind==="number"?"number":e.kind,o=e.kind==="array"?"Comma separated":e.example!=null?String(e.example):"";return c`<div class="field"><label for="${r}">${m(e.name)}${this.reqMark(e)}</label> <input id="${r}" type="${e.kind==="array"?"text":t}" ?required="${e.required}" min="${A(e.min)}" max="${A(e.max)}" step="${e.kind==="number"?"any":g}" placeholder="${o||g}" .value="${this.values[e.key]??""}" @input="${a=>this.setValue(e.key,this.coerce(e.kind,a.target.value))}"> ${this.description(e)}</div>`}renderField(e){switch(e.kind){case"tiles":return this.renderTiles(e);case"select":return this.renderSelect(e);case"toggle":return this.renderToggle(e);default:return this.renderInput(e)}}locationBlock(e){return c`<div class="location-block"><label>${e?`${m(e)} location`:"Birth location"}${this.locationRequired(e)?c`<span class="req" aria-hidden="true">*</span>`:g}</label><roxy-location-search publishable-key="${A(this.publishableKey)}" @roxy-location-select="${this.onLocationFor(e)}" placeholder="City of birth"></roxy-location-search><small class="help">Required: latitude, longitude, timezone. Pick a city to autofill.</small></div>`}groupCard(e){let r=this.fields.filter(t=>t.group===e&&this.isRendered(t));return c`<fieldset class="person-group"><legend>${m(e)}</legend>${this.groupHasLocation(e)?this.locationBlock(e):g}<div class="fields">${r.map(t=>this.renderField(t))}</div></fieldset>`}render(){if(!this.loaded)return c`<form><div class="roxy-skeleton" style="height:8rem"></div></form>`;if(this.specError)return c`<div class="spec-error" role="alert">Schema load failed: ${this.specError} <button type="button" class="submit" @click="${this.retryLoadSchema}">Retry</button></div>`;let e=this.fields.filter(l=>!l.group&&this.isRendered(l)),r=e.filter(l=>l.required),t=e.filter(l=>!l.required),o=this.groupKeys().filter(l=>l!==void 0),a=o.filter(l=>this.groupIsRequired(l)),s=o.filter(l=>!this.groupIsRequired(l)),d=t.length>0||s.length>0;return c`<form @submit="${this.onSubmit}"><h2 class="title">${this.formTitle}</h2>${this.validationErrors.length>0?c`<div class="validation-error" role="alert"><strong>Please complete:</strong> ${this.validationErrors.join(", ")}</div>`:g}<div class="fields">${r.map(l=>this.renderField(l))}</div>${this.groupHasLocation(void 0)?this.locationBlock(void 0):g} ${a.map(l=>this.groupCard(l))} ${d?c`<details class="advanced"><summary>Advanced${$()}</summary><div class="fields">${t.map(l=>this.renderField(l))}</div>${s.map(l=>this.groupCard(l))}</details>`:g} ${this.singleEnumField?g:c`<button class="submit" type="submit">${this.effectiveSubmitLabel()}</button>`}</form>`}coerce(e,r){if(r!==""){if(e==="number"){let t=Number(r);return Number.isFinite(t)?t:void 0}return r}}};u.styles=[q,R,Q`form{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);box-shadow:var(--roxy-shadow-sm);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.fields{align-items:start;gap:var(--roxy-space-md,1rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));display:grid}.fields:empty{display:none}.person-group{background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);gap:var(--roxy-space-md,1rem);min-inline-size:0;margin:0;display:grid}.person-group legend{padding:0 var(--roxy-space-xs,.25rem);font-weight:var(--roxy-weight-bold,600)}.field{gap:var(--roxy-space-xs,.25rem);flex-direction:column;min-width:0;display:flex}.tiles-field{grid-column:1/-1}label,.label{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-secondary,#475569)}.req{color:var(--roxy-danger-fg,#991b1b);margin-left:4px}input,select{box-sizing:border-box;width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);font-family:inherit}input:focus,select:focus{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-color:var(--roxy-accent-ink,#b45309)}.help{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem)}.help-details>summary{cursor:pointer;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);align-items:center;gap:4px;display:flex}.help-details .help-lead{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.help-details .help-full{margin-top:var(--roxy-space-xs,.25rem);display:block}.location-block{gap:var(--roxy-space-xs,.25rem);grid-column:1/-1;display:grid}.tiles{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(5.5rem,1fr));display:grid}.tile{min-height:44px;padding:var(--roxy-space-sm,.5rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;transition:border-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease), background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-direction:column;justify-content:center;align-items:center;gap:2px;display:flex}.tile:hover{border-color:var(--roxy-accent,#f59e0b)}.tile[aria-checked=true]{border-color:var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 12%, transparent);color:var(--roxy-accent-ink,#b45309);font-weight:var(--roxy-weight-bold,600)}.tile:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.tile-glyph{font-size:1.35em;line-height:1}.toggle-row{align-items:center;gap:var(--roxy-space-sm,.5rem);display:flex}.toggle{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);background:var(--roxy-border,#e4e4e7);cursor:pointer;width:44px;height:26px;transition:background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0;padding:0;position:relative}.toggle[aria-checked=true]{background:var(--roxy-accent,#f59e0b);border-color:var(--roxy-accent,#f59e0b)}.toggle .knob{background:var(--roxy-bg,#fff);width:20px;height:20px;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);border-radius:50%;position:absolute;top:2px;left:2px}.toggle[aria-checked=true] .knob{transform:translate(18px)}.toggle:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.toggle-label{cursor:pointer}@media (prefers-reduced-motion:reduce){.tile,.toggle,.toggle .knob{transition:none}}.advanced{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.advanced>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a);align-items:center;gap:6px;display:flex}.advanced[open]>summary{margin-bottom:var(--roxy-space-md,1rem)}.advanced .fields,.advanced .person-group{margin-top:var(--roxy-space-md,1rem)}.validation-error{gap:var(--roxy-space-xs,.25rem);padding:var(--roxy-space-md,1rem);background:color-mix(in srgb, var(--roxy-danger,#dc2626) 8%, transparent);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);display:grid}button.submit{background:var(--roxy-accent-ink,#b45309);color:var(--roxy-bg,#fff);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-lg,1.5rem);font-size:var(--roxy-text-base,1rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));border:0;justify-self:start}button.submit:hover{transform:scale(1.02)}button.submit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}@media (prefers-reduced-motion:reduce){button.submit{transition:none}}.spec-error{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}`],p([h({type:String,attribute:"data-endpoint"})],u.prototype,"endpoint",2),p([h({type:String})],u.prototype,"method",2),p([h({type:String,attribute:"spec-url"})],u.prototype,"specUrl",2),p([h({type:String,attribute:"submit-label"})],u.prototype,"submitLabel",2),p([h({type:String,attribute:"publishable-key"})],u.prototype,"publishableKey",2),p([h({attribute:!1})],u.prototype,"initialValues",2),p([y()],u.prototype,"fields",2),p([y()],u.prototype,"formTitle",2),p([y()],u.prototype,"hasLang",2),p([y()],u.prototype,"values",2),p([y()],u.prototype,"loaded",2),p([y()],u.prototype,"specError",2),p([y()],u.prototype,"validationErrors",2),u=p([Z("roxy-endpoint-form")],u);export{u as RoxyEndpointForm,Se as resetSpecCache};
1
+ var _=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var p=(n,i,e,r)=>{for(var t=r>1?void 0:r?G(i,e):i,o=n.length-1,a;o>=0;o--)(a=n[o])&&(t=(r?a(i,e,t):a(t))||t);return r&&t&&_(i,e,t),t};import{css as Q,html as c,LitElement as J,nothing as g}from"lit";import{customElement as Z,property as h,state as y}from"lit/decorators.js";import{ifDefined as A}from"lit/directives/if-defined.js";var O={Aries:"\u2648",Taurus:"\u2649",Gemini:"\u264A",Cancer:"\u264B",Leo:"\u264C",Virgo:"\u264D",Libra:"\u264E",Scorpio:"\u264F",Sagittarius:"\u2650",Capricorn:"\u2651",Aquarius:"\u2652",Pisces:"\u2653"};var L=["Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius","Capricorn","Aquarius","Pisces"];import{css as B}from"lit";var q=B`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;import{css as H,html as j}from"lit";function $(){return j`<svg class="roxy-chevron" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`}var R=H`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;function M(n){return n?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():""}function m(n){return n.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([a-z])([0-9])/g,"$1 $2").replace(/^\w/,i=>i.toUpperCase())}var V=12,b=["latitude","longitude","timezone"],U=L.map(n=>n.toLowerCase());function v(n,i){if(n){if("$ref"in n&&n.$ref){let e=n.$ref.split("/").pop();return e?i[e]:void 0}return n}}function E(n){let i=n.anyOf??n.oneOf;return!i||i.length===0?n:i.find(e=>Array.isArray(e.enum))??i.find(e=>e.type&&e.type!=="null")??i[0]??n}function K(n){let i=E(n);return Array.isArray(i.enum)?i.enum.length<=V?"tiles":"select":i.type==="boolean"?"toggle":i.format==="date"?"date":i.format==="time"?"time":i.format==="date-time"?"datetime":i.type==="integer"||i.type==="number"?"number":i.type==="string"?"text":i.type==="array"?"array":null}function T(n){if(n.length!==12)return!1;let i=new Set(n.map(e=>e.toLowerCase()));return U.every(e=>i.has(e))}function w(n,i,e){let r=E(i);return{key:e.key,name:n,group:e.group,inQuery:e.inQuery,kind:K(i)??"text",required:e.required,description:r.description??i.description,enum:r.enum,min:r.minimum,max:r.maximum,default:i.default??r.default,example:i.example??r.example}}function C(n,i,e){let r=[],t=!1,o=n.requestBody?.content?.["application/json"]?.schema,a=v(o,i);if(a?.properties){let s=new Set(a.required??[]);for(let[d,l]of Object.entries(a.properties)){let f=v(l,i)??{};if(f.type==="object"&&f.properties){let x=new Set(f.required??[]);for(let[S,P]of Object.entries(f.properties)){let N=v(P,i)??{};r.push(w(S,N,{key:`${d}.${S}`,group:d,required:s.has(d)&&x.has(S)}))}}else r.push(w(d,f,{key:d,required:s.has(d)}))}}for(let s of n.parameters??[]){if(s.in!=="path"&&s.in!=="query")continue;if(s.name==="lang"&&s.in==="query"){t=!0;continue}let d=v(s.schema,i)??{};r.push(w(s.name,d,{key:s.name,required:!!s.required,inQuery:s.in==="query"}))}return{title:Y(n.summary,e),fields:r,hasLang:t}}function Y(n,i){let e=n?.split(" - ")[0]?.trim();return e||m(i.split("/").pop()??"")}function z(n){let i=n.toLowerCase();return/compat|synastry|guna|connection|penta|composite/.test(i)?"Compare":/\bcast\b|\/draw|iching|hexagram|tarot/.test(i)?"Cast":/horoscope|dream|angel|nakshatra|crystal|meaning|reference/.test(i)?"Get reading":"Generate"}function D(n,i){let e=i.replace(/^\//,"").replace(/[{}]/g,"").replace(/\//g,"-");return`${n.toLowerCase()}--${e}.json`}var F="0.20.0";var I="https://roxyapi.com/api/v2/openapi.json",W=`https://cdn.jsdelivr.net/npm/@roxyapi/ui@${F}/dist/schemas`,k=new Map;function Se(){k.clear()}async function X(n){let i=k.get(n);return i||(i=fetch(n).then(async e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}).catch(e=>{throw k.delete(n),e}),k.set(n,i)),i}function ee(){return globalThis.crypto?.randomUUID?.()??Math.random().toString(36).slice(2)}function re(n){let i=n.trim();if(!i)return[];try{let e=JSON.parse(i);if(Array.isArray(e))return e}catch{}return i.split(",").map(e=>e.trim()).filter(Boolean)}var u=class extends J{constructor(){super(...arguments);this.endpoint="vedic-astrology/birth-chart";this.method="POST";this.specUrl="";this.submitLabel="";this.fields=[];this.formTitle="";this.hasLang=!1;this.values={};this.loaded=!1;this.specError=null;this.validationErrors=[];this.retryLoadSchema=()=>{this.loaded=!1,this.specError=null,this.loadSchema()};this.onSubmit=e=>{e.preventDefault(),this.submit()}}connectedCallback(){super.connectedCallback(),this.loadSchema()}async loadSchema(){this.specError=null;try{this.applyModel(await this.resolveModel())}catch(e){let r=e instanceof Error?e.message:String(e);this.specError=r,this.loaded=!0,this.dispatchEvent(new CustomEvent("roxy-spec-error",{detail:{url:this.specUrl||I,message:r},bubbles:!0,composed:!0}))}}async resolveModel(){return this.specUrl?this.modelFromSpec(this.specUrl):await this.tryLoadSlice()??this.modelFromSpec(I)}async modelFromSpec(e){let r=await X(e),t=`/${this.endpoint.replace(/^\//,"")}`,o=r.paths?.[t]?.[this.method.toLowerCase()];if(!o)throw new Error(`Endpoint ${this.method} ${t} not found in OpenAPI spec`);return C(o,r.components?.schemas??{},this.endpoint)}async tryLoadSlice(){try{let e=await fetch(`${W}/${D(this.method,this.endpoint)}`);return e.ok?await e.json():null}catch{return null}}applyModel(e){this.fields=e.fields,this.formTitle=e.title,this.hasLang=e.hasLang;let r={};for(let t of e.fields){t.default!==void 0&&(r[t.key]=t.default);let o=t.group?this.initialValues?.[t.group]?.[t.name]:this.initialValues?.[t.name];o!==void 0&&(r[t.key]=o)}this.values=r,this.loaded=!0}setValue(e,r){this.values={...this.values,[e]:r}}roleOf(e){return e.name==="seed"?"seed":(e.name==="limit"||e.name==="offset")&&!e.required?"hidden-default":b.includes(e.name)&&this.groupHasLocation(e.group)?"location":"normal"}isRendered(e){return this.roleOf(e)==="normal"}groupKeys(){let e=[];for(let r of this.fields)e.includes(r.group)||e.push(r.group);return e}groupHasLocation(e){let r=this.fields.filter(t=>t.group===e);return b.every(t=>r.some(o=>o.name===t))}locationRequired(e){let r=this.fields.filter(t=>t.group===e);return b.some(t=>r.some(o=>o.name===t&&o.required))}groupIsRequired(e){return this.groupHasLocation(e)||this.fields.some(r=>r.group===e&&r.required)}get singleEnumField(){if(this.groupKeys().some(t=>this.groupHasLocation(t))||this.groupKeys().some(t=>t!==void 0))return null;let e=this.fields.filter(t=>t.required&&this.isRendered(t)),r=e[0];return e.length!==1||!r?null:r.kind==="tiles"||r.kind==="select"?r:null}effectiveSubmitLabel(){return this.submitLabel||z(this.endpoint)}effectiveLang(){return this.lang||void 0}onLocationFor(e){let r=e?`${e}.`:"";return t=>{let o=t.detail;o&&(this.values={...this.values,[`${r}latitude`]:o.latitude,[`${r}longitude`]:o.longitude,[`${r}timezone`]:o.timezone??o.utcOffset})}}selectTile(e,r){this.setValue(e.key,r),this.singleEnumField?.key===e.key&&this.submit()}onTilesKeyDown(e){return r=>{let t=e.enum??[];if(t.length===0)return;let o=t.indexOf(this.values[e.key]),a;if(r.key==="Home")a=0;else if(r.key==="End")a=t.length-1;else if(r.key==="ArrowRight"||r.key==="ArrowDown")a=o===-1?0:(o+1)%t.length;else if(r.key==="ArrowLeft"||r.key==="ArrowUp")a=o===-1?t.length-1:(o-1+t.length)%t.length;else return;r.preventDefault();let s=t[a];if(s===void 0)return;this.selectTile(e,s);let d=r.currentTarget;requestAnimationFrame(()=>d.querySelector(`[data-tile='${a}']`)?.focus())}}submit(){let e=this.collectMissing();if(e.keys.length>0){this.validationErrors=e.labels,this.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{missing:e.keys},bubbles:!0,composed:!0}));return}this.validationErrors=[];let r={};for(let a of this.fields){let s=this.values[a.key];if(a.name==="seed"&&(s===void 0||s==="")&&(s=ee()),!(s===void 0||s===""))if(a.kind==="array"&&typeof s=="string"&&(s=re(s)),a.group){let d=r[a.group]??{};d[a.name]=s,r[a.group]=d}else r[a.name]=s}let t=this.fields.filter(a=>a.inQuery).map(a=>a.name),o=this.effectiveLang();this.hasLang&&o&&(r.lang=o,t.push("lang")),this.dispatchEvent(new CustomEvent("roxy-submit",{detail:{endpoint:this.endpoint,values:r,queryKeys:t,sticky:this.singleEnumField!=null},bubbles:!0,composed:!0}))}collectMissing(){let e=[],r=[],t=new Set;for(let o of this.fields){if(!o.required)continue;let a=this.roleOf(o)==="location";if(!this.isRendered(o)&&!a)continue;let s=this.values[o.key];if(!(s!==void 0&&s!=="")){if(e.push(o.key),a){t.add(o.group);continue}r.push(o.group?`${m(o.group)} ${m(o.name)}`:m(o.name))}}for(let o of t)r.push(o?`${m(o)} location`:"Birth location");return{keys:e,labels:r}}reqMark(e){return e.required?c`<span class="req" aria-hidden="true">*</span>`:g}description(e){if(!e.description)return g;if(e.description.length<=120)return c`<small class="help">${e.description}</small>`;let r=e.description.split(". ")[0]??e.description;return c`<details class="help-details"><summary><span class="help-lead">${r}</span>${$()}</summary><small class="help help-full">${e.description}</small></details>`}renderTiles(e){let r=`roxy-form-${e.key}-label`,t=!!e.enum&&T(e.enum),o=e.enum??[],a=o.indexOf(this.values[e.key]),s=a===-1?0:a;return c`<div class="field tiles-field"><span class="label" id="${r}">${m(e.name)}${this.reqMark(e)}</span><div class="tiles" role="radiogroup" aria-labelledby="${r}" @keydown="${this.onTilesKeyDown(e)}">${o.map((d,l)=>{let f=this.values[e.key]===d,x=t?O[M(d)]:void 0;return c`<button type="button" class="tile" role="radio" data-tile="${l}" aria-checked="${f?"true":"false"}" tabindex="${l===s?"0":"-1"}" @click="${()=>this.selectTile(e,d)}">${x?c`<span class="tile-glyph" aria-hidden="true">${x}</span>`:g} <span class="tile-label">${m(d)}</span></button>`})}</div>${this.description(e)}</div>`}renderSelect(e){let r=`roxy-form-${e.key}`;return c`<div class="field"><label for="${r}">${m(e.name)}${this.reqMark(e)}</label> <select id="${r}" ?required="${e.required}" @change="${t=>this.setValue(e.key,t.target.value)}"><option value="">Choose</option>${(e.enum??[]).map(t=>c`<option value="${t}" ?selected="${this.values[e.key]===t}">${m(t)}</option>`)}</select> ${this.description(e)}</div>`}renderToggle(e){let r=`roxy-form-${e.key}`,t=this.values[e.key]===!0;return c`<div class="field"><div class="toggle-row"><button type="button" id="${r}" class="toggle" role="switch" aria-checked="${t?"true":"false"}" @click="${()=>this.setValue(e.key,!t)}"><span class="knob"></span></button> <label class="toggle-label" for="${r}">${m(e.name)}${this.reqMark(e)}</label></div>${this.description(e)}</div>`}renderInput(e){let r=`roxy-form-${e.key}`,t=e.kind==="datetime"?"datetime-local":e.kind==="number"?"number":e.kind,o=e.kind==="array"?"Comma separated":e.example!=null?String(e.example):"";return c`<div class="field"><label for="${r}">${m(e.name)}${this.reqMark(e)}</label> <input id="${r}" type="${e.kind==="array"?"text":t}" ?required="${e.required}" min="${A(e.min)}" max="${A(e.max)}" step="${e.kind==="number"?"any":g}" placeholder="${o||g}" .value="${this.values[e.key]??""}" @input="${a=>this.setValue(e.key,this.coerce(e.kind,a.target.value))}"> ${this.description(e)}</div>`}renderField(e){switch(e.kind){case"tiles":return this.renderTiles(e);case"select":return this.renderSelect(e);case"toggle":return this.renderToggle(e);default:return this.renderInput(e)}}locationBlock(e){return c`<div class="location-block"><label>${e?`${m(e)} location`:"Birth location"}${this.locationRequired(e)?c`<span class="req" aria-hidden="true">*</span>`:g}</label><roxy-location-search publishable-key="${A(this.publishableKey)}" @roxy-location-select="${this.onLocationFor(e)}" placeholder="City of birth"></roxy-location-search><small class="help">Required: latitude, longitude, timezone. Pick a city to autofill.</small></div>`}groupCard(e){let r=this.fields.filter(t=>t.group===e&&this.isRendered(t));return c`<fieldset class="person-group"><legend>${m(e)}</legend>${this.groupHasLocation(e)?this.locationBlock(e):g}<div class="fields">${r.map(t=>this.renderField(t))}</div></fieldset>`}render(){if(!this.loaded)return c`<form><div class="roxy-skeleton" style="height:8rem"></div></form>`;if(this.specError)return c`<div class="spec-error" role="alert">Schema load failed: ${this.specError} <button type="button" class="submit" @click="${this.retryLoadSchema}">Retry</button></div>`;let e=this.fields.filter(l=>!l.group&&this.isRendered(l)),r=e.filter(l=>l.required),t=e.filter(l=>!l.required),o=this.groupKeys().filter(l=>l!==void 0),a=o.filter(l=>this.groupIsRequired(l)),s=o.filter(l=>!this.groupIsRequired(l)),d=t.length>0||s.length>0;return c`<form @submit="${this.onSubmit}"><h2 class="title">${this.formTitle}</h2>${this.validationErrors.length>0?c`<div class="validation-error" role="alert"><strong>Please complete:</strong> ${this.validationErrors.join(", ")}</div>`:g}<div class="fields">${r.map(l=>this.renderField(l))}</div>${this.groupHasLocation(void 0)?this.locationBlock(void 0):g} ${a.map(l=>this.groupCard(l))} ${d?c`<details class="advanced"><summary>Advanced${$()}</summary><div class="fields">${t.map(l=>this.renderField(l))}</div>${s.map(l=>this.groupCard(l))}</details>`:g} ${this.singleEnumField?g:c`<button class="submit" type="submit">${this.effectiveSubmitLabel()}</button>`}</form>`}coerce(e,r){if(r!==""){if(e==="number"){let t=Number(r);return Number.isFinite(t)?t:void 0}return r}}};u.styles=[q,R,Q`form{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);box-shadow:var(--roxy-shadow-sm);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.fields{align-items:start;gap:var(--roxy-space-md,1rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));display:grid}.fields:empty{display:none}.person-group{background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);gap:var(--roxy-space-md,1rem);min-inline-size:0;margin:0;display:grid}.person-group legend{padding:0 var(--roxy-space-xs,.25rem);font-weight:var(--roxy-weight-bold,600)}.field{gap:var(--roxy-space-xs,.25rem);flex-direction:column;min-width:0;display:flex}.tiles-field{grid-column:1/-1}label,.label{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-secondary,#475569)}.req{color:var(--roxy-danger-fg,#991b1b);margin-left:4px}input,select{box-sizing:border-box;width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);font-family:inherit}input:focus,select:focus{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-color:var(--roxy-accent-ink,#b45309)}.help{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem)}.help-details>summary{cursor:pointer;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);align-items:center;gap:4px;display:flex}.help-details .help-lead{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.help-details .help-full{margin-top:var(--roxy-space-xs,.25rem);display:block}.location-block{gap:var(--roxy-space-xs,.25rem);grid-column:1/-1;display:grid}.tiles{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(5.5rem,1fr));display:grid}.tile{min-height:44px;padding:var(--roxy-space-sm,.5rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;transition:border-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease), background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-direction:column;justify-content:center;align-items:center;gap:2px;display:flex}.tile:hover{border-color:var(--roxy-accent,#f59e0b)}.tile[aria-checked=true]{border-color:var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 12%, transparent);color:var(--roxy-accent-ink,#b45309);font-weight:var(--roxy-weight-bold,600)}.tile:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.tile-glyph{font-size:1.35em;line-height:1}.toggle-row{align-items:center;gap:var(--roxy-space-sm,.5rem);display:flex}.toggle{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);background:var(--roxy-border,#e4e4e7);cursor:pointer;width:44px;height:26px;transition:background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0;padding:0;position:relative}.toggle[aria-checked=true]{background:var(--roxy-accent,#f59e0b);border-color:var(--roxy-accent,#f59e0b)}.toggle .knob{background:var(--roxy-bg,#fff);width:20px;height:20px;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);border-radius:50%;position:absolute;top:2px;left:2px}.toggle[aria-checked=true] .knob{transform:translate(18px)}.toggle:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.toggle-label{cursor:pointer}@media (prefers-reduced-motion:reduce){.tile,.toggle,.toggle .knob{transition:none}}.advanced{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.advanced>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a);align-items:center;gap:6px;display:flex}.advanced[open]>summary{margin-bottom:var(--roxy-space-md,1rem)}.advanced .fields,.advanced .person-group{margin-top:var(--roxy-space-md,1rem)}.validation-error{gap:var(--roxy-space-xs,.25rem);padding:var(--roxy-space-md,1rem);background:color-mix(in srgb, var(--roxy-danger,#dc2626) 8%, transparent);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);display:grid}button.submit{background:var(--roxy-accent-ink,#b45309);color:var(--roxy-bg,#fff);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-lg,1.5rem);font-size:var(--roxy-text-base,1rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));border:0;justify-self:start}button.submit:hover{transform:scale(1.02)}button.submit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}@media (prefers-reduced-motion:reduce){button.submit{transition:none}}.spec-error{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}`],p([h({type:String,attribute:"data-endpoint"})],u.prototype,"endpoint",2),p([h({type:String})],u.prototype,"method",2),p([h({type:String,attribute:"spec-url"})],u.prototype,"specUrl",2),p([h({type:String,attribute:"submit-label"})],u.prototype,"submitLabel",2),p([h({type:String,attribute:"publishable-key"})],u.prototype,"publishableKey",2),p([h({attribute:!1})],u.prototype,"initialValues",2),p([y()],u.prototype,"fields",2),p([y()],u.prototype,"formTitle",2),p([y()],u.prototype,"hasLang",2),p([y()],u.prototype,"values",2),p([y()],u.prototype,"loaded",2),p([y()],u.prototype,"specError",2),p([y()],u.prototype,"validationErrors",2),u=p([Z("roxy-endpoint-form")],u);export{u as RoxyEndpointForm,Se as resetSpecCache};
2
2
  //# sourceMappingURL=endpoint-form.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/components/endpoint-form.ts", "../../src/tokens/index.ts", "../../src/utils/base-styles.ts", "../../src/utils/disclosure.ts", "../../src/utils/string.ts", "../../src/utils/field-schema.ts", "../../src/version.ts"],
4
- "sourcesContent": ["import { css, html, LitElement, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { SIGN_GLYPH } from '../tokens/index.js';\nimport { baseStyles } from '../utils/base-styles.js';\nimport { chevron, disclosureStyles } from '../utils/disclosure.js';\nimport {\n\tbuildFormModel,\n\tderiveSubmitLabel,\n\ttype FieldDef,\n\ttype FormModel,\n\tisZodiacEnum,\n\tLOCATION_TRIO,\n\ttype OpenApiDoc,\n\ttype OperationSchema,\n\tsliceFileName,\n} from '../utils/field-schema.js';\nimport { capitalize, humanize } from '../utils/string.js';\nimport { ROXY_UI_VERSION } from '../version.js';\n\n/** Production spec, fetched when no slice is available and no explicit `spec-url` is set. */\nconst PROD_SPEC_URL = 'https://roxyapi.com/api/v2/openapi.json';\n\n/** Version-pinned jsDelivr base for the digested per-operation schema slices, mirroring the wrapper CDN pinning so a slice matches the bundle it ships beside. */\nconst SLICE_BASE = `https://cdn.jsdelivr.net/npm/@roxyapi/ui@${ROXY_UI_VERSION}/dist/schemas`;\n\nconst specCache = new Map<string, Promise<OpenApiDoc>>();\n\n/**\n * Drop every cached spec promise.\n\n * @remarks\n * Test-only, and deliberately NOT re-exported from the package entry. The cache is module state shared by every test file in a single `bun test` process, and it only self-evicts on rejection, so one file that resolves a spec leaves a warm entry that silently satisfies a later file assertion about fetching. That made slice-fallback coverage pass or fail purely on file order.\n\n * @internal\n */\nexport function resetSpecCache(): void {\n\tspecCache.clear();\n}\n\nasync function loadSpec(url: string): Promise<OpenApiDoc> {\n\tlet pending = specCache.get(url);\n\tif (!pending) {\n\t\tpending = fetch(url)\n\t\t\t.then(async (res) => {\n\t\t\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\t\t\treturn (await res.json()) as OpenApiDoc;\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\t// Evict the rejected promise BEFORE rethrowing so subsequent\n\t\t\t\t// callers (the user clicking Retry, a remount) hit the network\n\t\t\t\t// again instead of replaying the cached failure forever.\n\t\t\t\tspecCache.delete(url);\n\t\t\t\tthrow err;\n\t\t\t});\n\t\tspecCache.set(url, pending);\n\t}\n\treturn pending;\n}\n\n/** A fresh seed for a hidden `seed` field, so each submit is a new draw unless the caller pinned one. */\nfunction randomSeed(): string {\n\treturn (\n\t\tglobalThis.crypto?.randomUUID?.() ?? Math.random().toString(36).slice(2)\n\t);\n}\n\n/** Parse an array-field text value into a real array: JSON when it parses to one, else comma-separated tokens. */\nfunction parseArrayValue(raw: string): unknown {\n\tconst trimmed = raw.trim();\n\tif (!trimmed) return [];\n\ttry {\n\t\tconst parsed = JSON.parse(trimmed);\n\t\tif (Array.isArray(parsed)) return parsed;\n\t} catch {\n\t\t// Not JSON: fall through to comma splitting.\n\t}\n\treturn trimmed\n\t\t.split(',')\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean);\n}\n\n/**\n * Schema-driven form. Pass `endpoint` (e.g. \"vedic-astrology/birth-chart\"). The form digests the operation's request schema into a spec-derived input for each parameter (a zodiac tile grid, a date or time input, a city search, a toggle) with progressive disclosure, and emits a `roxy-submit` CustomEvent carrying the validated payload. The caller decides what to do (call the SDK, render a chart, navigate).\n *\n * @remarks\n * Schema resolution order: an explicit `spec-url` fetches that full spec and digests it (unchanged, the demo path); otherwise the form tries a small version-pinned per-operation slice from the CDN, and on any miss falls back to fetching the production spec. Each input kind is chosen purely from the parameter shape (see {@link ../utils/field-schema.ts}), so a new endpoint gets a working, on-brand form with no per-endpoint code.\n *\n * The visitor-facing `lang` parameter is never rendered: a site owner sets the element `lang` attribute, and the form routes it to the query string on submit. Optional parameters collapse under one Advanced disclosure; a form whose only required field is an enum submits on selection.\n */\n@customElement('roxy-endpoint-form')\nexport class RoxyEndpointForm extends LitElement {\n\tstatic styles = [\n\t\tbaseStyles,\n\t\tdisclosureStyles,\n\t\tcss`form{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);box-shadow:var(--roxy-shadow-sm);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.fields{align-items:start;gap:var(--roxy-space-md,1rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));display:grid}.fields:empty{display:none}.person-group{background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);gap:var(--roxy-space-md,1rem);min-inline-size:0;margin:0;display:grid}.person-group legend{padding:0 var(--roxy-space-xs,.25rem);font-weight:var(--roxy-weight-bold,600)}.field{gap:var(--roxy-space-xs,.25rem);flex-direction:column;min-width:0;display:flex}.tiles-field{grid-column:1/-1}label,.label{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-secondary,#475569)}.req{color:var(--roxy-danger-fg,#991b1b);margin-left:4px}input,select{box-sizing:border-box;width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);font-family:inherit}input:focus,select:focus{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-color:var(--roxy-accent-ink,#b45309)}.help{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem)}.help-details>summary{cursor:pointer;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);align-items:center;gap:4px;display:flex}.help-details .help-lead{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.help-details .help-full{margin-top:var(--roxy-space-xs,.25rem);display:block}.location-block{gap:var(--roxy-space-xs,.25rem);grid-column:1/-1;display:grid}.tiles{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(5.5rem,1fr));display:grid}.tile{min-height:44px;padding:var(--roxy-space-sm,.5rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;transition:border-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease), background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-direction:column;justify-content:center;align-items:center;gap:2px;display:flex}.tile:hover{border-color:var(--roxy-accent,#f59e0b)}.tile[aria-checked=true]{border-color:var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 12%, transparent);color:var(--roxy-accent-ink,#b45309);font-weight:var(--roxy-weight-bold,600)}.tile:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.tile-glyph{font-size:1.35em;line-height:1}.toggle-row{align-items:center;gap:var(--roxy-space-sm,.5rem);display:flex}.toggle{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);background:var(--roxy-border,#e4e4e7);cursor:pointer;width:44px;height:26px;transition:background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0;padding:0;position:relative}.toggle[aria-checked=true]{background:var(--roxy-accent,#f59e0b);border-color:var(--roxy-accent,#f59e0b)}.toggle .knob{background:var(--roxy-bg,#fff);width:20px;height:20px;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);border-radius:50%;position:absolute;top:2px;left:2px}.toggle[aria-checked=true] .knob{transform:translate(18px)}.toggle:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.toggle-label{cursor:pointer}@media (prefers-reduced-motion:reduce){.tile,.toggle,.toggle .knob{transition:none}}.advanced{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.advanced>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a);align-items:center;gap:6px;display:flex}.advanced[open]>summary{margin-bottom:var(--roxy-space-md,1rem)}.advanced .fields,.advanced .person-group{margin-top:var(--roxy-space-md,1rem)}.validation-error{gap:var(--roxy-space-xs,.25rem);padding:var(--roxy-space-md,1rem);background:color-mix(in srgb, var(--roxy-danger,#dc2626) 8%, transparent);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);display:grid}button.submit{background:var(--roxy-accent-ink,#b45309);color:var(--roxy-bg,#fff);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-lg,1.5rem);font-size:var(--roxy-text-base,1rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));border:0;justify-self:start}button.submit:hover{transform:scale(1.02)}button.submit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}@media (prefers-reduced-motion:reduce){button.submit{transition:none}}.spec-error{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}`,\n\t];\n\n\t@property({ type: String, attribute: 'data-endpoint' })\n\tendpoint = 'vedic-astrology/birth-chart';\n\n\t@property({ type: String })\n\tmethod: 'GET' | 'POST' = 'POST';\n\n\t/** Explicit OpenAPI spec URL. When set, the form fetches and digests that full spec (the demo path). When empty, it resolves a version-pinned slice first, then the production spec. */\n\t@property({ type: String, attribute: 'spec-url' })\n\tspecUrl = '';\n\n\t/** Override the submit-button label. Empty derives an outcome-first label from the endpoint. */\n\t@property({ type: String, attribute: 'submit-label' })\n\tsubmitLabel = '';\n\n\t/** Browser-safe publishable key, forwarded to the slotted city search so the natal or synastry form can geocode. */\n\t@property({ type: String, attribute: 'publishable-key' })\n\tpublishableKey?: string;\n\n\t/** Prefill values, keyed by field name (nested per group). Used by `remember` mode and to restore the previous submission. JS property only. */\n\t@property({ attribute: false })\n\tinitialValues?: Record<string, unknown>;\n\n\t@state()\n\tprivate fields: FieldDef[] = [];\n\n\t@state()\n\tprivate formTitle = '';\n\n\t@state()\n\tprivate hasLang = false;\n\n\t@state()\n\tprivate values: Record<string, unknown> = {};\n\n\t@state()\n\tprivate loaded = false;\n\n\t@state()\n\tprivate specError: string | null = null;\n\n\t@state()\n\tprivate validationErrors: string[] = [];\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tvoid this.loadSchema();\n\t}\n\n\tprivate async loadSchema() {\n\t\tthis.specError = null;\n\t\ttry {\n\t\t\tthis.applyModel(await this.resolveModel());\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\tthis.specError = message;\n\t\t\tthis.loaded = true;\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('roxy-spec-error', {\n\t\t\t\t\tdetail: { url: this.specUrl || PROD_SPEC_URL, message },\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Resolve the form model: explicit spec-url wins; else a version-pinned slice; else the production spec. */\n\tprivate async resolveModel(): Promise<FormModel> {\n\t\tif (this.specUrl) return this.modelFromSpec(this.specUrl);\n\t\tconst slice = await this.tryLoadSlice();\n\t\treturn slice ?? this.modelFromSpec(PROD_SPEC_URL);\n\t}\n\n\t/** Fetch and digest one operation from a full OpenAPI document. */\n\tprivate async modelFromSpec(url: string): Promise<FormModel> {\n\t\tconst spec = await loadSpec(url);\n\t\tconst path = `/${this.endpoint.replace(/^\\//, '')}`;\n\t\tconst op = spec.paths?.[path]?.[this.method.toLowerCase()] as\n\t\t\t| OperationSchema\n\t\t\t| undefined;\n\t\tif (!op) {\n\t\t\tthrow new Error(\n\t\t\t\t`Endpoint ${this.method} ${path} not found in OpenAPI spec`,\n\t\t\t);\n\t\t}\n\t\treturn buildFormModel(op, spec.components?.schemas ?? {}, this.endpoint);\n\t}\n\n\t/** Try the small precomputed slice; return null on any miss so the caller falls back to the full spec. */\n\tprivate async tryLoadSlice(): Promise<FormModel | null> {\n\t\ttry {\n\t\t\tconst res = await fetch(\n\t\t\t\t`${SLICE_BASE}/${sliceFileName(this.method, this.endpoint)}`,\n\t\t\t);\n\t\t\tif (!res.ok) return null;\n\t\t\treturn (await res.json()) as FormModel;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate applyModel(model: FormModel) {\n\t\tthis.fields = model.fields;\n\t\tthis.formTitle = model.title;\n\t\tthis.hasLang = model.hasLang;\n\t\t// Pre-fill: schema defaults first, then any remembered/initial values (only\n\t\t// for fields this endpoint has) so a stale stored payload from another\n\t\t// endpoint cannot inject unknown keys. Remembered values are nested per\n\t\t// group, so read them by group.\n\t\tconst init: Record<string, unknown> = {};\n\t\tfor (const f of model.fields) {\n\t\t\tif (f.default !== undefined) init[f.key] = f.default;\n\t\t\tconst remembered = f.group\n\t\t\t\t? (\n\t\t\t\t\t\tthis.initialValues?.[f.group] as Record<string, unknown> | undefined\n\t\t\t\t\t)?.[f.name]\n\t\t\t\t: this.initialValues?.[f.name];\n\t\t\tif (remembered !== undefined) init[f.key] = remembered;\n\t\t}\n\t\tthis.values = init;\n\t\tthis.loaded = true;\n\t}\n\n\tprivate retryLoadSchema = () => {\n\t\tthis.loaded = false;\n\t\tthis.specError = null;\n\t\tvoid this.loadSchema();\n\t};\n\n\tprivate setValue(name: string, value: unknown) {\n\t\tthis.values = { ...this.values, [name]: value };\n\t}\n\n\t/** The field's render role: a hidden autogenerated seed, a hidden defaulted limit/offset, a suppressed location coordinate, or a normally rendered input. */\n\tprivate roleOf(\n\t\tf: FieldDef,\n\t): 'seed' | 'hidden-default' | 'location' | 'normal' {\n\t\tif (f.name === 'seed') return 'seed';\n\t\tif ((f.name === 'limit' || f.name === 'offset') && !f.required)\n\t\t\treturn 'hidden-default';\n\t\tif (\n\t\t\t(LOCATION_TRIO as readonly string[]).includes(f.name) &&\n\t\t\tthis.groupHasLocation(f.group)\n\t\t)\n\t\t\treturn 'location';\n\t\treturn 'normal';\n\t}\n\n\t/** True when the field renders its own input (as opposed to being hidden or replaced by the city search). */\n\tprivate isRendered(f: FieldDef): boolean {\n\t\treturn this.roleOf(f) === 'normal';\n\t}\n\n\t/** Ordered, de-duplicated group keys (undefined flat group plus each named object). */\n\tprivate groupKeys(): (string | undefined)[] {\n\t\tconst keys: (string | undefined)[] = [];\n\t\tfor (const f of this.fields)\n\t\t\tif (!keys.includes(f.group)) keys.push(f.group);\n\t\treturn keys;\n\t}\n\n\t/** True when the fields in `group` (or the flat top level) carry latitude+longitude+timezone, so a location-search can autofill them. */\n\tprivate groupHasLocation(group?: string): boolean {\n\t\tconst inGroup = this.fields.filter((f) => f.group === group);\n\t\treturn LOCATION_TRIO.every((n) => inGroup.some((f) => f.name === n));\n\t}\n\n\t/**\n\t * True when the location block must show a required mark, i.e. ANY member of the trio is required. The block is a single city-search input that fills all three, so if even one is required (e.g. bodygraph requires `timezone` while `latitude`/`longitude` are optional) the input is required and `collectMissing` blocks submit without it. Requiring ALL three understated that: the asterisk went missing on a block the form still enforced, which reads as optional to a non-technical embedder.\n\t */\n\tprivate locationRequired(group?: string): boolean {\n\t\tconst inGroup = this.fields.filter((f) => f.group === group);\n\t\treturn LOCATION_TRIO.some((n) =>\n\t\t\tinGroup.some((f) => f.name === n && f.required),\n\t\t);\n\t}\n\n\t/** A named group is a required input when any of its leaf fields is required or it carries a location. */\n\tprivate groupIsRequired(group: string): boolean {\n\t\treturn (\n\t\t\tthis.groupHasLocation(group) ||\n\t\t\tthis.fields.some((f) => f.group === group && f.required)\n\t\t);\n\t}\n\n\t/**\n\t * The single visible required enum field, when the whole form reduces to exactly one: no location block, no named group, one required rendered enum. This is what turns the horoscope form into a tap-to-load sign grid; returns null otherwise.\n\t */\n\tprivate get singleEnumField(): FieldDef | null {\n\t\tif (this.groupKeys().some((g) => this.groupHasLocation(g))) return null;\n\t\tif (this.groupKeys().some((g) => g !== undefined)) return null;\n\t\tconst req = this.fields.filter((f) => f.required && this.isRendered(f));\n\t\tconst only = req[0];\n\t\tif (req.length !== 1 || !only) return null;\n\t\treturn only.kind === 'tiles' || only.kind === 'select' ? only : null;\n\t}\n\n\tprivate effectiveSubmitLabel(): string {\n\t\treturn this.submitLabel || deriveSubmitLabel(this.endpoint);\n\t}\n\n\t/** The site-owner language from the element `lang` attribute (native), or undefined. Read here, never a Lit property, to avoid shadowing the native accessor. */\n\tprivate effectiveLang(): string | undefined {\n\t\treturn this.lang || undefined;\n\t}\n\n\t/** Location-select handler bound to a group: fills that group's lat/lng/timezone keys (flat top level when group is undefined). */\n\tprivate onLocationFor(group?: string) {\n\t\tconst prefix = group ? `${group}.` : '';\n\t\treturn (e: Event) => {\n\t\t\tconst detail = (e as CustomEvent).detail as {\n\t\t\t\tlatitude?: number;\n\t\t\t\tlongitude?: number;\n\t\t\t\ttimezone?: string;\n\t\t\t\tutcOffset?: number;\n\t\t\t};\n\t\t\tif (!detail) return;\n\t\t\tthis.values = {\n\t\t\t\t...this.values,\n\t\t\t\t[`${prefix}latitude`]: detail.latitude,\n\t\t\t\t[`${prefix}longitude`]: detail.longitude,\n\t\t\t\t[`${prefix}timezone`]: detail.timezone ?? detail.utcOffset,\n\t\t\t};\n\t\t};\n\t}\n\n\tprivate selectTile(f: FieldDef, value: string) {\n\t\tthis.setValue(f.key, value);\n\t\tif (this.singleEnumField?.key === f.key) this.submit();\n\t}\n\n\t/** Roving-tabindex arrow-key navigation for a tile radiogroup, modeled on the shared tablist pattern (selection follows focus). */\n\tprivate onTilesKeyDown(f: FieldDef) {\n\t\treturn (e: KeyboardEvent) => {\n\t\t\tconst opts = f.enum ?? [];\n\t\t\tif (opts.length === 0) return;\n\t\t\tconst cur = opts.indexOf(this.values[f.key] as string);\n\t\t\tlet next: number;\n\t\t\tif (e.key === 'Home') next = 0;\n\t\t\telse if (e.key === 'End') next = opts.length - 1;\n\t\t\telse if (e.key === 'ArrowRight' || e.key === 'ArrowDown')\n\t\t\t\tnext = cur === -1 ? 0 : (cur + 1) % opts.length;\n\t\t\telse if (e.key === 'ArrowLeft' || e.key === 'ArrowUp')\n\t\t\t\tnext =\n\t\t\t\t\tcur === -1 ? opts.length - 1 : (cur - 1 + opts.length) % opts.length;\n\t\t\telse return;\n\t\t\te.preventDefault();\n\t\t\tconst value = opts[next];\n\t\t\tif (value === undefined) return;\n\t\t\tthis.selectTile(f, value);\n\t\t\tconst root = e.currentTarget as HTMLElement;\n\t\t\trequestAnimationFrame(() =>\n\t\t\t\troot.querySelector<HTMLButtonElement>(`[data-tile='${next}']`)?.focus(),\n\t\t\t);\n\t\t};\n\t}\n\n\tprivate onSubmit = (e: Event) => {\n\t\te.preventDefault();\n\t\tthis.submit();\n\t};\n\n\t/** Validate, then emit `roxy-submit` with the reconstructed payload, the spec query keys, and whether the form was a single-enum sticky picker. */\n\tprivate submit() {\n\t\tconst missing = this.collectMissing();\n\t\tif (missing.keys.length > 0) {\n\t\t\tthis.validationErrors = missing.labels;\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('roxy-validation-error', {\n\t\t\t\t\tdetail: { missing: missing.keys },\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis.validationErrors = [];\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const f of this.fields) {\n\t\t\tlet v = this.values[f.key];\n\t\t\t// A hidden seed autogenerates per submit unless a value was remembered.\n\t\t\tif (f.name === 'seed' && (v === undefined || v === '')) v = randomSeed();\n\t\t\tif (v === undefined || v === '') continue;\n\t\t\tif (f.kind === 'array' && typeof v === 'string') v = parseArrayValue(v);\n\t\t\tif (f.group) {\n\t\t\t\tconst g = (out[f.group] as Record<string, unknown> | undefined) ?? {};\n\t\t\t\tg[f.name] = v;\n\t\t\t\tout[f.group] = g;\n\t\t\t} else {\n\t\t\t\tout[f.name] = v;\n\t\t\t}\n\t\t}\n\t\t// The spec knows which parameters belong in the query string; the listener\n\t\t// does not. Report them (including a site-owner lang) so a POST with a query\n\t\t// parameter reaches the API correctly instead of being dropped in the body.\n\t\tconst queryKeys = this.fields.filter((f) => f.inQuery).map((f) => f.name);\n\t\tconst lang = this.effectiveLang();\n\t\tif (this.hasLang && lang) {\n\t\t\tout.lang = lang;\n\t\t\tqueryKeys.push('lang');\n\t\t}\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent('roxy-submit', {\n\t\t\t\tdetail: {\n\t\t\t\t\tendpoint: this.endpoint,\n\t\t\t\t\tvalues: out,\n\t\t\t\t\tqueryKeys,\n\t\t\t\t\tsticky: this.singleEnumField != null,\n\t\t\t\t},\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** Required fields left empty, with the location trio collapsed to one entry per group. Seed and hidden defaults never block. */\n\tprivate collectMissing(): { keys: string[]; labels: string[] } {\n\t\tconst keys: string[] = [];\n\t\tconst labels: string[] = [];\n\t\tconst locGroups = new Set<string | undefined>();\n\t\tfor (const f of this.fields) {\n\t\t\tif (!f.required) continue;\n\t\t\tconst isLocation = this.roleOf(f) === 'location';\n\t\t\tif (!this.isRendered(f) && !isLocation) continue;\n\t\t\tconst v = this.values[f.key];\n\t\t\tif (v !== undefined && v !== '') continue;\n\t\t\tkeys.push(f.key);\n\t\t\tif (isLocation) {\n\t\t\t\tlocGroups.add(f.group);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlabels.push(\n\t\t\t\tf.group ? `${humanize(f.group)} ${humanize(f.name)}` : humanize(f.name),\n\t\t\t);\n\t\t}\n\t\tfor (const g of locGroups) {\n\t\t\tlabels.push(g ? `${humanize(g)} location` : 'Birth location');\n\t\t}\n\t\treturn { keys, labels };\n\t}\n\n\tprivate reqMark(f: FieldDef) {\n\t\treturn f.required\n\t\t\t? html`<span class=\"req\" aria-hidden=\"true\">*</span>`\n\t\t\t: nothing;\n\t}\n\n\t/** A description under a field: rendered inline when short, collapsed behind a disclosure showing its first line when long. */\n\tprivate description(f: FieldDef) {\n\t\tif (!f.description) return nothing;\n\t\tif (f.description.length <= 120) {\n\t\t\treturn html`<small class=\"help\">${f.description}</small>`;\n\t\t}\n\t\tconst lead = f.description.split('. ')[0] ?? f.description;\n\t\treturn html`<details class=\"help-details\"><summary><span class=\"help-lead\">${lead}</span>${chevron()}</summary><small class=\"help help-full\">${f.description}</small></details>`;\n\t}\n\n\tprivate renderTiles(f: FieldDef) {\n\t\tconst labelId = `roxy-form-${f.key}-label`;\n\t\tconst zodiac = !!f.enum && isZodiacEnum(f.enum);\n\t\tconst opts = f.enum ?? [];\n\t\tconst cur = opts.indexOf(this.values[f.key] as string);\n\t\tconst active = cur === -1 ? 0 : cur;\n\t\treturn html`<div class=\"field tiles-field\"><span class=\"label\" id=\"${labelId}\">${humanize(f.name)}${this.reqMark(f)}</span><div class=\"tiles\" role=\"radiogroup\" aria-labelledby=\"${labelId}\" @keydown=\"${this.onTilesKeyDown(f)}\">${opts.map((opt, i) => {\n\t\t\t\t\tconst selected = this.values[f.key] === opt;\n\t\t\t\t\tconst glyph = zodiac ? SIGN_GLYPH[capitalize(opt)] : undefined;\n\t\t\t\t\treturn html`<button type=\"button\" class=\"tile\" role=\"radio\" data-tile=\"${i}\" aria-checked=\"${selected ? 'true' : 'false'}\" tabindex=\"${i === active ? '0' : '-1'}\" @click=\"${() => this.selectTile(f, opt)}\">${\n\t\t\t\t\t\t\tglyph\n\t\t\t\t\t\t\t\t? html`<span class=\"tile-glyph\" aria-hidden=\"true\">${glyph}</span>`\n\t\t\t\t\t\t\t\t: nothing\n\t\t\t\t\t\t} <span class=\"tile-label\">${humanize(opt)}</span></button>`;\n\t\t\t\t})}</div>${this.description(f)}</div>`;\n\t}\n\n\tprivate renderSelect(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\treturn html`<div class=\"field\"><label for=\"${id}\">${humanize(f.name)}${this.reqMark(f)}</label> <select id=\"${id}\" ?required=\"${f.required}\" @change=\"${(e: Event) =>\n\t\t\t\t\tthis.setValue(f.key, (e.target as HTMLSelectElement).value)}\"><option value=\"\">Choose</option>${(f.enum ?? []).map(\n\t\t\t\t\t(\n\t\t\t\t\t\topt,\n\t\t\t\t\t) => html`<option value=\"${opt}\" ?selected=\"${this.values[f.key] === opt}\">${humanize(opt)}</option>`,\n\t\t\t\t)}</select> ${this.description(f)}</div>`;\n\t}\n\n\tprivate renderToggle(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst checked = this.values[f.key] === true;\n\t\treturn html`<div class=\"field\"><div class=\"toggle-row\"><button type=\"button\" id=\"${id}\" class=\"toggle\" role=\"switch\" aria-checked=\"${checked ? 'true' : 'false'}\" @click=\"${() => this.setValue(f.key, !checked)}\"><span class=\"knob\"></span></button> <label class=\"toggle-label\" for=\"${id}\">${humanize(f.name)}${this.reqMark(f)}</label></div>${this.description(f)}</div>`;\n\t}\n\n\tprivate renderInput(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst type =\n\t\t\tf.kind === 'datetime'\n\t\t\t\t? 'datetime-local'\n\t\t\t\t: f.kind === 'number'\n\t\t\t\t\t? 'number'\n\t\t\t\t\t: f.kind;\n\t\tconst placeholder =\n\t\t\tf.kind === 'array'\n\t\t\t\t? 'Comma separated'\n\t\t\t\t: f.example != null\n\t\t\t\t\t? String(f.example)\n\t\t\t\t\t: '';\n\t\treturn html`<div class=\"field\"><label for=\"${id}\">${humanize(f.name)}${this.reqMark(f)}</label> <input id=\"${id}\" type=\"${f.kind === 'array' ? 'text' : type}\" ?required=\"${f.required}\" min=\"${ifDefined(f.min)}\" max=\"${ifDefined(f.max)}\" step=\"${f.kind === 'number' ? 'any' : nothing}\" placeholder=\"${placeholder || nothing}\" .value=\"${(this.values[f.key] ?? '') as string}\" @input=\"${(e: Event) =>\n\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\tf.key,\n\t\t\t\t\t\tthis.coerce(f.kind, (e.target as HTMLInputElement).value),\n\t\t\t\t\t)}\"> ${this.description(f)}</div>`;\n\t}\n\n\tprivate renderField(f: FieldDef) {\n\t\tswitch (f.kind) {\n\t\t\tcase 'tiles':\n\t\t\t\treturn this.renderTiles(f);\n\t\t\tcase 'select':\n\t\t\t\treturn this.renderSelect(f);\n\t\t\tcase 'toggle':\n\t\t\t\treturn this.renderToggle(f);\n\t\t\tdefault:\n\t\t\t\treturn this.renderInput(f);\n\t\t}\n\t}\n\n\tprivate locationBlock(group?: string) {\n\t\treturn html`<div class=\"location-block\"><label>${group ? `${humanize(group)} location` : 'Birth location'}${\n\t\t\t\t\tthis.locationRequired(group)\n\t\t\t\t\t\t? html`<span class=\"req\" aria-hidden=\"true\">*</span>`\n\t\t\t\t\t\t: nothing\n\t\t\t\t}</label><roxy-location-search publishable-key=\"${ifDefined(this.publishableKey)}\" @roxy-location-select=\"${this.onLocationFor(group)}\" placeholder=\"City of birth\"></roxy-location-search><small class=\"help\">Required: latitude, longitude, timezone. Pick a city to autofill.</small></div>`;\n\t}\n\n\tprivate groupCard(group: string) {\n\t\tconst fields = this.fields.filter(\n\t\t\t(f) => f.group === group && this.isRendered(f),\n\t\t);\n\t\treturn html`<fieldset class=\"person-group\"><legend>${humanize(group)}</legend>${this.groupHasLocation(group) ? this.locationBlock(group) : nothing}<div class=\"fields\">${fields.map((f) => this.renderField(f))}</div></fieldset>`;\n\t}\n\n\trender() {\n\t\tif (!this.loaded) {\n\t\t\treturn html`<form><div class=\"roxy-skeleton\" style=\"height:8rem\"></div></form>`;\n\t\t}\n\t\tif (this.specError) {\n\t\t\treturn html`<div class=\"spec-error\" role=\"alert\">Schema load failed: ${this.specError} <button type=\"button\" class=\"submit\" @click=\"${this.retryLoadSchema}\">Retry</button></div>`;\n\t\t}\n\n\t\tconst flat = this.fields.filter((f) => !f.group && this.isRendered(f));\n\t\tconst flatReq = flat.filter((f) => f.required);\n\t\tconst flatOpt = flat.filter((f) => !f.required);\n\t\tconst named = this.groupKeys().filter((g): g is string => g !== undefined);\n\t\tconst reqGroups = named.filter((g) => this.groupIsRequired(g));\n\t\tconst optGroups = named.filter((g) => !this.groupIsRequired(g));\n\t\tconst hasAdvanced = flatOpt.length > 0 || optGroups.length > 0;\n\n\t\treturn html`<form @submit=\"${this.onSubmit}\"><h2 class=\"title\">${this.formTitle}</h2>${\n\t\t\t\tthis.validationErrors.length > 0\n\t\t\t\t\t? html`<div class=\"validation-error\" role=\"alert\"><strong>Please complete:</strong> ${this.validationErrors.join(', ')}</div>`\n\t\t\t\t\t: nothing\n\t\t\t}<div class=\"fields\">${flatReq.map((f) => this.renderField(f))}</div>${this.groupHasLocation(undefined) ? this.locationBlock(undefined) : nothing} ${reqGroups.map((g) => this.groupCard(g))} ${\n\t\t\t\thasAdvanced\n\t\t\t\t\t? html`<details class=\"advanced\"><summary>Advanced${chevron()}</summary><div class=\"fields\">${flatOpt.map((f) => this.renderField(f))}</div>${optGroups.map((g) => this.groupCard(g))}</details>`\n\t\t\t\t\t: nothing\n\t\t\t} ${\n\t\t\t\tthis.singleEnumField\n\t\t\t\t\t? nothing\n\t\t\t\t\t: html`<button class=\"submit\" type=\"submit\">${this.effectiveSubmitLabel()}</button>`\n\t\t\t}</form>`;\n\t}\n\n\tprivate coerce(kind: string, v: string): unknown {\n\t\tif (v === '') return undefined;\n\t\tif (kind === 'number') {\n\t\t\tconst n = Number(v);\n\t\t\treturn Number.isFinite(n) ? n : undefined;\n\t\t}\n\t\treturn v;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'roxy-endpoint-form': RoxyEndpointForm;\n\t}\n}\n", "/**\n * Symbol constants used across components. Single source of truth so chart\n * wheels, card headers, hexagram displays, and panchang tables stay visually\n * consistent.\n */\n\nexport const PLANET_GLYPH: Record<string, string> = {\n\tSun: '\u2609',\n\tMoon: '\u263D',\n\tMercury: '\u263F',\n\tVenus: '\u2640',\n\tEarth: '\u2641',\n\tMars: '\u2642',\n\tJupiter: '\u2643',\n\tSaturn: '\u2644',\n\tUranus: '\u2645',\n\tNeptune: '\u2646',\n\tPluto: '\u2647',\n\tRahu: '\u260A',\n\tKetu: '\u260B',\n\tAscendant: 'Asc',\n\tLagna: 'La',\n\tNorthNode: '\u260A',\n\tSouthNode: '\u260B',\n\t'North node': '\u260A',\n\t'South node': '\u260B',\n\tChiron: '\u26B7',\n\tLilith: '\u26B8',\n\t'Black moon lilith': '\u26B8',\n};\n\nexport const PLANET_ABBR: Record<string, string> = {\n\tSun: 'Su',\n\tMoon: 'Mo',\n\tMercury: 'Me',\n\tVenus: 'Ve',\n\tMars: 'Ma',\n\tJupiter: 'Ju',\n\tSaturn: 'Sa',\n\tUranus: 'Ur',\n\tNeptune: 'Ne',\n\tPluto: 'Pl',\n\tRahu: 'Ra',\n\tKetu: 'Ke',\n\tAscendant: 'Asc',\n\tLagna: 'La',\n};\n\nexport const SIGN_GLYPH: Record<string, string> = {\n\tAries: '\u2648',\n\tTaurus: '\u2649',\n\tGemini: '\u264A',\n\tCancer: '\u264B',\n\tLeo: '\u264C',\n\tVirgo: '\u264D',\n\tLibra: '\u264E',\n\tScorpio: '\u264F',\n\tSagittarius: '\u2650',\n\tCapricorn: '\u2651',\n\tAquarius: '\u2652',\n\tPisces: '\u2653',\n};\n\nexport const SIGN_ABBR: Record<string, string> = {\n\tAries: 'Ar',\n\tTaurus: 'Ta',\n\tGemini: 'Ge',\n\tCancer: 'Cn',\n\tLeo: 'Le',\n\tVirgo: 'Vi',\n\tLibra: 'Li',\n\tScorpio: 'Sc',\n\tSagittarius: 'Sg',\n\tCapricorn: 'Cp',\n\tAquarius: 'Aq',\n\tPisces: 'Pi',\n};\n\nexport const SIGNS_ORDER = [\n\t'Aries',\n\t'Taurus',\n\t'Gemini',\n\t'Cancer',\n\t'Leo',\n\t'Virgo',\n\t'Libra',\n\t'Scorpio',\n\t'Sagittarius',\n\t'Capricorn',\n\t'Aquarius',\n\t'Pisces',\n] as const;\n\n/** Aspect symbols. Used by synastry and natal chart aspect tables. */\n/**\n * Glyph per aspect, keyed by the hyphen-free canonical name.\n *\n * @remarks\n * These are the nine aspects Unicode itself defines as a set, in its Miscellaneous Symbols block note: `260C, 26BA, 2220, 26B9, 25A1, 25B3, 26BC, 26BB, 260D` for 0, 30, 45, 60, 90, 120, 135, 150 and 180 degrees. That is exactly the vocabulary the API returns, so every aspect resolves to a real glyph and none falls through to a truncated slug.\n *\n * Do not substitute the visually similar maths operators. An earlier revision used `\u22BB` XOR for quincunx and `\u22BC` NAND for semisextile, which are the two characters Unicode lists as cross-references FROM the real glyphs, and it had them the wrong way round: charts rendered a 150 degree quincunx with the 30 degree semisextile symbol and vice versa. An astrologer reads the glyph, not the tooltip.\n */\nexport const ASPECT_SYMBOL: Record<string, string> = {\n\tconjunction: '\u260C',\n\tsemisextile: '\u26BA',\n\tsemisquare: '\u2220',\n\tsextile: '\u26B9',\n\tsquare: '\u25A1',\n\ttrine: '\u25B3',\n\tsesquiquadrate: '\u26BC',\n\tquincunx: '\u26BB',\n\topposition: '\u260D',\n};\n\n/** Trigrams used by I Ching hexagrams. Eight trigrams compose 64 hexagrams. */\nexport const TRIGRAM_GLYPH: Record<string, string> = {\n\theaven: '\u2630',\n\tlake: '\u2631',\n\tfire: '\u2632',\n\tthunder: '\u2633',\n\twind: '\u2634',\n\twater: '\u2635',\n\tmountain: '\u2636',\n\tearth: '\u2637',\n\tHeaven: '\u2630',\n\tLake: '\u2631',\n\tFire: '\u2632',\n\tThunder: '\u2633',\n\tWind: '\u2634',\n\tWater: '\u2635',\n\tMountain: '\u2636',\n\tEarth: '\u2637',\n};\n\n/** Moon phase emoji set. Used by moon phase card. */\nexport const MOON_PHASE_EMOJI: Record<string, string> = {\n\t'new moon': '\uD83C\uDF11',\n\t'waxing crescent': '\uD83C\uDF12',\n\t'first quarter': '\uD83C\uDF13',\n\t'waxing gibbous': '\uD83C\uDF14',\n\t'full moon': '\uD83C\uDF15',\n\t'waning gibbous': '\uD83C\uDF16',\n\t'last quarter': '\uD83C\uDF17',\n\t'waning crescent': '\uD83C\uDF18',\n};\n", "import { css } from 'lit';\n\n/**\n * Shared host styles every component pulls in. Sets default font, color,\n * container query support, and the entry fade-in.\n */\nexport const baseStyles = css`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;\n", "import type { TemplateResult } from 'lit';\nimport { css, html } from 'lit';\n\n/**\n * Disclosure chevron for `<details>`/`<summary>` accordions. Replaces the\n * browser default triangle with a thin chevron that rotates when the host\n * `<details>` opens. Render it inside the `<summary>` and pair with\n * {@link disclosureStyles}.\n */\nexport function chevron(): TemplateResult {\n\treturn html`<svg class=\"roxy-chevron\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\"><path d=\"M4 6l4 4 4-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n}\n\n/**\n * Shared `<details>` accordion styling: hides the native disclosure triangle\n * and rotates the {@link chevron} 180 degrees when the accordion is open.\n * Import into any component that renders disclosure accordions so the chevron\n * looks and behaves identically.\n */\nexport const disclosureStyles = css`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;\n", "/**\n * Shared string helpers used across components. Single source of truth so the\n * same formatting rules apply to every key/label/title that surfaces in the\n * shadow tree.\n *\n * - `capitalize`: title-cases the first character, lowercases the rest. Used\n * when matching API-supplied planet/sign names against the glyph maps in\n * `tokens/index.ts`, which use canonical TitleCase keys.\n * - `humanize`: turns an API key (`birth_date`, `birthDate`, `mahadasha-end`)\n * into a label suitable for display (\"Birth date\", \"Mahadasha end\").\n */\n\nexport function capitalize(s: string): string {\n\tif (!s) return '';\n\treturn s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();\n}\n\nexport function humanize(s: string): string {\n\treturn (\n\t\ts\n\t\t\t.replace(/[_-]+/g, ' ')\n\t\t\t.replace(/([a-z])([A-Z])/g, '$1 $2')\n\t\t\t// Split a trailing/embedded digit off a word so \"person1\" reads \"Person 1\"\n\t\t\t// and every group legend and field label spaces its ordinal.\n\t\t\t.replace(/([a-z])([0-9])/g, '$1 $2')\n\t\t\t.replace(/^\\w/, (c) => c.toUpperCase())\n\t);\n}\n", "/**\n * Pure, framework-free schema layer shared by the self-fetch form. It turns one OpenAPI operation into a digested list of {@link FieldDef}s whose {@link InputKind} decides which input widget renders, with zero Lit or DOM dependency so the build-time slice generator ({@link ../../../scripts/build-schemas.ts}) and the taxonomy-coverage test consume the exact same classification the browser does.\n *\n * @remarks\n * The registry is by SHAPE, never by name: {@link classifyInput} inspects `enum` / `type` / `format` only, so a new API parameter gets a working widget with no code change, and the taxonomy gate fails loudly (via a `null` return) the day a genuinely new shape appears. Name-driven behaviour (suppressing `lang`, hiding `seed` / `limit` / `offset`, replacing the latitude+longitude+timezone trio with a city search) is a separate render-time concern layered on top by the form, never encoded here.\n */\n\nimport { SIGNS_ORDER } from '../tokens/index.js';\nimport { humanize } from './string.js';\n\n/** A JSON `$ref` node, before resolution against `components.schemas`. */\nexport interface OpenApiSchemaRef {\n\t$ref?: string;\n}\n\n/** The subset of an OpenAPI 3 schema object the form reads. */\nexport interface OpenApiSchema extends OpenApiSchemaRef {\n\ttype?: string;\n\tformat?: string;\n\tdescription?: string;\n\tenum?: string[];\n\tdefault?: unknown;\n\tminimum?: number;\n\tmaximum?: number;\n\tproperties?: Record<string, OpenApiSchema>;\n\trequired?: string[];\n\titems?: OpenApiSchema;\n\texample?: unknown;\n\tanyOf?: OpenApiSchema[];\n\toneOf?: OpenApiSchema[];\n}\n\n/** One operation's request shape, as read from `spec.paths[path][method]`. */\nexport interface OperationSchema {\n\tsummary?: string;\n\trequestBody?: {\n\t\tcontent?: Record<string, { schema?: OpenApiSchema | OpenApiSchemaRef }>;\n\t};\n\tparameters?: Array<{\n\t\tname: string;\n\t\tin: string;\n\t\trequired?: boolean;\n\t\tschema?: OpenApiSchema;\n\t}>;\n}\n\n/** The minimal OpenAPI document surface the form introspects. */\nexport interface OpenApiDoc {\n\tpaths?: Record<string, Record<string, unknown>>;\n\tcomponents?: { schemas?: Record<string, OpenApiSchema> };\n}\n\n/** The fully typed spec document the build-time scripts read from the committed `specs/openapi.json`: every path item value is an {@link OperationSchema}. The runtime form keeps the looser {@link OpenApiDoc} because a live spec fetch is untrusted input it narrows per operation. */\nexport interface SpecDoc {\n\tpaths: Record<string, Record<string, OperationSchema>>;\n\tcomponents?: { schemas?: Record<string, OpenApiSchema> };\n}\n\n/**\n * The widget kind a parameter resolves to. This is the closed set the taxonomy gate enforces: every request parameter in the spec MUST classify to one of these, or {@link classifyInput} returns `null` and the gate fails, forcing a conscious decision when the API grows a new shape.\n */\nexport type InputKind =\n\t| 'tiles'\n\t| 'select'\n\t| 'toggle'\n\t| 'date'\n\t| 'time'\n\t| 'datetime'\n\t| 'number'\n\t| 'text'\n\t| 'array';\n\n/** A single input the form renders, digested from one schema property or parameter. */\nexport interface FieldDef {\n\t/** Unique storage + input key: the property name, or \"group.name\" for a nested object field. */\n\tkey: string;\n\t/** Schema property name (the label source), e.g. \"date\". */\n\tname: string;\n\t/** Parent object key for a nested schema (person1/person2); undefined for a flat field. */\n\tgroup?: string;\n\t/** True when the spec declares the field as `in: query`, so it belongs in the query string even on a POST. */\n\tinQuery?: boolean;\n\t/** The resolved widget kind. */\n\tkind: InputKind;\n\trequired: boolean;\n\tdescription?: string;\n\tenum?: string[];\n\tmin?: number;\n\tmax?: number;\n\tdefault?: unknown;\n\t/** Spec `example`, used as the placeholder for a text input. */\n\texample?: unknown;\n}\n\n/** The digested form model for one operation. The build-time slice is exactly this shape. */\nexport interface FormModel {\n\t/** Concise heading derived from the operation summary, falling back to the path. */\n\ttitle: string;\n\t/** Every rendered field. The `lang` query parameter is intentionally excluded (routed via the element `lang` attribute instead). */\n\tfields: FieldDef[];\n\t/** True when the operation carries a `lang` query parameter, so the form knows to route an effective language to the query string on submit. */\n\thasLang: boolean;\n}\n\n/** At most this many enum options render as a tile/chip picker; above it a filterable select is used instead. */\nexport const TILE_MAX = 12;\n\n/** The latitude+longitude+timezone trio the form suppresses in favour of a city search. Centralised so the render path and tests agree. */\nexport const LOCATION_TRIO = ['latitude', 'longitude', 'timezone'] as const;\n\n/** Canonical lowercase zodiac set, derived from {@link SIGNS_ORDER} so sign detection and the glyph map can never disagree. */\nconst ZODIAC_LOWER = SIGNS_ORDER.map((s) => s.toLowerCase());\n\n/** Resolve a `$ref` (one hop is all the spec uses) against the schema map; pass non-refs through. */\nexport function resolveSchema(\n\tschema: OpenApiSchema | OpenApiSchemaRef | undefined,\n\tall: Record<string, OpenApiSchema>,\n): OpenApiSchema | undefined {\n\tif (!schema) return undefined;\n\tif ('$ref' in schema && schema.$ref) {\n\t\tconst name = schema.$ref.split('/').pop();\n\t\treturn name ? all[name] : undefined;\n\t}\n\treturn schema as OpenApiSchema;\n}\n\n/**\n * Collapse an `anyOf`/`oneOf` union to the single member that decides the widget: an enum member wins (so `houseSystem` as enum-or-string renders as a picker), then any concrete-typed member (so timezone as number-or-string resolves to a real kind), else the first member. Non-union schemas pass through untouched.\n */\nfunction representative(s: OpenApiSchema): OpenApiSchema {\n\tconst union = s.anyOf ?? s.oneOf;\n\tif (!union || union.length === 0) return s;\n\treturn (\n\t\tunion.find((m) => Array.isArray(m.enum)) ??\n\t\tunion.find((m) => m.type && m.type !== 'null') ??\n\t\tunion[0] ??\n\t\ts\n\t);\n}\n\n/**\n * Map one resolved schema to its {@link InputKind}, or `null` when the shape is genuinely unhandled. The form treats `null` as a plain text fallback (never crashes); the taxonomy gate treats it as a failure (forces a decision). Object schemas are never passed here: an object with `properties` expands into a group of leaf fields upstream, so it has no leaf kind of its own.\n */\nexport function classifyInput(schema: OpenApiSchema): InputKind | null {\n\tconst s = representative(schema);\n\tif (Array.isArray(s.enum))\n\t\treturn s.enum.length <= TILE_MAX ? 'tiles' : 'select';\n\tif (s.type === 'boolean') return 'toggle';\n\tif (s.format === 'date') return 'date';\n\tif (s.format === 'time') return 'time';\n\tif (s.format === 'date-time') return 'datetime';\n\tif (s.type === 'integer' || s.type === 'number') return 'number';\n\tif (s.type === 'string') return 'text';\n\tif (s.type === 'array') return 'array';\n\treturn null;\n}\n\n/** True when an enum's values are exactly the twelve zodiac signs (case-insensitive), so the tiles can carry sign glyphs. */\nexport function isZodiacEnum(values: readonly string[]): boolean {\n\tif (values.length !== 12) return false;\n\tconst lower = new Set(values.map((v) => v.toLowerCase()));\n\treturn ZODIAC_LOWER.every((s) => lower.has(s));\n}\n\n/** One digested leaf field from a resolved schema. Shared by the flat and grouped construction paths so params and body props carry identical metadata (min/max included). */\nfunction toField(\n\tname: string,\n\tresolved: OpenApiSchema,\n\topts: { key: string; group?: string; required: boolean; inQuery?: boolean },\n): FieldDef {\n\tconst rep = representative(resolved);\n\treturn {\n\t\tkey: opts.key,\n\t\tname,\n\t\tgroup: opts.group,\n\t\tinQuery: opts.inQuery,\n\t\tkind: classifyInput(resolved) ?? 'text',\n\t\trequired: opts.required,\n\t\tdescription: rep.description ?? resolved.description,\n\t\tenum: rep.enum,\n\t\tmin: rep.minimum,\n\t\tmax: rep.maximum,\n\t\tdefault: resolved.default ?? rep.default,\n\t\texample: resolved.example ?? rep.example,\n\t};\n}\n\n/**\n * Digest one operation into the {@link FormModel} the form renders. This is the single construction path: body properties (nested objects expand to `group.sub` keys) and path+query parameters flow through {@link toField} identically, so a query integer keeps its min/max the same as a body integer. The `lang` query parameter is dropped from `fields` and surfaced as {@link FormModel.hasLang} instead.\n */\nexport function buildFormModel(\n\top: OperationSchema,\n\tschemas: Record<string, OpenApiSchema>,\n\tendpoint: string,\n): FormModel {\n\tconst fields: FieldDef[] = [];\n\tlet hasLang = false;\n\n\tconst bodyRef = op.requestBody?.content?.['application/json']?.schema;\n\tconst bodySchema = resolveSchema(bodyRef, schemas);\n\tif (bodySchema?.properties) {\n\t\tconst required = new Set(bodySchema.required ?? []);\n\t\tfor (const [name, sub] of Object.entries(bodySchema.properties)) {\n\t\t\tconst resolved = resolveSchema(sub, schemas) ?? {};\n\t\t\tif (resolved.type === 'object' && resolved.properties) {\n\t\t\t\tconst subRequired = new Set(resolved.required ?? []);\n\t\t\t\tfor (const [subName, subSchema] of Object.entries(\n\t\t\t\t\tresolved.properties,\n\t\t\t\t)) {\n\t\t\t\t\tconst r = resolveSchema(subSchema, schemas) ?? {};\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\ttoField(subName, r, {\n\t\t\t\t\t\t\tkey: `${name}.${subName}`,\n\t\t\t\t\t\t\tgroup: name,\n\t\t\t\t\t\t\trequired: required.has(name) && subRequired.has(subName),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfields.push(\n\t\t\t\t\ttoField(name, resolved, { key: name, required: required.has(name) }),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const param of op.parameters ?? []) {\n\t\tif (param.in !== 'path' && param.in !== 'query') continue;\n\t\t// lang is site-owner chrome, not a visitor field: route it through the\n\t\t// element `lang` attribute, never render it in the form.\n\t\tif (param.name === 'lang' && param.in === 'query') {\n\t\t\thasLang = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolved = resolveSchema(param.schema, schemas) ?? {};\n\t\tfields.push(\n\t\t\ttoField(param.name, resolved, {\n\t\t\t\tkey: param.name,\n\t\t\t\trequired: !!param.required,\n\t\t\t\tinQuery: param.in === 'query',\n\t\t\t}),\n\t\t);\n\t}\n\n\treturn { title: deriveTitle(op.summary, endpoint), fields, hasLang };\n}\n\n/**\n * Concise form heading. Prefers the operation summary (spec-authored), taking the clause before the first \" - \" so \"Daily horoscope by zodiac sign - Transit-based forecast\" reads as \"Daily horoscope by zodiac sign\", and falls back to the humanized last path segment.\n */\nexport function deriveTitle(\n\tsummary: string | undefined,\n\tendpoint: string,\n): string {\n\tconst lead = summary?.split(' - ')[0]?.trim();\n\tif (lead) return lead;\n\treturn humanize(endpoint.split('/').pop() ?? '');\n}\n\n/**\n * Outcome-first submit-button label keyed off the endpoint intent. Chart and reading endpoints \"Generate\", divination endpoints \"Cast\", comparison endpoints \"Compare\", and lookup/reading GETs \"Get reading\". A generic verb beats a bare \"Submit\" on a widget a visitor never set up.\n */\nexport function deriveSubmitLabel(endpoint: string): string {\n\tconst e = endpoint.toLowerCase();\n\tif (/compat|synastry|guna|connection|penta|composite/.test(e))\n\t\treturn 'Compare';\n\tif (/\\bcast\\b|\\/draw|iching|hexagram|tarot/.test(e)) return 'Cast';\n\tif (/horoscope|dream|angel|nakshatra|crystal|meaning|reference/.test(e))\n\t\treturn 'Get reading';\n\treturn 'Generate';\n}\n\n/** Deterministic slice filename for one operation, shared by the generator and the runtime loader so both address the same artifact. */\nexport function sliceFileName(method: string, endpoint: string): string {\n\tconst path = endpoint\n\t\t.replace(/^\\//, '')\n\t\t.replace(/[{}]/g, '')\n\t\t.replace(/\\//g, '-');\n\treturn `${method.toLowerCase()}--${path}.json`;\n}\n", "// Generated by scripts/sync-version.ts. Do not edit.\nexport const ROXY_UI_VERSION = '0.19.4';\n"],
4
+ "sourcesContent": ["import { css, html, LitElement, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { SIGN_GLYPH } from '../tokens/index.js';\nimport { baseStyles } from '../utils/base-styles.js';\nimport { chevron, disclosureStyles } from '../utils/disclosure.js';\nimport {\n\tbuildFormModel,\n\tderiveSubmitLabel,\n\ttype FieldDef,\n\ttype FormModel,\n\tisZodiacEnum,\n\tLOCATION_TRIO,\n\ttype OpenApiDoc,\n\ttype OperationSchema,\n\tsliceFileName,\n} from '../utils/field-schema.js';\nimport { capitalize, humanize } from '../utils/string.js';\nimport { ROXY_UI_VERSION } from '../version.js';\n\n/** Production spec, fetched when no slice is available and no explicit `spec-url` is set. */\nconst PROD_SPEC_URL = 'https://roxyapi.com/api/v2/openapi.json';\n\n/** Version-pinned jsDelivr base for the digested per-operation schema slices, mirroring the wrapper CDN pinning so a slice matches the bundle it ships beside. */\nconst SLICE_BASE = `https://cdn.jsdelivr.net/npm/@roxyapi/ui@${ROXY_UI_VERSION}/dist/schemas`;\n\nconst specCache = new Map<string, Promise<OpenApiDoc>>();\n\n/**\n * Drop every cached spec promise.\n\n * @remarks\n * Test-only, and deliberately NOT re-exported from the package entry. The cache is module state shared by every test file in a single `bun test` process, and it only self-evicts on rejection, so one file that resolves a spec leaves a warm entry that silently satisfies a later file assertion about fetching. That made slice-fallback coverage pass or fail purely on file order.\n\n * @internal\n */\nexport function resetSpecCache(): void {\n\tspecCache.clear();\n}\n\nasync function loadSpec(url: string): Promise<OpenApiDoc> {\n\tlet pending = specCache.get(url);\n\tif (!pending) {\n\t\tpending = fetch(url)\n\t\t\t.then(async (res) => {\n\t\t\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\t\t\treturn (await res.json()) as OpenApiDoc;\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\t// Evict the rejected promise BEFORE rethrowing so subsequent\n\t\t\t\t// callers (the user clicking Retry, a remount) hit the network\n\t\t\t\t// again instead of replaying the cached failure forever.\n\t\t\t\tspecCache.delete(url);\n\t\t\t\tthrow err;\n\t\t\t});\n\t\tspecCache.set(url, pending);\n\t}\n\treturn pending;\n}\n\n/** A fresh seed for a hidden `seed` field, so each submit is a new draw unless the caller pinned one. */\nfunction randomSeed(): string {\n\treturn (\n\t\tglobalThis.crypto?.randomUUID?.() ?? Math.random().toString(36).slice(2)\n\t);\n}\n\n/** Parse an array-field text value into a real array: JSON when it parses to one, else comma-separated tokens. */\nfunction parseArrayValue(raw: string): unknown {\n\tconst trimmed = raw.trim();\n\tif (!trimmed) return [];\n\ttry {\n\t\tconst parsed = JSON.parse(trimmed);\n\t\tif (Array.isArray(parsed)) return parsed;\n\t} catch {\n\t\t// Not JSON: fall through to comma splitting.\n\t}\n\treturn trimmed\n\t\t.split(',')\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean);\n}\n\n/**\n * Schema-driven form. Pass `endpoint` (e.g. \"vedic-astrology/birth-chart\"). The form digests the operation's request schema into a spec-derived input for each parameter (a zodiac tile grid, a date or time input, a city search, a toggle) with progressive disclosure, and emits a `roxy-submit` CustomEvent carrying the validated payload. The caller decides what to do (call the SDK, render a chart, navigate).\n *\n * @remarks\n * Schema resolution order: an explicit `spec-url` fetches that full spec and digests it (unchanged, the demo path); otherwise the form tries a small version-pinned per-operation slice from the CDN, and on any miss falls back to fetching the production spec. Each input kind is chosen purely from the parameter shape (see {@link ../utils/field-schema.ts}), so a new endpoint gets a working, on-brand form with no per-endpoint code.\n *\n * The visitor-facing `lang` parameter is never rendered: a site owner sets the element `lang` attribute, and the form routes it to the query string on submit. Optional parameters collapse under one Advanced disclosure; a form whose only required field is an enum submits on selection.\n */\n@customElement('roxy-endpoint-form')\nexport class RoxyEndpointForm extends LitElement {\n\tstatic styles = [\n\t\tbaseStyles,\n\t\tdisclosureStyles,\n\t\tcss`form{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);box-shadow:var(--roxy-shadow-sm);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.fields{align-items:start;gap:var(--roxy-space-md,1rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));display:grid}.fields:empty{display:none}.person-group{background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);gap:var(--roxy-space-md,1rem);min-inline-size:0;margin:0;display:grid}.person-group legend{padding:0 var(--roxy-space-xs,.25rem);font-weight:var(--roxy-weight-bold,600)}.field{gap:var(--roxy-space-xs,.25rem);flex-direction:column;min-width:0;display:flex}.tiles-field{grid-column:1/-1}label,.label{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-secondary,#475569)}.req{color:var(--roxy-danger-fg,#991b1b);margin-left:4px}input,select{box-sizing:border-box;width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);font-family:inherit}input:focus,select:focus{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-color:var(--roxy-accent-ink,#b45309)}.help{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem)}.help-details>summary{cursor:pointer;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);align-items:center;gap:4px;display:flex}.help-details .help-lead{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.help-details .help-full{margin-top:var(--roxy-space-xs,.25rem);display:block}.location-block{gap:var(--roxy-space-xs,.25rem);grid-column:1/-1;display:grid}.tiles{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(5.5rem,1fr));display:grid}.tile{min-height:44px;padding:var(--roxy-space-sm,.5rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;transition:border-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease), background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-direction:column;justify-content:center;align-items:center;gap:2px;display:flex}.tile:hover{border-color:var(--roxy-accent,#f59e0b)}.tile[aria-checked=true]{border-color:var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 12%, transparent);color:var(--roxy-accent-ink,#b45309);font-weight:var(--roxy-weight-bold,600)}.tile:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.tile-glyph{font-size:1.35em;line-height:1}.toggle-row{align-items:center;gap:var(--roxy-space-sm,.5rem);display:flex}.toggle{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);background:var(--roxy-border,#e4e4e7);cursor:pointer;width:44px;height:26px;transition:background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0;padding:0;position:relative}.toggle[aria-checked=true]{background:var(--roxy-accent,#f59e0b);border-color:var(--roxy-accent,#f59e0b)}.toggle .knob{background:var(--roxy-bg,#fff);width:20px;height:20px;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);border-radius:50%;position:absolute;top:2px;left:2px}.toggle[aria-checked=true] .knob{transform:translate(18px)}.toggle:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.toggle-label{cursor:pointer}@media (prefers-reduced-motion:reduce){.tile,.toggle,.toggle .knob{transition:none}}.advanced{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.advanced>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a);align-items:center;gap:6px;display:flex}.advanced[open]>summary{margin-bottom:var(--roxy-space-md,1rem)}.advanced .fields,.advanced .person-group{margin-top:var(--roxy-space-md,1rem)}.validation-error{gap:var(--roxy-space-xs,.25rem);padding:var(--roxy-space-md,1rem);background:color-mix(in srgb, var(--roxy-danger,#dc2626) 8%, transparent);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);display:grid}button.submit{background:var(--roxy-accent-ink,#b45309);color:var(--roxy-bg,#fff);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-lg,1.5rem);font-size:var(--roxy-text-base,1rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));border:0;justify-self:start}button.submit:hover{transform:scale(1.02)}button.submit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}@media (prefers-reduced-motion:reduce){button.submit{transition:none}}.spec-error{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}`,\n\t];\n\n\t@property({ type: String, attribute: 'data-endpoint' })\n\tendpoint = 'vedic-astrology/birth-chart';\n\n\t@property({ type: String })\n\tmethod: 'GET' | 'POST' = 'POST';\n\n\t/** Explicit OpenAPI spec URL. When set, the form fetches and digests that full spec (the demo path). When empty, it resolves a version-pinned slice first, then the production spec. */\n\t@property({ type: String, attribute: 'spec-url' })\n\tspecUrl = '';\n\n\t/** Override the submit-button label. Empty derives an outcome-first label from the endpoint. */\n\t@property({ type: String, attribute: 'submit-label' })\n\tsubmitLabel = '';\n\n\t/** Browser-safe publishable key, forwarded to the slotted city search so the natal or synastry form can geocode. */\n\t@property({ type: String, attribute: 'publishable-key' })\n\tpublishableKey?: string;\n\n\t/** Prefill values, keyed by field name (nested per group). Used by `remember` mode and to restore the previous submission. JS property only. */\n\t@property({ attribute: false })\n\tinitialValues?: Record<string, unknown>;\n\n\t@state()\n\tprivate fields: FieldDef[] = [];\n\n\t@state()\n\tprivate formTitle = '';\n\n\t@state()\n\tprivate hasLang = false;\n\n\t@state()\n\tprivate values: Record<string, unknown> = {};\n\n\t@state()\n\tprivate loaded = false;\n\n\t@state()\n\tprivate specError: string | null = null;\n\n\t@state()\n\tprivate validationErrors: string[] = [];\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tvoid this.loadSchema();\n\t}\n\n\tprivate async loadSchema() {\n\t\tthis.specError = null;\n\t\ttry {\n\t\t\tthis.applyModel(await this.resolveModel());\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\tthis.specError = message;\n\t\t\tthis.loaded = true;\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('roxy-spec-error', {\n\t\t\t\t\tdetail: { url: this.specUrl || PROD_SPEC_URL, message },\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Resolve the form model: explicit spec-url wins; else a version-pinned slice; else the production spec. */\n\tprivate async resolveModel(): Promise<FormModel> {\n\t\tif (this.specUrl) return this.modelFromSpec(this.specUrl);\n\t\tconst slice = await this.tryLoadSlice();\n\t\treturn slice ?? this.modelFromSpec(PROD_SPEC_URL);\n\t}\n\n\t/** Fetch and digest one operation from a full OpenAPI document. */\n\tprivate async modelFromSpec(url: string): Promise<FormModel> {\n\t\tconst spec = await loadSpec(url);\n\t\tconst path = `/${this.endpoint.replace(/^\\//, '')}`;\n\t\tconst op = spec.paths?.[path]?.[this.method.toLowerCase()] as\n\t\t\t| OperationSchema\n\t\t\t| undefined;\n\t\tif (!op) {\n\t\t\tthrow new Error(\n\t\t\t\t`Endpoint ${this.method} ${path} not found in OpenAPI spec`,\n\t\t\t);\n\t\t}\n\t\treturn buildFormModel(op, spec.components?.schemas ?? {}, this.endpoint);\n\t}\n\n\t/** Try the small precomputed slice; return null on any miss so the caller falls back to the full spec. */\n\tprivate async tryLoadSlice(): Promise<FormModel | null> {\n\t\ttry {\n\t\t\tconst res = await fetch(\n\t\t\t\t`${SLICE_BASE}/${sliceFileName(this.method, this.endpoint)}`,\n\t\t\t);\n\t\t\tif (!res.ok) return null;\n\t\t\treturn (await res.json()) as FormModel;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate applyModel(model: FormModel) {\n\t\tthis.fields = model.fields;\n\t\tthis.formTitle = model.title;\n\t\tthis.hasLang = model.hasLang;\n\t\t// Pre-fill: schema defaults first, then any remembered/initial values (only\n\t\t// for fields this endpoint has) so a stale stored payload from another\n\t\t// endpoint cannot inject unknown keys. Remembered values are nested per\n\t\t// group, so read them by group.\n\t\tconst init: Record<string, unknown> = {};\n\t\tfor (const f of model.fields) {\n\t\t\tif (f.default !== undefined) init[f.key] = f.default;\n\t\t\tconst remembered = f.group\n\t\t\t\t? (\n\t\t\t\t\t\tthis.initialValues?.[f.group] as Record<string, unknown> | undefined\n\t\t\t\t\t)?.[f.name]\n\t\t\t\t: this.initialValues?.[f.name];\n\t\t\tif (remembered !== undefined) init[f.key] = remembered;\n\t\t}\n\t\tthis.values = init;\n\t\tthis.loaded = true;\n\t}\n\n\tprivate retryLoadSchema = () => {\n\t\tthis.loaded = false;\n\t\tthis.specError = null;\n\t\tvoid this.loadSchema();\n\t};\n\n\tprivate setValue(name: string, value: unknown) {\n\t\tthis.values = { ...this.values, [name]: value };\n\t}\n\n\t/** The field's render role: a hidden autogenerated seed, a hidden defaulted limit/offset, a suppressed location coordinate, or a normally rendered input. */\n\tprivate roleOf(\n\t\tf: FieldDef,\n\t): 'seed' | 'hidden-default' | 'location' | 'normal' {\n\t\tif (f.name === 'seed') return 'seed';\n\t\tif ((f.name === 'limit' || f.name === 'offset') && !f.required)\n\t\t\treturn 'hidden-default';\n\t\tif (\n\t\t\t(LOCATION_TRIO as readonly string[]).includes(f.name) &&\n\t\t\tthis.groupHasLocation(f.group)\n\t\t)\n\t\t\treturn 'location';\n\t\treturn 'normal';\n\t}\n\n\t/** True when the field renders its own input (as opposed to being hidden or replaced by the city search). */\n\tprivate isRendered(f: FieldDef): boolean {\n\t\treturn this.roleOf(f) === 'normal';\n\t}\n\n\t/** Ordered, de-duplicated group keys (undefined flat group plus each named object). */\n\tprivate groupKeys(): (string | undefined)[] {\n\t\tconst keys: (string | undefined)[] = [];\n\t\tfor (const f of this.fields)\n\t\t\tif (!keys.includes(f.group)) keys.push(f.group);\n\t\treturn keys;\n\t}\n\n\t/** True when the fields in `group` (or the flat top level) carry latitude+longitude+timezone, so a location-search can autofill them. */\n\tprivate groupHasLocation(group?: string): boolean {\n\t\tconst inGroup = this.fields.filter((f) => f.group === group);\n\t\treturn LOCATION_TRIO.every((n) => inGroup.some((f) => f.name === n));\n\t}\n\n\t/**\n\t * True when the location block must show a required mark, i.e. ANY member of the trio is required. The block is a single city-search input that fills all three, so if even one is required (e.g. bodygraph requires `timezone` while `latitude`/`longitude` are optional) the input is required and `collectMissing` blocks submit without it. Requiring ALL three understated that: the asterisk went missing on a block the form still enforced, which reads as optional to a non-technical embedder.\n\t */\n\tprivate locationRequired(group?: string): boolean {\n\t\tconst inGroup = this.fields.filter((f) => f.group === group);\n\t\treturn LOCATION_TRIO.some((n) =>\n\t\t\tinGroup.some((f) => f.name === n && f.required),\n\t\t);\n\t}\n\n\t/** A named group is a required input when any of its leaf fields is required or it carries a location. */\n\tprivate groupIsRequired(group: string): boolean {\n\t\treturn (\n\t\t\tthis.groupHasLocation(group) ||\n\t\t\tthis.fields.some((f) => f.group === group && f.required)\n\t\t);\n\t}\n\n\t/**\n\t * The single visible required enum field, when the whole form reduces to exactly one: no location block, no named group, one required rendered enum. This is what turns the horoscope form into a tap-to-load sign grid; returns null otherwise.\n\t */\n\tprivate get singleEnumField(): FieldDef | null {\n\t\tif (this.groupKeys().some((g) => this.groupHasLocation(g))) return null;\n\t\tif (this.groupKeys().some((g) => g !== undefined)) return null;\n\t\tconst req = this.fields.filter((f) => f.required && this.isRendered(f));\n\t\tconst only = req[0];\n\t\tif (req.length !== 1 || !only) return null;\n\t\treturn only.kind === 'tiles' || only.kind === 'select' ? only : null;\n\t}\n\n\tprivate effectiveSubmitLabel(): string {\n\t\treturn this.submitLabel || deriveSubmitLabel(this.endpoint);\n\t}\n\n\t/** The site-owner language from the element `lang` attribute (native), or undefined. Read here, never a Lit property, to avoid shadowing the native accessor. */\n\tprivate effectiveLang(): string | undefined {\n\t\treturn this.lang || undefined;\n\t}\n\n\t/** Location-select handler bound to a group: fills that group's lat/lng/timezone keys (flat top level when group is undefined). */\n\tprivate onLocationFor(group?: string) {\n\t\tconst prefix = group ? `${group}.` : '';\n\t\treturn (e: Event) => {\n\t\t\tconst detail = (e as CustomEvent).detail as {\n\t\t\t\tlatitude?: number;\n\t\t\t\tlongitude?: number;\n\t\t\t\ttimezone?: string;\n\t\t\t\tutcOffset?: number;\n\t\t\t};\n\t\t\tif (!detail) return;\n\t\t\tthis.values = {\n\t\t\t\t...this.values,\n\t\t\t\t[`${prefix}latitude`]: detail.latitude,\n\t\t\t\t[`${prefix}longitude`]: detail.longitude,\n\t\t\t\t[`${prefix}timezone`]: detail.timezone ?? detail.utcOffset,\n\t\t\t};\n\t\t};\n\t}\n\n\tprivate selectTile(f: FieldDef, value: string) {\n\t\tthis.setValue(f.key, value);\n\t\tif (this.singleEnumField?.key === f.key) this.submit();\n\t}\n\n\t/** Roving-tabindex arrow-key navigation for a tile radiogroup, modeled on the shared tablist pattern (selection follows focus). */\n\tprivate onTilesKeyDown(f: FieldDef) {\n\t\treturn (e: KeyboardEvent) => {\n\t\t\tconst opts = f.enum ?? [];\n\t\t\tif (opts.length === 0) return;\n\t\t\tconst cur = opts.indexOf(this.values[f.key] as string);\n\t\t\tlet next: number;\n\t\t\tif (e.key === 'Home') next = 0;\n\t\t\telse if (e.key === 'End') next = opts.length - 1;\n\t\t\telse if (e.key === 'ArrowRight' || e.key === 'ArrowDown')\n\t\t\t\tnext = cur === -1 ? 0 : (cur + 1) % opts.length;\n\t\t\telse if (e.key === 'ArrowLeft' || e.key === 'ArrowUp')\n\t\t\t\tnext =\n\t\t\t\t\tcur === -1 ? opts.length - 1 : (cur - 1 + opts.length) % opts.length;\n\t\t\telse return;\n\t\t\te.preventDefault();\n\t\t\tconst value = opts[next];\n\t\t\tif (value === undefined) return;\n\t\t\tthis.selectTile(f, value);\n\t\t\tconst root = e.currentTarget as HTMLElement;\n\t\t\trequestAnimationFrame(() =>\n\t\t\t\troot.querySelector<HTMLButtonElement>(`[data-tile='${next}']`)?.focus(),\n\t\t\t);\n\t\t};\n\t}\n\n\tprivate onSubmit = (e: Event) => {\n\t\te.preventDefault();\n\t\tthis.submit();\n\t};\n\n\t/** Validate, then emit `roxy-submit` with the reconstructed payload, the spec query keys, and whether the form was a single-enum sticky picker. */\n\tprivate submit() {\n\t\tconst missing = this.collectMissing();\n\t\tif (missing.keys.length > 0) {\n\t\t\tthis.validationErrors = missing.labels;\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('roxy-validation-error', {\n\t\t\t\t\tdetail: { missing: missing.keys },\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis.validationErrors = [];\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const f of this.fields) {\n\t\t\tlet v = this.values[f.key];\n\t\t\t// A hidden seed autogenerates per submit unless a value was remembered.\n\t\t\tif (f.name === 'seed' && (v === undefined || v === '')) v = randomSeed();\n\t\t\tif (v === undefined || v === '') continue;\n\t\t\tif (f.kind === 'array' && typeof v === 'string') v = parseArrayValue(v);\n\t\t\tif (f.group) {\n\t\t\t\tconst g = (out[f.group] as Record<string, unknown> | undefined) ?? {};\n\t\t\t\tg[f.name] = v;\n\t\t\t\tout[f.group] = g;\n\t\t\t} else {\n\t\t\t\tout[f.name] = v;\n\t\t\t}\n\t\t}\n\t\t// The spec knows which parameters belong in the query string; the listener\n\t\t// does not. Report them (including a site-owner lang) so a POST with a query\n\t\t// parameter reaches the API correctly instead of being dropped in the body.\n\t\tconst queryKeys = this.fields.filter((f) => f.inQuery).map((f) => f.name);\n\t\tconst lang = this.effectiveLang();\n\t\tif (this.hasLang && lang) {\n\t\t\tout.lang = lang;\n\t\t\tqueryKeys.push('lang');\n\t\t}\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent('roxy-submit', {\n\t\t\t\tdetail: {\n\t\t\t\t\tendpoint: this.endpoint,\n\t\t\t\t\tvalues: out,\n\t\t\t\t\tqueryKeys,\n\t\t\t\t\tsticky: this.singleEnumField != null,\n\t\t\t\t},\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** Required fields left empty, with the location trio collapsed to one entry per group. Seed and hidden defaults never block. */\n\tprivate collectMissing(): { keys: string[]; labels: string[] } {\n\t\tconst keys: string[] = [];\n\t\tconst labels: string[] = [];\n\t\tconst locGroups = new Set<string | undefined>();\n\t\tfor (const f of this.fields) {\n\t\t\tif (!f.required) continue;\n\t\t\tconst isLocation = this.roleOf(f) === 'location';\n\t\t\tif (!this.isRendered(f) && !isLocation) continue;\n\t\t\tconst v = this.values[f.key];\n\t\t\tif (v !== undefined && v !== '') continue;\n\t\t\tkeys.push(f.key);\n\t\t\tif (isLocation) {\n\t\t\t\tlocGroups.add(f.group);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlabels.push(\n\t\t\t\tf.group ? `${humanize(f.group)} ${humanize(f.name)}` : humanize(f.name),\n\t\t\t);\n\t\t}\n\t\tfor (const g of locGroups) {\n\t\t\tlabels.push(g ? `${humanize(g)} location` : 'Birth location');\n\t\t}\n\t\treturn { keys, labels };\n\t}\n\n\tprivate reqMark(f: FieldDef) {\n\t\treturn f.required\n\t\t\t? html`<span class=\"req\" aria-hidden=\"true\">*</span>`\n\t\t\t: nothing;\n\t}\n\n\t/** A description under a field: rendered inline when short, collapsed behind a disclosure showing its first line when long. */\n\tprivate description(f: FieldDef) {\n\t\tif (!f.description) return nothing;\n\t\tif (f.description.length <= 120) {\n\t\t\treturn html`<small class=\"help\">${f.description}</small>`;\n\t\t}\n\t\tconst lead = f.description.split('. ')[0] ?? f.description;\n\t\treturn html`<details class=\"help-details\"><summary><span class=\"help-lead\">${lead}</span>${chevron()}</summary><small class=\"help help-full\">${f.description}</small></details>`;\n\t}\n\n\tprivate renderTiles(f: FieldDef) {\n\t\tconst labelId = `roxy-form-${f.key}-label`;\n\t\tconst zodiac = !!f.enum && isZodiacEnum(f.enum);\n\t\tconst opts = f.enum ?? [];\n\t\tconst cur = opts.indexOf(this.values[f.key] as string);\n\t\tconst active = cur === -1 ? 0 : cur;\n\t\treturn html`<div class=\"field tiles-field\"><span class=\"label\" id=\"${labelId}\">${humanize(f.name)}${this.reqMark(f)}</span><div class=\"tiles\" role=\"radiogroup\" aria-labelledby=\"${labelId}\" @keydown=\"${this.onTilesKeyDown(f)}\">${opts.map((opt, i) => {\n\t\t\t\t\tconst selected = this.values[f.key] === opt;\n\t\t\t\t\tconst glyph = zodiac ? SIGN_GLYPH[capitalize(opt)] : undefined;\n\t\t\t\t\treturn html`<button type=\"button\" class=\"tile\" role=\"radio\" data-tile=\"${i}\" aria-checked=\"${selected ? 'true' : 'false'}\" tabindex=\"${i === active ? '0' : '-1'}\" @click=\"${() => this.selectTile(f, opt)}\">${\n\t\t\t\t\t\t\tglyph\n\t\t\t\t\t\t\t\t? html`<span class=\"tile-glyph\" aria-hidden=\"true\">${glyph}</span>`\n\t\t\t\t\t\t\t\t: nothing\n\t\t\t\t\t\t} <span class=\"tile-label\">${humanize(opt)}</span></button>`;\n\t\t\t\t})}</div>${this.description(f)}</div>`;\n\t}\n\n\tprivate renderSelect(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\treturn html`<div class=\"field\"><label for=\"${id}\">${humanize(f.name)}${this.reqMark(f)}</label> <select id=\"${id}\" ?required=\"${f.required}\" @change=\"${(e: Event) =>\n\t\t\t\t\tthis.setValue(f.key, (e.target as HTMLSelectElement).value)}\"><option value=\"\">Choose</option>${(f.enum ?? []).map(\n\t\t\t\t\t(\n\t\t\t\t\t\topt,\n\t\t\t\t\t) => html`<option value=\"${opt}\" ?selected=\"${this.values[f.key] === opt}\">${humanize(opt)}</option>`,\n\t\t\t\t)}</select> ${this.description(f)}</div>`;\n\t}\n\n\tprivate renderToggle(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst checked = this.values[f.key] === true;\n\t\treturn html`<div class=\"field\"><div class=\"toggle-row\"><button type=\"button\" id=\"${id}\" class=\"toggle\" role=\"switch\" aria-checked=\"${checked ? 'true' : 'false'}\" @click=\"${() => this.setValue(f.key, !checked)}\"><span class=\"knob\"></span></button> <label class=\"toggle-label\" for=\"${id}\">${humanize(f.name)}${this.reqMark(f)}</label></div>${this.description(f)}</div>`;\n\t}\n\n\tprivate renderInput(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst type =\n\t\t\tf.kind === 'datetime'\n\t\t\t\t? 'datetime-local'\n\t\t\t\t: f.kind === 'number'\n\t\t\t\t\t? 'number'\n\t\t\t\t\t: f.kind;\n\t\tconst placeholder =\n\t\t\tf.kind === 'array'\n\t\t\t\t? 'Comma separated'\n\t\t\t\t: f.example != null\n\t\t\t\t\t? String(f.example)\n\t\t\t\t\t: '';\n\t\treturn html`<div class=\"field\"><label for=\"${id}\">${humanize(f.name)}${this.reqMark(f)}</label> <input id=\"${id}\" type=\"${f.kind === 'array' ? 'text' : type}\" ?required=\"${f.required}\" min=\"${ifDefined(f.min)}\" max=\"${ifDefined(f.max)}\" step=\"${f.kind === 'number' ? 'any' : nothing}\" placeholder=\"${placeholder || nothing}\" .value=\"${(this.values[f.key] ?? '') as string}\" @input=\"${(e: Event) =>\n\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\tf.key,\n\t\t\t\t\t\tthis.coerce(f.kind, (e.target as HTMLInputElement).value),\n\t\t\t\t\t)}\"> ${this.description(f)}</div>`;\n\t}\n\n\tprivate renderField(f: FieldDef) {\n\t\tswitch (f.kind) {\n\t\t\tcase 'tiles':\n\t\t\t\treturn this.renderTiles(f);\n\t\t\tcase 'select':\n\t\t\t\treturn this.renderSelect(f);\n\t\t\tcase 'toggle':\n\t\t\t\treturn this.renderToggle(f);\n\t\t\tdefault:\n\t\t\t\treturn this.renderInput(f);\n\t\t}\n\t}\n\n\tprivate locationBlock(group?: string) {\n\t\treturn html`<div class=\"location-block\"><label>${group ? `${humanize(group)} location` : 'Birth location'}${\n\t\t\t\t\tthis.locationRequired(group)\n\t\t\t\t\t\t? html`<span class=\"req\" aria-hidden=\"true\">*</span>`\n\t\t\t\t\t\t: nothing\n\t\t\t\t}</label><roxy-location-search publishable-key=\"${ifDefined(this.publishableKey)}\" @roxy-location-select=\"${this.onLocationFor(group)}\" placeholder=\"City of birth\"></roxy-location-search><small class=\"help\">Required: latitude, longitude, timezone. Pick a city to autofill.</small></div>`;\n\t}\n\n\tprivate groupCard(group: string) {\n\t\tconst fields = this.fields.filter(\n\t\t\t(f) => f.group === group && this.isRendered(f),\n\t\t);\n\t\treturn html`<fieldset class=\"person-group\"><legend>${humanize(group)}</legend>${this.groupHasLocation(group) ? this.locationBlock(group) : nothing}<div class=\"fields\">${fields.map((f) => this.renderField(f))}</div></fieldset>`;\n\t}\n\n\trender() {\n\t\tif (!this.loaded) {\n\t\t\treturn html`<form><div class=\"roxy-skeleton\" style=\"height:8rem\"></div></form>`;\n\t\t}\n\t\tif (this.specError) {\n\t\t\treturn html`<div class=\"spec-error\" role=\"alert\">Schema load failed: ${this.specError} <button type=\"button\" class=\"submit\" @click=\"${this.retryLoadSchema}\">Retry</button></div>`;\n\t\t}\n\n\t\tconst flat = this.fields.filter((f) => !f.group && this.isRendered(f));\n\t\tconst flatReq = flat.filter((f) => f.required);\n\t\tconst flatOpt = flat.filter((f) => !f.required);\n\t\tconst named = this.groupKeys().filter((g): g is string => g !== undefined);\n\t\tconst reqGroups = named.filter((g) => this.groupIsRequired(g));\n\t\tconst optGroups = named.filter((g) => !this.groupIsRequired(g));\n\t\tconst hasAdvanced = flatOpt.length > 0 || optGroups.length > 0;\n\n\t\treturn html`<form @submit=\"${this.onSubmit}\"><h2 class=\"title\">${this.formTitle}</h2>${\n\t\t\t\tthis.validationErrors.length > 0\n\t\t\t\t\t? html`<div class=\"validation-error\" role=\"alert\"><strong>Please complete:</strong> ${this.validationErrors.join(', ')}</div>`\n\t\t\t\t\t: nothing\n\t\t\t}<div class=\"fields\">${flatReq.map((f) => this.renderField(f))}</div>${this.groupHasLocation(undefined) ? this.locationBlock(undefined) : nothing} ${reqGroups.map((g) => this.groupCard(g))} ${\n\t\t\t\thasAdvanced\n\t\t\t\t\t? html`<details class=\"advanced\"><summary>Advanced${chevron()}</summary><div class=\"fields\">${flatOpt.map((f) => this.renderField(f))}</div>${optGroups.map((g) => this.groupCard(g))}</details>`\n\t\t\t\t\t: nothing\n\t\t\t} ${\n\t\t\t\tthis.singleEnumField\n\t\t\t\t\t? nothing\n\t\t\t\t\t: html`<button class=\"submit\" type=\"submit\">${this.effectiveSubmitLabel()}</button>`\n\t\t\t}</form>`;\n\t}\n\n\tprivate coerce(kind: string, v: string): unknown {\n\t\tif (v === '') return undefined;\n\t\tif (kind === 'number') {\n\t\t\tconst n = Number(v);\n\t\t\treturn Number.isFinite(n) ? n : undefined;\n\t\t}\n\t\treturn v;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'roxy-endpoint-form': RoxyEndpointForm;\n\t}\n}\n", "/**\n * Symbol constants used across components. Single source of truth so chart\n * wheels, card headers, hexagram displays, and panchang tables stay visually\n * consistent.\n */\n\nexport const PLANET_GLYPH: Record<string, string> = {\n\tSun: '\u2609',\n\tMoon: '\u263D',\n\tMercury: '\u263F',\n\tVenus: '\u2640',\n\tEarth: '\u2641',\n\tMars: '\u2642',\n\tJupiter: '\u2643',\n\tSaturn: '\u2644',\n\tUranus: '\u2645',\n\tNeptune: '\u2646',\n\tPluto: '\u2647',\n\tRahu: '\u260A',\n\tKetu: '\u260B',\n\tAscendant: 'Asc',\n\tLagna: 'La',\n\tNorthNode: '\u260A',\n\tSouthNode: '\u260B',\n\t'North node': '\u260A',\n\t'South node': '\u260B',\n\tChiron: '\u26B7',\n\tLilith: '\u26B8',\n\t'Black moon lilith': '\u26B8',\n};\n\nexport const PLANET_ABBR: Record<string, string> = {\n\tSun: 'Su',\n\tMoon: 'Mo',\n\tMercury: 'Me',\n\tVenus: 'Ve',\n\tMars: 'Ma',\n\tJupiter: 'Ju',\n\tSaturn: 'Sa',\n\tUranus: 'Ur',\n\tNeptune: 'Ne',\n\tPluto: 'Pl',\n\tRahu: 'Ra',\n\tKetu: 'Ke',\n\tAscendant: 'Asc',\n\tLagna: 'La',\n};\n\nexport const SIGN_GLYPH: Record<string, string> = {\n\tAries: '\u2648',\n\tTaurus: '\u2649',\n\tGemini: '\u264A',\n\tCancer: '\u264B',\n\tLeo: '\u264C',\n\tVirgo: '\u264D',\n\tLibra: '\u264E',\n\tScorpio: '\u264F',\n\tSagittarius: '\u2650',\n\tCapricorn: '\u2651',\n\tAquarius: '\u2652',\n\tPisces: '\u2653',\n};\n\nexport const SIGN_ABBR: Record<string, string> = {\n\tAries: 'Ar',\n\tTaurus: 'Ta',\n\tGemini: 'Ge',\n\tCancer: 'Cn',\n\tLeo: 'Le',\n\tVirgo: 'Vi',\n\tLibra: 'Li',\n\tScorpio: 'Sc',\n\tSagittarius: 'Sg',\n\tCapricorn: 'Cp',\n\tAquarius: 'Aq',\n\tPisces: 'Pi',\n};\n\nexport const SIGNS_ORDER = [\n\t'Aries',\n\t'Taurus',\n\t'Gemini',\n\t'Cancer',\n\t'Leo',\n\t'Virgo',\n\t'Libra',\n\t'Scorpio',\n\t'Sagittarius',\n\t'Capricorn',\n\t'Aquarius',\n\t'Pisces',\n] as const;\n\n/** Aspect symbols. Used by synastry and natal chart aspect tables. */\n/**\n * Glyph per aspect, keyed by the hyphen-free canonical name.\n *\n * @remarks\n * These are the nine aspects Unicode itself defines as a set, in its Miscellaneous Symbols block note: `260C, 26BA, 2220, 26B9, 25A1, 25B3, 26BC, 26BB, 260D` for 0, 30, 45, 60, 90, 120, 135, 150 and 180 degrees. That is exactly the vocabulary the API returns, so every aspect resolves to a real glyph and none falls through to a truncated slug.\n *\n * Do not substitute the visually similar maths operators. An earlier revision used `\u22BB` XOR for quincunx and `\u22BC` NAND for semisextile, which are the two characters Unicode lists as cross-references FROM the real glyphs, and it had them the wrong way round: charts rendered a 150 degree quincunx with the 30 degree semisextile symbol and vice versa. An astrologer reads the glyph, not the tooltip.\n */\nexport const ASPECT_SYMBOL: Record<string, string> = {\n\tconjunction: '\u260C',\n\tsemisextile: '\u26BA',\n\tsemisquare: '\u2220',\n\tsextile: '\u26B9',\n\tsquare: '\u25A1',\n\ttrine: '\u25B3',\n\tsesquiquadrate: '\u26BC',\n\tquincunx: '\u26BB',\n\topposition: '\u260D',\n};\n\n/** Trigrams used by I Ching hexagrams. Eight trigrams compose 64 hexagrams. */\nexport const TRIGRAM_GLYPH: Record<string, string> = {\n\theaven: '\u2630',\n\tlake: '\u2631',\n\tfire: '\u2632',\n\tthunder: '\u2633',\n\twind: '\u2634',\n\twater: '\u2635',\n\tmountain: '\u2636',\n\tearth: '\u2637',\n\tHeaven: '\u2630',\n\tLake: '\u2631',\n\tFire: '\u2632',\n\tThunder: '\u2633',\n\tWind: '\u2634',\n\tWater: '\u2635',\n\tMountain: '\u2636',\n\tEarth: '\u2637',\n};\n\n/** Moon phase emoji set. Used by moon phase card. */\nexport const MOON_PHASE_EMOJI: Record<string, string> = {\n\t'new moon': '\uD83C\uDF11',\n\t'waxing crescent': '\uD83C\uDF12',\n\t'first quarter': '\uD83C\uDF13',\n\t'waxing gibbous': '\uD83C\uDF14',\n\t'full moon': '\uD83C\uDF15',\n\t'waning gibbous': '\uD83C\uDF16',\n\t'last quarter': '\uD83C\uDF17',\n\t'waning crescent': '\uD83C\uDF18',\n};\n", "import { css } from 'lit';\n\n/**\n * Shared host styles every component pulls in. Sets default font, color,\n * container query support, and the entry fade-in.\n */\nexport const baseStyles = css`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;\n", "import type { TemplateResult } from 'lit';\nimport { css, html } from 'lit';\n\n/**\n * Disclosure chevron for `<details>`/`<summary>` accordions. Replaces the\n * browser default triangle with a thin chevron that rotates when the host\n * `<details>` opens. Render it inside the `<summary>` and pair with\n * {@link disclosureStyles}.\n */\nexport function chevron(): TemplateResult {\n\treturn html`<svg class=\"roxy-chevron\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\"><path d=\"M4 6l4 4 4-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n}\n\n/**\n * Shared `<details>` accordion styling: hides the native disclosure triangle\n * and rotates the {@link chevron} 180 degrees when the accordion is open.\n * Import into any component that renders disclosure accordions so the chevron\n * looks and behaves identically.\n */\nexport const disclosureStyles = css`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;\n", "/**\n * Shared string helpers used across components. Single source of truth so the\n * same formatting rules apply to every key/label/title that surfaces in the\n * shadow tree.\n *\n * - `capitalize`: title-cases the first character, lowercases the rest. Used\n * when matching API-supplied planet/sign names against the glyph maps in\n * `tokens/index.ts`, which use canonical TitleCase keys.\n * - `humanize`: turns an API key (`birth_date`, `birthDate`, `mahadasha-end`)\n * into a label suitable for display (\"Birth date\", \"Mahadasha end\").\n */\n\nexport function capitalize(s: string): string {\n\tif (!s) return '';\n\treturn s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();\n}\n\nexport function humanize(s: string): string {\n\treturn (\n\t\ts\n\t\t\t.replace(/[_-]+/g, ' ')\n\t\t\t.replace(/([a-z])([A-Z])/g, '$1 $2')\n\t\t\t// Split a trailing/embedded digit off a word so \"person1\" reads \"Person 1\"\n\t\t\t// and every group legend and field label spaces its ordinal.\n\t\t\t.replace(/([a-z])([0-9])/g, '$1 $2')\n\t\t\t.replace(/^\\w/, (c) => c.toUpperCase())\n\t);\n}\n", "/**\n * Pure, framework-free schema layer shared by the self-fetch form. It turns one OpenAPI operation into a digested list of {@link FieldDef}s whose {@link InputKind} decides which input widget renders, with zero Lit or DOM dependency so the build-time slice generator ({@link ../../../scripts/build-schemas.ts}) and the taxonomy-coverage test consume the exact same classification the browser does.\n *\n * @remarks\n * The registry is by SHAPE, never by name: {@link classifyInput} inspects `enum` / `type` / `format` only, so a new API parameter gets a working widget with no code change, and the taxonomy gate fails loudly (via a `null` return) the day a genuinely new shape appears. Name-driven behaviour (suppressing `lang`, hiding `seed` / `limit` / `offset`, replacing the latitude+longitude+timezone trio with a city search) is a separate render-time concern layered on top by the form, never encoded here.\n */\n\nimport { SIGNS_ORDER } from '../tokens/index.js';\nimport { humanize } from './string.js';\n\n/** A JSON `$ref` node, before resolution against `components.schemas`. */\nexport interface OpenApiSchemaRef {\n\t$ref?: string;\n}\n\n/** The subset of an OpenAPI 3 schema object the form reads. */\nexport interface OpenApiSchema extends OpenApiSchemaRef {\n\ttype?: string;\n\tformat?: string;\n\tdescription?: string;\n\tenum?: string[];\n\tdefault?: unknown;\n\tminimum?: number;\n\tmaximum?: number;\n\tproperties?: Record<string, OpenApiSchema>;\n\trequired?: string[];\n\titems?: OpenApiSchema;\n\texample?: unknown;\n\tanyOf?: OpenApiSchema[];\n\toneOf?: OpenApiSchema[];\n}\n\n/** One operation's request shape, as read from `spec.paths[path][method]`. */\nexport interface OperationSchema {\n\tsummary?: string;\n\trequestBody?: {\n\t\tcontent?: Record<string, { schema?: OpenApiSchema | OpenApiSchemaRef }>;\n\t};\n\tparameters?: Array<{\n\t\tname: string;\n\t\tin: string;\n\t\trequired?: boolean;\n\t\tschema?: OpenApiSchema;\n\t}>;\n}\n\n/** The minimal OpenAPI document surface the form introspects. */\nexport interface OpenApiDoc {\n\tpaths?: Record<string, Record<string, unknown>>;\n\tcomponents?: { schemas?: Record<string, OpenApiSchema> };\n}\n\n/** The fully typed spec document the build-time scripts read from the committed `specs/openapi.json`: every path item value is an {@link OperationSchema}. The runtime form keeps the looser {@link OpenApiDoc} because a live spec fetch is untrusted input it narrows per operation. */\nexport interface SpecDoc {\n\tpaths: Record<string, Record<string, OperationSchema>>;\n\tcomponents?: { schemas?: Record<string, OpenApiSchema> };\n}\n\n/**\n * The widget kind a parameter resolves to. This is the closed set the taxonomy gate enforces: every request parameter in the spec MUST classify to one of these, or {@link classifyInput} returns `null` and the gate fails, forcing a conscious decision when the API grows a new shape.\n */\nexport type InputKind =\n\t| 'tiles'\n\t| 'select'\n\t| 'toggle'\n\t| 'date'\n\t| 'time'\n\t| 'datetime'\n\t| 'number'\n\t| 'text'\n\t| 'array';\n\n/** A single input the form renders, digested from one schema property or parameter. */\nexport interface FieldDef {\n\t/** Unique storage + input key: the property name, or \"group.name\" for a nested object field. */\n\tkey: string;\n\t/** Schema property name (the label source), e.g. \"date\". */\n\tname: string;\n\t/** Parent object key for a nested schema (person1/person2); undefined for a flat field. */\n\tgroup?: string;\n\t/** True when the spec declares the field as `in: query`, so it belongs in the query string even on a POST. */\n\tinQuery?: boolean;\n\t/** The resolved widget kind. */\n\tkind: InputKind;\n\trequired: boolean;\n\tdescription?: string;\n\tenum?: string[];\n\tmin?: number;\n\tmax?: number;\n\tdefault?: unknown;\n\t/** Spec `example`, used as the placeholder for a text input. */\n\texample?: unknown;\n}\n\n/** The digested form model for one operation. The build-time slice is exactly this shape. */\nexport interface FormModel {\n\t/** Concise heading derived from the operation summary, falling back to the path. */\n\ttitle: string;\n\t/** Every rendered field. The `lang` query parameter is intentionally excluded (routed via the element `lang` attribute instead). */\n\tfields: FieldDef[];\n\t/** True when the operation carries a `lang` query parameter, so the form knows to route an effective language to the query string on submit. */\n\thasLang: boolean;\n}\n\n/** At most this many enum options render as a tile/chip picker; above it a filterable select is used instead. */\nexport const TILE_MAX = 12;\n\n/** The latitude+longitude+timezone trio the form suppresses in favour of a city search. Centralised so the render path and tests agree. */\nexport const LOCATION_TRIO = ['latitude', 'longitude', 'timezone'] as const;\n\n/** Canonical lowercase zodiac set, derived from {@link SIGNS_ORDER} so sign detection and the glyph map can never disagree. */\nconst ZODIAC_LOWER = SIGNS_ORDER.map((s) => s.toLowerCase());\n\n/** Resolve a `$ref` (one hop is all the spec uses) against the schema map; pass non-refs through. */\nexport function resolveSchema(\n\tschema: OpenApiSchema | OpenApiSchemaRef | undefined,\n\tall: Record<string, OpenApiSchema>,\n): OpenApiSchema | undefined {\n\tif (!schema) return undefined;\n\tif ('$ref' in schema && schema.$ref) {\n\t\tconst name = schema.$ref.split('/').pop();\n\t\treturn name ? all[name] : undefined;\n\t}\n\treturn schema as OpenApiSchema;\n}\n\n/**\n * Collapse an `anyOf`/`oneOf` union to the single member that decides the widget: an enum member wins (so `houseSystem` as enum-or-string renders as a picker), then any concrete-typed member (so timezone as number-or-string resolves to a real kind), else the first member. Non-union schemas pass through untouched.\n */\nfunction representative(s: OpenApiSchema): OpenApiSchema {\n\tconst union = s.anyOf ?? s.oneOf;\n\tif (!union || union.length === 0) return s;\n\treturn (\n\t\tunion.find((m) => Array.isArray(m.enum)) ??\n\t\tunion.find((m) => m.type && m.type !== 'null') ??\n\t\tunion[0] ??\n\t\ts\n\t);\n}\n\n/**\n * Map one resolved schema to its {@link InputKind}, or `null` when the shape is genuinely unhandled. The form treats `null` as a plain text fallback (never crashes); the taxonomy gate treats it as a failure (forces a decision). Object schemas are never passed here: an object with `properties` expands into a group of leaf fields upstream, so it has no leaf kind of its own.\n */\nexport function classifyInput(schema: OpenApiSchema): InputKind | null {\n\tconst s = representative(schema);\n\tif (Array.isArray(s.enum))\n\t\treturn s.enum.length <= TILE_MAX ? 'tiles' : 'select';\n\tif (s.type === 'boolean') return 'toggle';\n\tif (s.format === 'date') return 'date';\n\tif (s.format === 'time') return 'time';\n\tif (s.format === 'date-time') return 'datetime';\n\tif (s.type === 'integer' || s.type === 'number') return 'number';\n\tif (s.type === 'string') return 'text';\n\tif (s.type === 'array') return 'array';\n\treturn null;\n}\n\n/** True when an enum's values are exactly the twelve zodiac signs (case-insensitive), so the tiles can carry sign glyphs. */\nexport function isZodiacEnum(values: readonly string[]): boolean {\n\tif (values.length !== 12) return false;\n\tconst lower = new Set(values.map((v) => v.toLowerCase()));\n\treturn ZODIAC_LOWER.every((s) => lower.has(s));\n}\n\n/** One digested leaf field from a resolved schema. Shared by the flat and grouped construction paths so params and body props carry identical metadata (min/max included). */\nfunction toField(\n\tname: string,\n\tresolved: OpenApiSchema,\n\topts: { key: string; group?: string; required: boolean; inQuery?: boolean },\n): FieldDef {\n\tconst rep = representative(resolved);\n\treturn {\n\t\tkey: opts.key,\n\t\tname,\n\t\tgroup: opts.group,\n\t\tinQuery: opts.inQuery,\n\t\tkind: classifyInput(resolved) ?? 'text',\n\t\trequired: opts.required,\n\t\tdescription: rep.description ?? resolved.description,\n\t\tenum: rep.enum,\n\t\tmin: rep.minimum,\n\t\tmax: rep.maximum,\n\t\tdefault: resolved.default ?? rep.default,\n\t\texample: resolved.example ?? rep.example,\n\t};\n}\n\n/**\n * Digest one operation into the {@link FormModel} the form renders. This is the single construction path: body properties (nested objects expand to `group.sub` keys) and path+query parameters flow through {@link toField} identically, so a query integer keeps its min/max the same as a body integer. The `lang` query parameter is dropped from `fields` and surfaced as {@link FormModel.hasLang} instead.\n */\nexport function buildFormModel(\n\top: OperationSchema,\n\tschemas: Record<string, OpenApiSchema>,\n\tendpoint: string,\n): FormModel {\n\tconst fields: FieldDef[] = [];\n\tlet hasLang = false;\n\n\tconst bodyRef = op.requestBody?.content?.['application/json']?.schema;\n\tconst bodySchema = resolveSchema(bodyRef, schemas);\n\tif (bodySchema?.properties) {\n\t\tconst required = new Set(bodySchema.required ?? []);\n\t\tfor (const [name, sub] of Object.entries(bodySchema.properties)) {\n\t\t\tconst resolved = resolveSchema(sub, schemas) ?? {};\n\t\t\tif (resolved.type === 'object' && resolved.properties) {\n\t\t\t\tconst subRequired = new Set(resolved.required ?? []);\n\t\t\t\tfor (const [subName, subSchema] of Object.entries(\n\t\t\t\t\tresolved.properties,\n\t\t\t\t)) {\n\t\t\t\t\tconst r = resolveSchema(subSchema, schemas) ?? {};\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\ttoField(subName, r, {\n\t\t\t\t\t\t\tkey: `${name}.${subName}`,\n\t\t\t\t\t\t\tgroup: name,\n\t\t\t\t\t\t\trequired: required.has(name) && subRequired.has(subName),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfields.push(\n\t\t\t\t\ttoField(name, resolved, { key: name, required: required.has(name) }),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const param of op.parameters ?? []) {\n\t\tif (param.in !== 'path' && param.in !== 'query') continue;\n\t\t// lang is site-owner chrome, not a visitor field: route it through the\n\t\t// element `lang` attribute, never render it in the form.\n\t\tif (param.name === 'lang' && param.in === 'query') {\n\t\t\thasLang = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolved = resolveSchema(param.schema, schemas) ?? {};\n\t\tfields.push(\n\t\t\ttoField(param.name, resolved, {\n\t\t\t\tkey: param.name,\n\t\t\t\trequired: !!param.required,\n\t\t\t\tinQuery: param.in === 'query',\n\t\t\t}),\n\t\t);\n\t}\n\n\treturn { title: deriveTitle(op.summary, endpoint), fields, hasLang };\n}\n\n/**\n * Concise form heading. Prefers the operation summary (spec-authored), taking the clause before the first \" - \" so \"Daily horoscope by zodiac sign - Transit-based forecast\" reads as \"Daily horoscope by zodiac sign\", and falls back to the humanized last path segment.\n */\nexport function deriveTitle(\n\tsummary: string | undefined,\n\tendpoint: string,\n): string {\n\tconst lead = summary?.split(' - ')[0]?.trim();\n\tif (lead) return lead;\n\treturn humanize(endpoint.split('/').pop() ?? '');\n}\n\n/**\n * Outcome-first submit-button label keyed off the endpoint intent. Chart and reading endpoints \"Generate\", divination endpoints \"Cast\", comparison endpoints \"Compare\", and lookup/reading GETs \"Get reading\". A generic verb beats a bare \"Submit\" on a widget a visitor never set up.\n */\nexport function deriveSubmitLabel(endpoint: string): string {\n\tconst e = endpoint.toLowerCase();\n\tif (/compat|synastry|guna|connection|penta|composite/.test(e))\n\t\treturn 'Compare';\n\tif (/\\bcast\\b|\\/draw|iching|hexagram|tarot/.test(e)) return 'Cast';\n\tif (/horoscope|dream|angel|nakshatra|crystal|meaning|reference/.test(e))\n\t\treturn 'Get reading';\n\treturn 'Generate';\n}\n\n/** Deterministic slice filename for one operation, shared by the generator and the runtime loader so both address the same artifact. */\nexport function sliceFileName(method: string, endpoint: string): string {\n\tconst path = endpoint\n\t\t.replace(/^\\//, '')\n\t\t.replace(/[{}]/g, '')\n\t\t.replace(/\\//g, '-');\n\treturn `${method.toLowerCase()}--${path}.json`;\n}\n", "// Generated by scripts/sync-version.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ACtBzE",
6
6
  "names": ["css", "html", "LitElement", "nothing", "customElement", "property", "state", "ifDefined", "SIGN_GLYPH", "SIGNS_ORDER", "css", "baseStyles", "css", "html", "chevron", "disclosureStyles", "capitalize", "s", "humanize", "c", "TILE_MAX", "LOCATION_TRIO", "ZODIAC_LOWER", "SIGNS_ORDER", "s", "resolveSchema", "schema", "all", "name", "representative", "union", "m", "classifyInput", "isZodiacEnum", "values", "lower", "v", "toField", "resolved", "opts", "rep", "buildFormModel", "op", "schemas", "endpoint", "fields", "hasLang", "bodyRef", "bodySchema", "required", "sub", "subRequired", "subName", "subSchema", "r", "param", "deriveTitle", "summary", "lead", "humanize", "deriveSubmitLabel", "e", "sliceFileName", "method", "path", "ROXY_UI_VERSION", "PROD_SPEC_URL", "SLICE_BASE", "ROXY_UI_VERSION", "specCache", "resetSpecCache", "loadSpec", "url", "pending", "res", "err", "randomSeed", "parseArrayValue", "raw", "trimmed", "parsed", "s", "RoxyEndpointForm", "LitElement", "message", "spec", "path", "op", "buildFormModel", "sliceFileName", "model", "init", "f", "remembered", "name", "value", "LOCATION_TRIO", "keys", "group", "inGroup", "n", "g", "req", "only", "deriveSubmitLabel", "prefix", "e", "detail", "opts", "cur", "next", "root", "missing", "out", "v", "queryKeys", "lang", "labels", "locGroups", "isLocation", "humanize", "html", "nothing", "lead", "chevron", "labelId", "zodiac", "isZodiacEnum", "active", "opt", "i", "selected", "glyph", "SIGN_GLYPH", "capitalize", "id", "checked", "type", "placeholder", "ifDefined", "fields", "flat", "flatReq", "flatOpt", "named", "reqGroups", "optGroups", "hasAdvanced", "kind", "baseStyles", "disclosureStyles", "css", "__decorateClass", "property", "state", "customElement"]
7
7
  }
@@ -12,6 +12,11 @@ import { RoxyDataElement } from '../utils/base-element.js';
12
12
  * The significators tab is the event-timing surface: house-wise (which planets
13
13
  * signify each house) and planet-wise (which houses each planet signifies),
14
14
  * both graded L1 to L4 with the API's own level labels shown as the legend.
15
+ *
16
+ * Every bare house number is captioned from the response `houseThemes` map, so
17
+ * "11, 6" reads "gains, enemies" and a cusp row says what that cusp is for. The
18
+ * words are the requested language and the requested `focus` lens, which is why
19
+ * they are read from the payload and never from a table held here.
15
20
  */
16
21
  export declare class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
17
22
  static styles: import("lit").CSSResult[];
@@ -29,6 +34,8 @@ export declare class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
29
34
  * grading a reader sees is the grading the engine applied.
30
35
  */
31
36
  private renderSignificators;
37
+ /** The house wording under a number cell, or nothing when the request did not ask for themes. */
38
+ private renderThemes;
32
39
  /** An em-dash-free placeholder keeps an empty level cell from reading as missing data. */
33
40
  private renderCell;
34
41
  private planetsAtLevel;
@@ -1 +1 @@
1
- {"version":3,"file":"kp-chart.d.ts","sourceRoot":"","sources":["../../src/components/kp-chart.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAwD3D;;;;;;;;;;;;GAYG;AACH,qBACa,WAAY,SAAQ,eAAe,CAAC,eAAe,CAAC;IAChE,MAAM,CAAC,MAAM,4BA8GX;IAGF,OAAO,CAAC,SAAS,CAAkB;IAEnC,wEAAwE;IACxE,OAAO,CAAC,MAAM;IAqCd,SAAS,CAAC,WAAW;IAIrB,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,eAAe;IAoDvC,OAAO,CAAC,aAAa;IA0CrB,OAAO,CAAC,WAAW;IAwCnB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAwE3B,0FAA0F;IAC1F,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,aAAa;IAMrB,gFAAgF;IAChF,OAAO,CAAC,iBAAiB;CAezB;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,WAAW,CAAC;KAC7B;CACD"}
1
+ {"version":3,"file":"kp-chart.d.ts","sourceRoot":"","sources":["../../src/components/kp-chart.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AA8D3D;;;;;;;;;;;;;;;;;GAiBG;AACH,qBACa,WAAY,SAAQ,eAAe,CAAC,eAAe,CAAC;IAChE,MAAM,CAAC,MAAM,4BAyHX;IAGF,OAAO,CAAC,SAAS,CAAkB;IAEnC,wEAAwE;IACxE,OAAO,CAAC,MAAM;IAqCd,SAAS,CAAC,WAAW;IAIrB,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,eAAe;IAoDvC,OAAO,CAAC,aAAa;IA0CrB,OAAO,CAAC,WAAW;IA2CnB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IA6E3B,iGAAiG;IACjG,OAAO,CAAC,YAAY;IAIpB,0FAA0F;IAC1F,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,aAAa;IAMrB,gFAAgF;IAChF,OAAO,CAAC,iBAAiB;CAezB;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,WAAW,CAAC;KAC7B;CACD"}
@@ -1,2 +1,2 @@
1
- var q=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var l=(s,r,e,t)=>{for(var n=t>1?void 0:t?O(r,e):r,o=s.length-1,i;o>=0;o--)(i=s[o])&&(n=(t?i(r,e,n):i(n))||n);return t&&n&&q(r,e,n),n};import{css as Q,html as a,nothing as h}from"lit";import{customElement as tt,state as et}from"lit/decorators.js";import{html as c,LitElement as V}from"lit";import{property as p,state as x}from"lit/decorators.js";import{ifDefined as k}from"lit/directives/if-defined.js";import{css as D}from"lit";var v=D`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;var S="Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side.";function P(s){return!!s&&!s.startsWith("pk_")}function N(s,r={}){r.warn&&console.warn(S),s.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{reason:"possible-secret-key",message:S},bubbles:!0,composed:!0}))}var j="https://roxyapi.com/api/v2",w=class{constructor(r){this.baseUrl=j;this.host=r,r.addController(this)}hostDisconnected(){this.abort?.abort(),this.abort=void 0}async run(r){if(!this.submitUrl&&this.secretKeyRefused())return;this.abort?.abort();let e=new AbortController;this.abort=e,this.host.loading=!0,this.host.error=null;try{let t=this.submitUrl?await fetch(this.submitUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r),signal:e.signal}):await this.callApi(r,e.signal);if(!t.ok)throw new Error(await this.readError(t));let n=await t.json();if(e.signal.aborted)return;this.host.data=n}catch(t){if(t?.name==="AbortError")return;this.host.error=t instanceof Error?t.message:String(t)}finally{this.abort===e&&(this.abort=void 0),e.signal.aborted||(this.host.loading=!1)}}callApi(r,e){let t=new URL(`${this.baseUrl}${r.path}`);for(let[o,i]of Object.entries(r.query??{}))i!=null&&t.searchParams.set(o,String(i));let n={Accept:"application/json"};return this.publishableKey&&(n["X-API-Key"]=this.publishableKey),r.body!=null&&(n["Content-Type"]="application/json"),fetch(t,{method:r.method??"GET",headers:n,body:r.body!=null?JSON.stringify(r.body):void 0,signal:e})}secretKeyRefused(){return P(this.publishableKey)?(this.host.error=S,N(this.host),!0):!1}async readError(r){try{let e=await r.json();if(e?.error)return e.error}catch{}return`Request failed (${r.status})`}};function C(s,r,e,t=[]){let n={...e},o=`/${s.replace(/^\//,"")}`.replace(/\{([^}]+)\}/g,(b,m)=>{let y=n[m];return delete n[m],encodeURIComponent(String(y??""))}),i=new Set(t),f={},d={};for(let[b,m]of Object.entries(n))m===void 0||m===""||(r==="GET"||i.has(b)?f[b]=m:d[b]=m);return{path:o,method:r,query:f,body:r==="POST"?d:void 0}}var G="roxy-data";function B(s){return s.nodeName==="SCRIPT"&&s.getAttribute("type")==="application/json"}var $=class{constructor(r){this.host=r,r.addController(this)}hostConnected(){if(this.host.data!=null)return;let r=this.read();r!==void 0&&(this.host.data=r,this.host.requestUpdate())}read(){let r=this.findInlineScript();return r?this.parse(r.textContent):void 0}findInlineScript(){for(let r of Array.from(this.host.children))if(B(r)&&r.classList.contains(G))return r;return null}parse(r){if(r?.trim())try{return JSON.parse(r)}catch{return}}};var u=class extends V{constructor(){super();this.data=null;this.endpoint="";this.method="POST";this.remember=!1;this.loading=!1;this.error=null;this.selfFetched=!1;this.editing=!1;this.sticky=!1;this.onEdit=()=>{this.editing=!0};this.onFormSubmit=e=>{let t=e.detail;this.lastValues=t.values,this.sticky=!!t.sticky,this.selfFetched=!0,this.editing=!1,this.remember&&this.writeRemembered(t.values),this.fetcher.run(C(this.endpoint,this.method,t.values,t.queryKeys??[]))};new $(this),this.fetcher=new w(this)}static{this.styles=[v]}willUpdate(e){e.has("publishableKey")&&(this.fetcher.publishableKey=this.publishableKey),e.has("baseUrl")&&this.baseUrl&&(this.fetcher.baseUrl=this.baseUrl),e.has("submitUrl")&&(this.fetcher.submitUrl=this.submitUrl)}render(){return this.loading?this.renderLoading():this.error!=null?this.renderError(this.error):this.data!=null?this.selfFetched?this.editing?this.renderForm():this.renderResult(this.data):this.showAttribution()?c`${this.renderData(this.data)}${this.renderAttribution()}`:this.renderData(this.data):this.renderNoData()}renderResult(e){let t=this.sticky?c`${this.renderForm()}${this.renderData(e)}`:c`<div class="roxy-edit-bar"><button type="button" class="roxy-edit" @click="${this.onEdit}">Edit query</button></div>${this.renderData(e)}`;return this.showAttribution()?c`${t}${this.renderAttribution()}`:t}showAttribution(){return this.attribution!=null&&this.attribution!=="off"&&this.attribution!=="false"}renderAttribution(){return c`<div class="roxy-attribution"><a href="https://roxyapi.com/?utm_source=widget&utm_medium=embed" target="_blank" rel="noopener">Spiritual data by RoxyAPI</a></div>`}renderNoData(){return this.endpoint?this.renderForm():this.renderEmpty()}renderForm(){return c`<roxy-endpoint-form data-endpoint="${this.endpoint}" method="${this.method}" spec-url="${k(this.specUrl)}" publishable-key="${k(this.publishableKey)}" submit-label="${k(this.submitLabel)}" lang="${k(this.effectiveLang())}" .initialValues="${this.formInitialValues()}" @roxy-submit="${this.onFormSubmit}"></roxy-endpoint-form>`}formInitialValues(){return this.lastValues??(this.remember?this.readRemembered():void 0)}effectiveLang(){return this.lang||void 0}rememberKey(){return`roxy-ui:form:${this.endpoint}`}readRemembered(){try{let e=sessionStorage.getItem(this.rememberKey());return e?JSON.parse(e):void 0}catch{return}}writeRemembered(e){try{sessionStorage.setItem(this.rememberKey(),JSON.stringify(e))}catch{}}renderEmpty(){return c`<div class="roxy-empty" role="status">No data</div>`}renderLoading(){return c`<div class="roxy-skeleton" style="height:8rem" role="status" aria-label="Loading"></div>`}renderError(e){let t=c`<div class="roxy-error" role="alert">${e}</div>`;return this.endpoint?c`${t}${this.renderForm()}`:t}};l([p({attribute:!1})],u.prototype,"data",2),l([p({type:String,attribute:"data-endpoint"})],u.prototype,"endpoint",2),l([p({type:String})],u.prototype,"method",2),l([p({type:String,attribute:"publishable-key"})],u.prototype,"publishableKey",2),l([p({type:String,attribute:"base-url"})],u.prototype,"baseUrl",2),l([p({type:String,attribute:"spec-url"})],u.prototype,"specUrl",2),l([p({type:String,attribute:"submit-url"})],u.prototype,"submitUrl",2),l([p({type:Boolean})],u.prototype,"remember",2),l([p({type:String,attribute:"submit-label"})],u.prototype,"submitLabel",2),l([p({type:String})],u.prototype,"attribution",2),l([x()],u.prototype,"loading",2),l([x()],u.prototype,"error",2),l([x()],u.prototype,"selfFetched",2),l([x()],u.prototype,"editing",2),l([x()],u.prototype,"sticky",2);var E=["Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius","Capricorn","Aquarius","Pisces"];function J(s){let r=s%360;return r<0?r+360:r}function Y(s){let r=J(s),e=Math.floor(r/30)%12,t=r%30,n=Math.floor(t),o=(t-n)*60,i=Math.floor(o),f=Math.round((o-i)*60);return{sign:E[e]??"Aries",signIndex:e,degree:n,minute:i,second:f}}function T(s){let{sign:r,degree:e,minute:t}=Y(s);return`${e}\xB0 ${r} ${String(t).padStart(2,"0")}'`}function K(s){return s.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([a-z])([0-9])/g,"$1 $2").replace(/^\w/,r=>r.toUpperCase())}function W(s,r=1){if(typeof s!="number"||!Number.isFinite(s))return"";let e=s.toFixed(r);return e.includes(".")?e.replace(/\.?0+$/,""):e}var Z={"kp-newcomb":"KP Newcomb","kp-old":"KP Old",lahiri:"Lahiri"};function M(s,r){let e=typeof s=="string"?Z[s]??K(s):"",t=typeof r=="number"?`${W(r,2)}\xB0`:"";return e&&t?`${e} (${t})`:e||t}import{css as X,html as R,nothing as U}from"lit";var I=X`.roxy-tablist{border-bottom:2px solid var(--roxy-border,#e4e4e7);scrollbar-width:thin;gap:2px;min-width:0;display:flex;overflow-x:auto}.roxy-tab{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-sm,.875rem);cursor:pointer;color:var(--roxy-muted,#71717a);transition:color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);background:0 0;border:none;border-bottom:2px solid #0000;flex-shrink:0;margin-bottom:-2px;font-family:inherit}.roxy-tab[aria-selected=true]{color:var(--roxy-accent-ink,#b45309);border-bottom-color:var(--roxy-accent,#f59e0b);font-weight:var(--roxy-weight-bold,600)}.roxy-tab:hover:not([aria-selected=true]){color:var(--roxy-fg,#0a0a0a)}.roxy-tab:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:-2px;border-radius:4px}`;function _(s){let{items:r,active:e,onSelect:t,label:n,idPrefix:o,controls:i=!1}=s;return R`<div class="roxy-tablist" role="tablist" aria-label="${n}" @keydown="${d=>{if(d.key!=="ArrowRight"&&d.key!=="ArrowLeft")return;d.preventDefault();let b=r.findIndex(F=>F.id===e);if(b===-1)return;let m=d.key==="ArrowRight"?1:-1,y=r[(b+m+r.length)%r.length];if(!y)return;t(y.id);let z=d.currentTarget.getRootNode();requestAnimationFrame(()=>{z.querySelector(`#${o}-tab-${y.id}`)?.focus()})}}">${r.map(d=>R`<button type="button" class="roxy-tab" role="tab" id="${o}-tab-${d.id}" aria-selected="${e===d.id?"true":"false"}" aria-controls="${i?`${o}-panel-${d.id}`:U}" tabindex="${e===d.id?"0":"-1"}" @click="${()=>t(d.id)}">${d.label}</button>`)}</div>${i?r.filter(d=>d.id!==e).map(d=>R`<div role="tabpanel" id="${o}-panel-${d.id}" aria-labelledby="${o}-tab-${d.id}" hidden></div>`):U}`}var rt=[{id:"planets",label:"Planets"},{id:"cusps",label:"Cusps"},{id:"significators",label:"Significators"}],L=[1,2,3,4];function A(s,r){return s?typeof r=="number"?`${s} ${r}`:s:""}function H(s){return[...new Set(s.map(String))].join(" > ")}var g=class extends u{constructor(){super(...arguments);this.activeTab="planets"}bodies(){let e=this.data;if(!e)return[];let t=(e.planets??[]).map(o=>({name:o.planet,longitude:o.longitude,house:o.house,nakshatra:o.nakshatra,pada:o.pada,starLord:o.starLord,subLord:o.subLord,subSubLord:o.subSubLord,kpNumber:o.kpNumber,retrograde:o.retrograde})),n=e.nodes;for(let[o,i]of[["Rahu",n?.rahu],["Ketu",n?.ketu]])i&&t.push({name:o,longitude:i.longitude,house:i.house,nakshatra:i.nakshatra,starLord:i.starLord,subLord:i.subLord,subSubLord:i.subSubLord,kpNumber:i.kpNumber,retrograde:!0});return t}renderEmpty(){return a`<div class="roxy-empty" role="status">No KP chart data</div>`}renderData(e){let t=e.ascendant;return a`<div class="wrap" aria-label="KP chart" tabindex="0"><header class="head"><h2 class="title">KP chart</h2>${t?a`<div class="asc">Ascendant: <strong>${typeof t.longitude=="number"?T(t.longitude):t.sign??""} </strong>${t.nakshatra?a`· ${A(t.nakshatra,t.pada)}`:h} ${t.subLord?a`· sub lord ${t.subLord}`:h} ${typeof t.kpNumber=="number"?a`· KP ${t.kpNumber}`:h}</div>`:h} ${typeof e.meta?.ayanamsa=="number"?a`<div class="ayan">Ayanamsa: ${M(e.meta.ayanamsaType,e.meta.ayanamsa)} ${e.meta.houseSystem?a`· ${e.meta.houseSystem} houses`:h}</div>`:h}</header>${_({items:rt,active:this.activeTab,onSelect:n=>{this.activeTab=n},label:"KP chart views",idPrefix:"kp",controls:!0})}<div id="kp-panel-${this.activeTab}" role="tabpanel" aria-labelledby="kp-tab-${this.activeTab}">${this.activeTab==="planets"?this.renderPlanets():this.activeTab==="cusps"?this.renderCusps():this.renderSignificators()}</div></div>`}renderPlanets(){let e=this.bodies();return e.length?a`<table role="table"><caption class="roxy-sr-only">KP planets and nodes: each body with its position, house, nakshatra and pada, star lord, sub lord, sub sub lord and KP number.</caption><thead><tr><th scope="col">Body</th><th scope="col">Position</th><th scope="col">House</th><th scope="col">Nakshatra, pada</th><th scope="col">Star lord</th><th scope="col">Sub lord</th><th scope="col">Sub sub lord</th><th scope="col">KP no.</th></tr></thead><tbody>${e.map(t=>a`<tr><td class="body">${t.name}${t.retrograde?a`<span class="retro">R</span>`:h}</td><td class="num">${typeof t.longitude=="number"?T(t.longitude):""}</td><td class="num">${typeof t.house=="number"?t.house:""}</td><td>${A(t.nakshatra,t.pada)}</td><td>${t.starLord??""}</td><td>${t.subLord??""}</td><td>${t.subSubLord??""}</td><td class="num">${typeof t.kpNumber=="number"?t.kpNumber:""}</td></tr>`)}</tbody></table>`:a`<p class="roxy-empty" role="status">No planets</p>`}renderCusps(){let e=this.data?.cusps??[];return e.length?a`<table role="table"><caption class="roxy-sr-only">KP Placidus cusps: each house cusp with its position, sign lord, nakshatra and pada, star lord, sub lord, sub sub lord and KP number.</caption><thead><tr><th scope="col">House</th><th scope="col">Position</th><th scope="col">Sign lord</th><th scope="col">Nakshatra, pada</th><th scope="col">Star lord</th><th scope="col">Sub lord</th><th scope="col">Sub sub lord</th><th scope="col">KP no.</th></tr></thead><tbody>${e.map(t=>a`<tr><td class="body num">${t.house}</td><td class="num">${typeof t.longitude=="number"?T(t.longitude):t.sign??""}</td><td>${t.signLord??""}</td><td>${A(t.nakshatra,t.pada)}</td><td>${t.starLord??""}</td><td>${t.subLord??""}</td><td>${t.subSubLord??""}</td><td class="num">${typeof t.kpNumber=="number"?t.kpNumber:""}</td></tr>`)}</tbody></table>`:a`<p class="roxy-empty" role="status">No cusps</p>`}renderSignificators(){let e=this.data?.significators,t=e?.houseWise??[],n=e?.planetWise??[];return!t.length&&!n.length?a`<p class="roxy-empty" role="status">No significators</p>`:a`${this.renderLevelLegend(t)} ${t.length?a`<div class="sig-head"><h3 class="sig-title">House-wise significators</h3><p class="sig-note">Planets that signify each house, strongest level first.</p></div><table role="table"><caption class="roxy-sr-only">KP house-wise significators: each house, the planets that signify it at levels 1 to 4, and the full strength order.</caption><thead><tr><th scope="col">House</th>${L.map(o=>a`<th scope="col">L${o}</th>`)}<th scope="col">Strength order</th></tr></thead><tbody>${t.map(o=>a`<tr><td class="body num">${o.house}</td>${L.map(i=>this.renderCell(this.planetsAtLevel(o,i).join(", ")))}<td class="chain">${H(o.all??[])}</td></tr>`)}</tbody></table>`:h} ${n.length?a`<div class="sig-head"><h3 class="sig-title">Planet-wise significators</h3><p class="sig-note">Houses each planet signifies, strongest level first.</p></div><table role="table"><caption class="roxy-sr-only">KP planet-wise significators: each planet, the houses it signifies at levels 1 to 4, and the full strength order.</caption><thead><tr><th scope="col">Planet</th>${L.map(o=>a`<th scope="col">L${o}</th>`)}<th scope="col">Strength order</th></tr></thead><tbody>${n.map(o=>a`<tr><td class="body">${o.planet}</td>${L.map(i=>this.renderCell(this.housesAtLevel(o,i).join(", ")))}<td class="chain">${H(o.allHouses??[])}</td></tr>`)}</tbody></table>`:h}`}renderCell(e){return e?a`<td>${e}</td>`:a`<td class="empty-cell">none</td>`}planetsAtLevel(e,t){return(e.significators??[]).filter(n=>n.level===t).flatMap(n=>n.planets??[])}housesAtLevel(e,t){return(e.signifies??[]).filter(n=>n.level===t).flatMap(n=>n.houses??[])}renderLevelLegend(e){let t=new Map;for(let n of e)for(let o of n.significators??[])o.description&&!t.has(o.level)&&t.set(o.level,o.description);return t.size===0?h:a`<ul class="legend" aria-label="Significator levels">${[...t.entries()].sort((n,o)=>n[0]-o[0]).map(([n,o])=>a`<li><b>L${n}</b>${o}</li>`)}</ul>`}};g.styles=[v,I,Q`.wrap{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);background:var(--roxy-surface,#fff);box-shadow:var(--roxy-shadow-sm);width:100%;overflow:auto}.head{padding:var(--roxy-space-md,1rem);border-bottom:1px solid var(--roxy-border,#e4e4e7);gap:var(--roxy-space-xs,.25rem);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.asc,.ayan{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-sm,.875rem)}.asc strong{color:var(--roxy-fg,#0a0a0a)}.roxy-tablist{padding:0 var(--roxy-space-md,1rem)}table{border-collapse:collapse;width:100%;font-size:var(--roxy-text-sm,.875rem);min-width:620px}thead{background:color-mix(in srgb, var(--roxy-border,#e4e4e7) 20%, transparent)}th,td{padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);text-align:left;white-space:nowrap}th{color:var(--roxy-muted,#71717a);font-weight:var(--roxy-weight-bold,600);text-transform:uppercase;font-size:var(--roxy-text-xs,.75rem);letter-spacing:.04em}tbody tr{border-top:1px solid var(--roxy-border,#e4e4e7)}td.body{font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a)}.retro{color:var(--roxy-warning-fg,#9a3412);font-size:var(--roxy-text-xs,.75rem);font-weight:var(--roxy-weight-bold,600);margin-left:4px}.num{font-variant-numeric:tabular-nums}.sig-head{padding:var(--roxy-space-md,1rem) var(--roxy-space-md,1rem) 0;gap:var(--roxy-space-xs,.25rem);display:grid}.sig-title{font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);margin:0}.sig-note{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);margin:0}.legend{gap:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);padding:var(--roxy-space-md,1rem) var(--roxy-space-md,1rem) 0;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);flex-wrap:wrap;margin:0;list-style:none;display:flex}.legend b{color:var(--roxy-accent-ink,#b45309);margin-right:4px}.chain,.empty-cell{color:var(--roxy-muted,#71717a)}`],l([et()],g.prototype,"activeTab",2),g=l([tt("roxy-kp-chart")],g);export{g as RoxyKpChart};
1
+ var q=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var l=(n,r,e,t)=>{for(var o=t>1?void 0:t?G(r,e):r,s=n.length-1,i;s>=0;s--)(i=n[s])&&(o=(t?i(r,e,o):i(o))||o);return t&&o&&q(r,e,o),o};import{css as te,html as a,nothing as c}from"lit";import{customElement as re,state as oe}from"lit/decorators.js";import{html as p,LitElement as J}from"lit";import{property as h,state as x}from"lit/decorators.js";import{ifDefined as k}from"lit/directives/if-defined.js";import{css as O}from"lit";var v=O`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;var S="Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side.";function N(n){return!!n&&!n.startsWith("pk_")}function C(n,r={}){r.warn&&console.warn(S),n.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{reason:"possible-secret-key",message:S},bubbles:!0,composed:!0}))}var B="https://roxyapi.com/api/v2",$=class{constructor(r){this.baseUrl=B;this.host=r,r.addController(this)}hostDisconnected(){this.abort?.abort(),this.abort=void 0}async run(r){if(!this.submitUrl&&this.secretKeyRefused())return;this.abort?.abort();let e=new AbortController;this.abort=e,this.host.loading=!0,this.host.error=null;try{let t=this.submitUrl?await fetch(this.submitUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r),signal:e.signal}):await this.callApi(r,e.signal);if(!t.ok)throw new Error(await this.readError(t));let o=await t.json();if(e.signal.aborted)return;this.host.data=o}catch(t){if(t?.name==="AbortError")return;this.host.error=t instanceof Error?t.message:String(t)}finally{this.abort===e&&(this.abort=void 0),e.signal.aborted||(this.host.loading=!1)}}callApi(r,e){let t=new URL(`${this.baseUrl}${r.path}`);for(let[s,i]of Object.entries(r.query??{}))i!=null&&t.searchParams.set(s,String(i));let o={Accept:"application/json"};return this.publishableKey&&(o["X-API-Key"]=this.publishableKey),r.body!=null&&(o["Content-Type"]="application/json"),fetch(t,{method:r.method??"GET",headers:o,body:r.body!=null?JSON.stringify(r.body):void 0,signal:e})}secretKeyRefused(){return N(this.publishableKey)?(this.host.error=S,C(this.host),!0):!1}async readError(r){try{let e=await r.json();if(e?.error)return e.error}catch{}return`Request failed (${r.status})`}};function E(n,r,e,t=[]){let o={...e},s=`/${n.replace(/^\//,"")}`.replace(/\{([^}]+)\}/g,(f,b)=>{let y=o[b];return delete o[b],encodeURIComponent(String(y??""))}),i=new Set(t),m={},d={};for(let[f,b]of Object.entries(o))b===void 0||b===""||(r==="GET"||i.has(f)?m[f]=b:d[f]=b);return{path:s,method:r,query:m,body:r==="POST"?d:void 0}}var V="roxy-data";function W(n){return n.nodeName==="SCRIPT"&&n.getAttribute("type")==="application/json"}var w=class{constructor(r){this.host=r,r.addController(this)}hostConnected(){if(this.host.data!=null)return;let r=this.read();r!==void 0&&(this.host.data=r,this.host.requestUpdate())}read(){let r=this.findInlineScript();return r?this.parse(r.textContent):void 0}findInlineScript(){for(let r of Array.from(this.host.children))if(W(r)&&r.classList.contains(V))return r;return null}parse(r){if(r?.trim())try{return JSON.parse(r)}catch{return}}};var u=class extends J{constructor(){super();this.data=null;this.endpoint="";this.method="POST";this.remember=!1;this.loading=!1;this.error=null;this.selfFetched=!1;this.editing=!1;this.sticky=!1;this.onEdit=()=>{this.editing=!0};this.onFormSubmit=e=>{let t=e.detail;this.lastValues=t.values,this.sticky=!!t.sticky,this.selfFetched=!0,this.editing=!1,this.remember&&this.writeRemembered(t.values),this.fetcher.run(E(this.endpoint,this.method,t.values,t.queryKeys??[]))};new w(this),this.fetcher=new $(this)}static{this.styles=[v]}willUpdate(e){e.has("publishableKey")&&(this.fetcher.publishableKey=this.publishableKey),e.has("baseUrl")&&this.baseUrl&&(this.fetcher.baseUrl=this.baseUrl),e.has("submitUrl")&&(this.fetcher.submitUrl=this.submitUrl)}render(){return this.loading?this.renderLoading():this.error!=null?this.renderError(this.error):this.data!=null?this.selfFetched?this.editing?this.renderForm():this.renderResult(this.data):this.showAttribution()?p`${this.renderData(this.data)}${this.renderAttribution()}`:this.renderData(this.data):this.renderNoData()}renderResult(e){let t=this.sticky?p`${this.renderForm()}${this.renderData(e)}`:p`<div class="roxy-edit-bar"><button type="button" class="roxy-edit" @click="${this.onEdit}">Edit query</button></div>${this.renderData(e)}`;return this.showAttribution()?p`${t}${this.renderAttribution()}`:t}showAttribution(){return this.attribution!=null&&this.attribution!=="off"&&this.attribution!=="false"}renderAttribution(){return p`<div class="roxy-attribution"><a href="https://roxyapi.com/?utm_source=widget&utm_medium=embed" target="_blank" rel="noopener">Spiritual data by RoxyAPI</a></div>`}renderNoData(){return this.endpoint?this.renderForm():this.renderEmpty()}renderForm(){return p`<roxy-endpoint-form data-endpoint="${this.endpoint}" method="${this.method}" spec-url="${k(this.specUrl)}" publishable-key="${k(this.publishableKey)}" submit-label="${k(this.submitLabel)}" lang="${k(this.effectiveLang())}" .initialValues="${this.formInitialValues()}" @roxy-submit="${this.onFormSubmit}"></roxy-endpoint-form>`}formInitialValues(){return this.lastValues??(this.remember?this.readRemembered():void 0)}effectiveLang(){return this.lang||void 0}rememberKey(){return`roxy-ui:form:${this.endpoint}`}readRemembered(){try{let e=sessionStorage.getItem(this.rememberKey());return e?JSON.parse(e):void 0}catch{return}}writeRemembered(e){try{sessionStorage.setItem(this.rememberKey(),JSON.stringify(e))}catch{}}renderEmpty(){return p`<div class="roxy-empty" role="status">No data</div>`}renderLoading(){return p`<div class="roxy-skeleton" style="height:8rem" role="status" aria-label="Loading"></div>`}renderError(e){let t=p`<div class="roxy-error" role="alert">${e}</div>`;return this.endpoint?p`${t}${this.renderForm()}`:t}};l([h({attribute:!1})],u.prototype,"data",2),l([h({type:String,attribute:"data-endpoint"})],u.prototype,"endpoint",2),l([h({type:String})],u.prototype,"method",2),l([h({type:String,attribute:"publishable-key"})],u.prototype,"publishableKey",2),l([h({type:String,attribute:"base-url"})],u.prototype,"baseUrl",2),l([h({type:String,attribute:"spec-url"})],u.prototype,"specUrl",2),l([h({type:String,attribute:"submit-url"})],u.prototype,"submitUrl",2),l([h({type:Boolean})],u.prototype,"remember",2),l([h({type:String,attribute:"submit-label"})],u.prototype,"submitLabel",2),l([h({type:String})],u.prototype,"attribution",2),l([x()],u.prototype,"loading",2),l([x()],u.prototype,"error",2),l([x()],u.prototype,"selfFetched",2),l([x()],u.prototype,"editing",2),l([x()],u.prototype,"sticky",2);var K=["Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius","Capricorn","Aquarius","Pisces"];function Y(n){let r=n%360;return r<0?r+360:r}function Z(n){let r=Y(n),e=Math.floor(r/30)%12,t=r%30,o=Math.floor(t),s=(t-o)*60,i=Math.floor(s),m=Math.round((s-i)*60);return{sign:K[e]??"Aries",signIndex:e,degree:o,minute:i,second:m}}function T(n){let{sign:r,degree:e,minute:t}=Z(n);return`${e}\xB0 ${r} ${String(t).padStart(2,"0")}'`}function M(n){return n.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([a-z])([0-9])/g,"$1 $2").replace(/^\w/,r=>r.toUpperCase())}function X(n,r=1){if(typeof n!="number"||!Number.isFinite(n))return"";let e=n.toFixed(r);return e.includes(".")?e.replace(/\.?0+$/,""):e}var Q={"kp-newcomb":"KP Newcomb","kp-old":"KP Old",lahiri:"Lahiri"};function U(n,r){let e=typeof n=="string"?Q[n]??M(n):"",t=typeof r=="number"?`${X(r,2)}\xB0`:"";return e&&t?`${e} (${t})`:e||t}function H(n,r){return!r||!n?.length?"":n.map(e=>r[String(e)]?.[0]).filter(Boolean).join(", ")}function R(n,r){return!r||typeof n!="number"?"":(r[String(n)]??[]).join(", ")}import{css as ee,html as A,nothing as I}from"lit";var _=ee`.roxy-tablist{border-bottom:2px solid var(--roxy-border,#e4e4e7);scrollbar-width:thin;gap:2px;min-width:0;display:flex;overflow-x:auto}.roxy-tab{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-sm,.875rem);cursor:pointer;color:var(--roxy-muted,#71717a);transition:color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);background:0 0;border:none;border-bottom:2px solid #0000;flex-shrink:0;margin-bottom:-2px;font-family:inherit}.roxy-tab[aria-selected=true]{color:var(--roxy-accent-ink,#b45309);border-bottom-color:var(--roxy-accent,#f59e0b);font-weight:var(--roxy-weight-bold,600)}.roxy-tab:hover:not([aria-selected=true]){color:var(--roxy-fg,#0a0a0a)}.roxy-tab:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:-2px;border-radius:4px}`;function z(n){let{items:r,active:e,onSelect:t,label:o,idPrefix:s,controls:i=!1}=n;return A`<div class="roxy-tablist" role="tablist" aria-label="${o}" @keydown="${d=>{if(d.key!=="ArrowRight"&&d.key!=="ArrowLeft")return;d.preventDefault();let f=r.findIndex(F=>F.id===e);if(f===-1)return;let b=d.key==="ArrowRight"?1:-1,y=r[(f+b+r.length)%r.length];if(!y)return;t(y.id);let D=d.currentTarget.getRootNode();requestAnimationFrame(()=>{D.querySelector(`#${s}-tab-${y.id}`)?.focus()})}}">${r.map(d=>A`<button type="button" class="roxy-tab" role="tab" id="${s}-tab-${d.id}" aria-selected="${e===d.id?"true":"false"}" aria-controls="${i?`${s}-panel-${d.id}`:I}" tabindex="${e===d.id?"0":"-1"}" @click="${()=>t(d.id)}">${d.label}</button>`)}</div>${i?r.filter(d=>d.id!==e).map(d=>A`<div role="tabpanel" id="${s}-panel-${d.id}" aria-labelledby="${s}-tab-${d.id}" hidden></div>`):I}`}var ne=[{id:"planets",label:"Planets"},{id:"cusps",label:"Cusps"},{id:"significators",label:"Significators"}],L=[1,2,3,4];function P(n,r){return n?typeof r=="number"?`${n} ${r}`:n:""}function j(n){return[...new Set(n.map(String))].join(" > ")}function se(n){return[...new Set(n??[])]}var g=class extends u{constructor(){super(...arguments);this.activeTab="planets"}bodies(){let e=this.data;if(!e)return[];let t=(e.planets??[]).map(s=>({name:s.planet,longitude:s.longitude,house:s.house,nakshatra:s.nakshatra,pada:s.pada,starLord:s.starLord,subLord:s.subLord,subSubLord:s.subSubLord,kpNumber:s.kpNumber,retrograde:s.retrograde})),o=e.nodes;for(let[s,i]of[["Rahu",o?.rahu],["Ketu",o?.ketu]])i&&t.push({name:s,longitude:i.longitude,house:i.house,nakshatra:i.nakshatra,starLord:i.starLord,subLord:i.subLord,subSubLord:i.subSubLord,kpNumber:i.kpNumber,retrograde:!0});return t}renderEmpty(){return a`<div class="roxy-empty" role="status">No KP chart data</div>`}renderData(e){let t=e.ascendant;return a`<div class="wrap" aria-label="KP chart" tabindex="0"><header class="head"><h2 class="title">KP chart</h2>${t?a`<div class="asc">Ascendant: <strong>${typeof t.longitude=="number"?T(t.longitude):t.sign??""} </strong>${t.nakshatra?a`· ${P(t.nakshatra,t.pada)}`:c} ${t.subLord?a`· sub lord ${t.subLord}`:c} ${typeof t.kpNumber=="number"?a`· KP ${t.kpNumber}`:c}</div>`:c} ${typeof e.meta?.ayanamsa=="number"?a`<div class="ayan">Ayanamsa: ${U(e.meta.ayanamsaType,e.meta.ayanamsa)} ${e.meta.houseSystem?a`· ${e.meta.houseSystem} houses`:c}</div>`:c}</header>${z({items:ne,active:this.activeTab,onSelect:o=>{this.activeTab=o},label:"KP chart views",idPrefix:"kp",controls:!0})}<div id="kp-panel-${this.activeTab}" role="tabpanel" aria-labelledby="kp-tab-${this.activeTab}">${this.activeTab==="planets"?this.renderPlanets():this.activeTab==="cusps"?this.renderCusps():this.renderSignificators()}</div></div>`}renderPlanets(){let e=this.bodies();return e.length?a`<table role="table"><caption class="roxy-sr-only">KP planets and nodes: each body with its position, house, nakshatra and pada, star lord, sub lord, sub sub lord and KP number.</caption><thead><tr><th scope="col">Body</th><th scope="col">Position</th><th scope="col">House</th><th scope="col">Nakshatra, pada</th><th scope="col">Star lord</th><th scope="col">Sub lord</th><th scope="col">Sub sub lord</th><th scope="col">KP no.</th></tr></thead><tbody>${e.map(t=>a`<tr><td class="body">${t.name}${t.retrograde?a`<span class="retro">R</span>`:c}</td><td class="num">${typeof t.longitude=="number"?T(t.longitude):""}</td><td class="num">${typeof t.house=="number"?t.house:""}</td><td>${P(t.nakshatra,t.pada)}</td><td>${t.starLord??""}</td><td>${t.subLord??""}</td><td>${t.subSubLord??""}</td><td class="num">${typeof t.kpNumber=="number"?t.kpNumber:""}</td></tr>`)}</tbody></table>`:a`<p class="roxy-empty" role="status">No planets</p>`}renderCusps(){let e=this.data?.cusps??[],t=this.data?.houseThemes;return e.length?a`<table role="table"><caption class="roxy-sr-only">KP Placidus cusps: each house cusp with what it signifies, its position, sign lord, nakshatra and pada, star lord, sub lord, sub sub lord and KP number.</caption><thead><tr><th scope="col">House</th><th scope="col">Position</th><th scope="col">Sign lord</th><th scope="col">Nakshatra, pada</th><th scope="col">Star lord</th><th scope="col">Sub lord</th><th scope="col">Sub sub lord</th><th scope="col">KP no.</th></tr></thead><tbody>${e.map(o=>a`<tr><td class="body num">${o.house}${this.renderThemes(R(o.house,t))}</td><td class="num">${typeof o.longitude=="number"?T(o.longitude):o.sign??""}</td><td>${o.signLord??""}</td><td>${P(o.nakshatra,o.pada)}</td><td>${o.starLord??""}</td><td>${o.subLord??""}</td><td>${o.subSubLord??""}</td><td class="num">${typeof o.kpNumber=="number"?o.kpNumber:""}</td></tr>`)}</tbody></table>`:a`<p class="roxy-empty" role="status">No cusps</p>`}renderSignificators(){let e=this.data?.significators,t=this.data?.houseThemes,o=e?.houseWise??[],s=e?.planetWise??[];return!o.length&&!s.length?a`<p class="roxy-empty" role="status">No significators</p>`:a`${this.renderLevelLegend(o)} ${o.length?a`<div class="sig-head"><h3 class="sig-title">House-wise significators</h3><p class="sig-note">Planets that signify each house, strongest level first.</p></div><table role="table"><caption class="roxy-sr-only">KP house-wise significators: each house, the planets that signify it at levels 1 to 4, and the full strength order.</caption><thead><tr><th scope="col">House</th>${L.map(i=>a`<th scope="col">L${i}</th>`)}<th scope="col">Strength order</th></tr></thead><tbody>${o.map(i=>a`<tr><td class="body num">${i.house}${this.renderThemes(R(i.house,t))}</td>${L.map(m=>this.renderCell(this.planetsAtLevel(i,m).join(", ")))}<td class="chain">${j(i.all??[])}</td></tr>`)}</tbody></table>`:c} ${s.length?a`<div class="sig-head"><h3 class="sig-title">Planet-wise significators</h3><p class="sig-note">Houses each planet signifies, strongest level first.</p></div><table role="table"><caption class="roxy-sr-only">KP planet-wise significators: each planet, the houses it signifies at levels 1 to 4, and the full strength order.</caption><thead><tr><th scope="col">Planet</th>${L.map(i=>a`<th scope="col">L${i}</th>`)}<th scope="col">Strength order</th></tr></thead><tbody>${s.map(i=>a`<tr><td class="body">${i.planet}</td>${L.map(m=>this.renderCell(this.housesAtLevel(i,m).join(", ")))}<td class="chain">${j(i.allHouses??[])}${this.renderThemes(H(se(i.allHouses),t))}</td></tr>`)}</tbody></table>`:c}`}renderThemes(e){return e?a`<span class="themes">${e}</span>`:c}renderCell(e){return e?a`<td>${e}</td>`:a`<td class="empty-cell">none</td>`}planetsAtLevel(e,t){return(e.significators??[]).filter(o=>o.level===t).flatMap(o=>o.planets??[])}housesAtLevel(e,t){return(e.signifies??[]).filter(o=>o.level===t).flatMap(o=>o.houses??[])}renderLevelLegend(e){let t=new Map;for(let o of e)for(let s of o.significators??[])s.description&&!t.has(s.level)&&t.set(s.level,s.description);return t.size===0?c:a`<ul class="legend" aria-label="Significator levels">${[...t.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>a`<li><b>L${o}</b>${s}</li>`)}</ul>`}};g.styles=[v,_,te`.wrap{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);background:var(--roxy-surface,#fff);box-shadow:var(--roxy-shadow-sm);width:100%;overflow:auto}.head{padding:var(--roxy-space-md,1rem);border-bottom:1px solid var(--roxy-border,#e4e4e7);gap:var(--roxy-space-xs,.25rem);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.asc,.ayan{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-sm,.875rem)}.asc strong{color:var(--roxy-fg,#0a0a0a)}.roxy-tablist{padding:0 var(--roxy-space-md,1rem)}table{border-collapse:collapse;width:100%;font-size:var(--roxy-text-sm,.875rem);min-width:620px}thead{background:color-mix(in srgb, var(--roxy-border,#e4e4e7) 20%, transparent)}th,td{padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);text-align:left;white-space:nowrap}th{color:var(--roxy-muted,#71717a);font-weight:var(--roxy-weight-bold,600);text-transform:uppercase;font-size:var(--roxy-text-xs,.75rem);letter-spacing:.04em}tbody tr{border-top:1px solid var(--roxy-border,#e4e4e7)}td.body{font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a)}.retro{color:var(--roxy-warning-fg,#9a3412);font-size:var(--roxy-text-xs,.75rem);font-weight:var(--roxy-weight-bold,600);margin-left:4px}.num{font-variant-numeric:tabular-nums}.sig-head{padding:var(--roxy-space-md,1rem) var(--roxy-space-md,1rem) 0;gap:var(--roxy-space-xs,.25rem);display:grid}.sig-title{font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);margin:0}.sig-note{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);margin:0}.legend{gap:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);padding:var(--roxy-space-md,1rem) var(--roxy-space-md,1rem) 0;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);flex-wrap:wrap;margin:0;list-style:none;display:flex}.legend b{color:var(--roxy-accent-ink,#b45309);margin-right:4px}.chain,.empty-cell{color:var(--roxy-muted,#71717a)}.themes{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);font-weight:var(--roxy-weight-normal,400);text-transform:none;letter-spacing:normal;display:block}`],l([oe()],g.prototype,"activeTab",2),g=l([re("roxy-kp-chart")],g);export{g as RoxyKpChart};
2
2
  //# sourceMappingURL=kp-chart.js.map