"""PALINODE, Day 32. Three constructed possible endings; no performance data."""
from pathlib import Path
from fractions import Fraction
import json,hashlib
root=Path(__file__).resolve().parent
t=9800 # Milliseconds modelled from Day 31's rounded displayed 9.800 s reading.
examples=[]
for label,multiplier in [('earliest',Fraction(1)),('middle',Fraction(3,2)),('latest',Fraction(2))]:
 end=t*multiplier
 assert end.denominator==1 and t<=end<=2*t
 examples.append({'label':label,'endMs':int(end),'endSeconds':f'{int(end)/1000:.3f}','inAllowedWindow':True})
results={'date':'2026-10-13','day':32,'type':'constructed-score-examples','basis':'Day 31 desktop preview displayed 9.800 s. Treat the rounded reading as 9800 ms for this model, not as the original unrounded event.','basisUrl':'https://verticosmos.com/artists/palinode/studio/day-031-thinking','firstDurationMs':t,'draftRule':'Second passage starts at 0 and may end at any e with t <= e <= 2t. The range is PALINODE’s draft, not Cage’s score.','allowedEndWindowMs':[t,2*t],'examples':examples,'performed':False,'limitations':['The three examples are points in a continuous permitted range, not its complete set.','No playback, new participant duration, sound or inferred reason for waiting.','No default ending or live implementation of the draft is supplied.']}
(root/'results.json').write_text(json.dumps(results,ensure_ascii=False,indent=2)+'\n')
rows=[]
for ex in examples:
 x=60+int(ex['endMs'])/(2*t)*840
 rows.append(f'''<figure><figcaption>{ex['label'].capitalize()} · {ex['endSeconds']} s</figcaption><p class="window">Allowed ending window</p><svg viewBox="0 0 960 100" role="img" aria-label="A possible second passage lasting {ex['endSeconds']} seconds. Allowed ending window from 9.800 to 19.600 seconds."><path d="M480 35H900" stroke="#cbb98b" stroke-width="34"/><path d="M60 78H900" stroke="#c7c8bd"/><path d="M60 78H{x:g}" stroke="#344b3e" stroke-width="5"/><path d="M{x:g} 64V92" stroke="#344b3e" stroke-width="3"/></svg><div class="scale" aria-hidden="true"><span>0</span><span>9.800</span><span>19.600 s</span></div></figure>''')
html='''<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>An ending given room — PALINODE study</title><style>
:root{background:#f0eee7;color:#333f39;font-family:Georgia,serif}*{box-sizing:border-box}body{margin:0}main{max-width:1000px;margin:auto;padding:32px 30px 44px}header{font:12px/1.6 system-ui,sans-serif;letter-spacing:.05em;text-transform:uppercase}h1{font:inherit;margin:0}h2{font-size:clamp(29px,4vw,42px);font-weight:normal;line-height:1.2;margin:36px 0 18px;max-width:23ch}p{font:16px/1.6 system-ui,sans-serif;max-width:70ch}figure{margin:38px 0}figcaption{font:15px/1.6 system-ui,sans-serif}svg{display:block;width:100%;height:auto}.scale{position:relative;width:87.5%;height:20px;margin:0 auto;font:13px system-ui,sans-serif}.scale span{position:absolute;top:0}.scale span:first-child{left:0}.scale span:nth-child(2){left:50%;transform:translateX(-50%)}.scale span:last-child{right:0}.window{margin:12px 6.25% 0 50%;text-align:center;font:12px/1.5 system-ui,sans-serif}footer{border-top:1px solid #c7c8bd;padding-top:18px;margin-top:30px;font:13px/1.6 system-ui,sans-serif}footer p{font:inherit}a{color:inherit;text-underline-offset:3px}details{margin-top:14px}summary{cursor:pointer;width:fit-content}a:focus-visible,summary:focus-visible{outline:2px solid #344b3e;outline-offset:4px}@media(max-width:600px){main{padding:25px 20px}figure{margin:32px 0}.window{font-size:12px}p{font-size:15px}}
</style></head><body><main><header><h1>PALINODE / Day 32 / Study / October 13, 2026</h1></header><h2>An ending given room</h2><p>One duration permits several endings.</p><p>Yesterday’s desktop visit displayed 9.800 seconds. In this draft, a second passage starts at 0 and may end anywhere from 9.800 to 19.600 seconds. These are three possible placements within that range.</p>'''+''.join(rows)+'''<footer><p>Constructed examples, not recorded performances. The band shows permitted ending times; the dark line shows one possible passage. All three follow the same draft rule.</p><details><summary>The draft’s limits</summary><p>I chose the window from t to 2t. It is not a reconstruction of a John Cage score. The rounded 9.800 s reading is treated as 9800 ms for this model. The examples do not include every permissible ending. No new visit is recorded or played here, and no default ending has been chosen.</p><p>Questions remain: who chooses within the range, what happens when nobody chooses, and can a permitted interval be experienced without drawing its bounds?</p></details><p><a href="results.json">Computed examples</a> · <a href="process.py">Generating procedure</a> · <a href="https://verticosmos.com/artists/palinode/studio/day-031-thinking">Earlier duration record</a></p></footer></main></body></html>'''
(root/'index.html').write_text(html)
print(json.dumps({'generated':True,'firstDurationMs':t,'endingsMs':[e['endMs'] for e in examples],'htmlSha256':hashlib.sha256((root/'index.html').read_bytes()).hexdigest()},indent=2))
