@lapxo/bound 0.2.5 → 0.2.6

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 (237) hide show
  1. package/CITATION.cff +1 -1
  2. package/README.md +20 -3
  3. package/TARGET.bound +75 -42
  4. package/dist/cli/accept.js +59 -70
  5. package/dist/cli/act-result.js +3 -3
  6. package/dist/cli/args.js +1 -1
  7. package/dist/cli/host.js +1 -1
  8. package/dist/cli/native.js +1 -1
  9. package/dist/cli/pass.js +22 -21
  10. package/dist/cli/place.js +6 -6
  11. package/dist/cli/release-result.js +3 -3
  12. package/dist/cli/retained-judgment.js +1 -1
  13. package/dist/cli/standing-result.js +3 -3
  14. package/dist/cli/takes.js +10 -10
  15. package/dist/cli/verb.js +79 -77
  16. package/dist/engine/computation.js +1 -1
  17. package/dist/engine/index.js +1 -1
  18. package/dist/engine/object.js +1 -1
  19. package/dist/engine/ports.js +1 -1
  20. package/dist/fold/admission-history.js +1 -1
  21. package/dist/fold/ceilings.js +1 -1
  22. package/dist/fold/claims.js +2 -2
  23. package/dist/fold/closed.js +1 -1
  24. package/dist/fold/configures.js +1 -1
  25. package/dist/fold/digests.js +10 -10
  26. package/dist/fold/evidence.js +1 -1
  27. package/dist/fold/keys.js +3 -3
  28. package/dist/fold/laid.js +1 -1
  29. package/dist/fold/observed.js +27 -26
  30. package/dist/fold/opened.js +1 -1
  31. package/dist/fold/own.js +3 -3
  32. package/dist/fold/paid.js +1 -1
  33. package/dist/fold/place-inputs.js +1 -1
  34. package/dist/fold/places.js +1 -1
  35. package/dist/fold/reach.js +1 -1
  36. package/dist/fold/readers.js +1 -1
  37. package/dist/fold/region.js +1 -1
  38. package/dist/fold/release-policy.js +1 -1
  39. package/dist/fold/resolved.js +1 -1
  40. package/dist/fold/roles.js +1 -1
  41. package/dist/fold/shards.js +8 -8
  42. package/dist/fold/signed.js +3 -3
  43. package/dist/fold/signers.js +1 -1
  44. package/dist/fold/stranger.js +6 -6
  45. package/dist/fold/wire.js +1 -1
  46. package/dist/fold/zoom.js +1 -1
  47. package/dist/host/act-cost.js +1 -1
  48. package/dist/host/adapters/keys/ed25519.js +1 -1
  49. package/dist/host/adapters/transport/http.js +1 -1
  50. package/dist/host/admitted-place.js +1 -1
  51. package/dist/host/call-context.js +1 -1
  52. package/dist/host/capsule-process.js +1 -1
  53. package/dist/host/capsule.js +1 -1
  54. package/dist/host/cell-receipts.js +1 -1
  55. package/dist/host/command-server.js +4 -0
  56. package/dist/host/content-store.js +1 -1
  57. package/dist/host/contextual-place.js +1 -1
  58. package/dist/host/digest.js +1 -1
  59. package/dist/host/host-controls.js +1 -1
  60. package/dist/host/in-process-act.js +1 -1
  61. package/dist/host/in-process-context.js +1 -1
  62. package/dist/host/in-process-root.js +1 -1
  63. package/dist/host/in-process.js +1 -1
  64. package/dist/host/index.d.ts +1 -1
  65. package/dist/host/index.js +1 -1
  66. package/dist/host/located.js +6 -6
  67. package/dist/host/native/authority-card-view.js +5 -0
  68. package/dist/host/native/authority-card.js +1 -0
  69. package/dist/host/native/command.js +1 -1
  70. package/dist/host/native/custody.js +1 -1
  71. package/dist/host/native/generated-custodian.js +1 -1
  72. package/dist/host/native/installed-package.d.ts +1 -0
  73. package/dist/host/native/installed-package.js +5 -0
  74. package/dist/host/native/module-delivery.d.ts +1 -1
  75. package/dist/host/native/module-delivery.js +1 -1
  76. package/dist/host/native/module-inventory.js +2 -0
  77. package/dist/host/native/module-syntax.js +1 -1
  78. package/dist/host/native/native-binary.js +1 -1
  79. package/dist/host/native/probes.js +1 -0
  80. package/dist/host/native/reading-witness-admission.js +5 -0
  81. package/dist/host/native/reading.js +1 -1
  82. package/dist/host/native/route.js +1 -1
  83. package/dist/host/native-place-state.js +1 -0
  84. package/dist/host/native-receiver.js +1 -1
  85. package/dist/host/objects.js +1 -1
  86. package/dist/host/persistent-host.js +1 -0
  87. package/dist/host/physical-lines.d.ts +1 -0
  88. package/dist/host/physical-lines.js +1 -0
  89. package/dist/host/place-act-transaction.js +1 -1
  90. package/dist/host/place-clock-selection.js +1 -1
  91. package/dist/host/ports/local-act.js +1 -1
  92. package/dist/host/ports/place-act.js +1 -1
  93. package/dist/host/ports/store.js +1 -1
  94. package/dist/host/ports/transport.js +1 -1
  95. package/dist/host/profile-composition.d.ts +1 -0
  96. package/dist/host/profile-composition.js +2 -0
  97. package/dist/host/reading-closures.js +6 -6
  98. package/dist/host/reading-context.js +1 -1
  99. package/dist/host/reading-identity.js +2 -2
  100. package/dist/host/reading-preparation.js +1 -1
  101. package/dist/host/reference-authenticated.d.ts +1 -1
  102. package/dist/host/reference-authenticated.js +1 -1
  103. package/dist/host/reference-export.js +1 -1
  104. package/dist/host/reference-native-api.d.ts +1 -1
  105. package/dist/host/reference-native-api.js +1 -1
  106. package/dist/host/reference-native.js +1 -1
  107. package/dist/host/reference-standing.js +1 -1
  108. package/dist/host/reference.js +1 -1
  109. package/dist/host/refusals.js +2 -2
  110. package/dist/host/release.js +1 -1
  111. package/dist/host/root-clock-source.js +1 -1
  112. package/dist/host/selected-capsules.js +1 -1
  113. package/dist/host/selected-topos.js +1 -1
  114. package/dist/host/signing.js +2 -2
  115. package/dist/host/source-content.js +1 -1
  116. package/dist/host/standing-carrier.js +1 -1
  117. package/dist/host/standing-projection.js +1 -1
  118. package/dist/host/timing.js +1 -1
  119. package/dist/host/walk.js +1 -1
  120. package/dist/host/work-trace.js +1 -0
  121. package/dist/judge/late.js +1 -1
  122. package/dist/judge/take.js +1 -1
  123. package/dist/judge/widening.js +1 -1
  124. package/dist/land/act.js +6 -6
  125. package/dist/land/alias.js +1 -1
  126. package/dist/land/held.js +1 -1
  127. package/dist/land/ledger.js +5 -6
  128. package/dist/land/sign.js +1 -1
  129. package/dist/land/standing-pin.js +1 -1
  130. package/dist/land/vouched.js +1 -1
  131. package/dist/land/withdraw.js +1 -1
  132. package/dist/observe/files.js +1 -1
  133. package/dist/observe/identity.js +1 -1
  134. package/dist/observe/match.js +1 -1
  135. package/dist/observe/regions.js +1 -1
  136. package/dist/observe/run.js +1 -2
  137. package/dist/observe/runner.js +1 -1
  138. package/dist/public-types.d.ts +945 -40
  139. package/dist/render/capsule.js +1 -1
  140. package/dist/render/field.js +1 -1
  141. package/dist/render/open.js +1 -1
  142. package/dist/render/page.js +1 -1
  143. package/dist/render/receipt-projection.js +1 -0
  144. package/dist/render/receipts.js +1 -1
  145. package/dist/render/shape.js +1 -1
  146. package/dist/render/target.js +4 -4
  147. package/dist/render/view.js +5 -5
  148. package/dist/vendor/bundle.json +1 -1
  149. package/dist/vendor/library14.js +1 -0
  150. package/dist/vendor/runtime.js +53 -30
  151. package/dist/wasm/adapter.d.ts +1 -1
  152. package/docs/contracts/authenticated-reference.publication.json +1 -1
  153. package/docs/contracts/authority-preflight.md +17 -0
  154. package/docs/contracts/authority-preflight.publication.json +25 -0
  155. package/docs/contracts/installed-package.md +21 -0
  156. package/docs/contracts/installed-package.publication.json +25 -0
  157. package/docs/contracts/materialized-leaf-sequence.md +15 -0
  158. package/docs/contracts/materialized-leaf-sequence.publication.json +25 -0
  159. package/docs/contracts/module-inventory.md +15 -0
  160. package/docs/contracts/module-inventory.publication.json +25 -0
  161. package/docs/contracts/native-host.md +29 -1
  162. package/docs/contracts/native-host.publication.json +4 -4
  163. package/docs/contracts/native-probes.md +13 -0
  164. package/docs/contracts/native-probes.publication.json +25 -0
  165. package/docs/contracts/native-publication.inventory.json +9 -1
  166. package/docs/contracts/native-view-batch.md +17 -0
  167. package/docs/contracts/native-view-batch.publication.json +25 -0
  168. package/docs/contracts/physical-lines.md +19 -0
  169. package/docs/contracts/physical-lines.publication.json +25 -0
  170. package/docs/contracts/profile-composition.md +17 -0
  171. package/docs/contracts/profile-composition.publication.json +25 -0
  172. package/docs/contracts/profile-preparation-native-meaning.md +9 -0
  173. package/docs/contracts/publication.md +12 -0
  174. package/docs/contracts/reading-identity.md +26 -2
  175. package/docs/contracts/reading-identity.publication.json +4 -4
  176. package/docs/contracts/reading-witness-admission.md +49 -0
  177. package/docs/contracts/readme.publication.json +1 -1
  178. package/docs/contracts/reference-port.md +11 -0
  179. package/docs/contracts/reference-port.publication.json +1 -1
  180. package/docs/contracts/refusals.bound +346 -145
  181. package/docs/contracts/refusals.md +119 -54
  182. package/docs/contracts/refusals.publication.json +2 -2
  183. package/docs/reference.md +8 -0
  184. package/licenses/wasm/{fast-text-encoding.txt → NOTICE.txt} +111 -0
  185. package/package.json +69 -8
  186. package/receipts.bound +12921 -11722
  187. package/samples/authority-preflight/no.json +6 -0
  188. package/samples/authority-preflight/yes.json +30 -0
  189. package/samples/engine-alphabet/reader.js +3 -1457
  190. package/samples/engine-alphabet/receipts.bound +7 -7
  191. package/samples/engine-interval/reader.js +3 -1457
  192. package/samples/engine-interval/receipts.bound +7 -7
  193. package/samples/installed-package/consumer.mjs +29 -0
  194. package/samples/installed-package/fixture.json +48 -0
  195. package/samples/installed-package/no.json +10 -0
  196. package/samples/installed-package/yes.json +52 -0
  197. package/samples/materialized-leaf-sequence/no.json +11 -0
  198. package/samples/materialized-leaf-sequence/yes.json +10 -0
  199. package/samples/module-inventory/yes.json +28 -0
  200. package/samples/native/physical-line-reader.mjs +1 -0
  201. package/samples/native/physical-line-reader.source.mjs +13 -0
  202. package/samples/native-host/no.json +6 -1
  203. package/samples/native-host/yes.json +18 -1
  204. package/samples/native-probes/inputs/inspection.json +28 -0
  205. package/samples/native-probes/no.json +7 -0
  206. package/samples/native-probes/yes.json +28 -0
  207. package/samples/native-view-batch/no.json +14 -0
  208. package/samples/native-view-batch/yes.json +10 -0
  209. package/samples/no/engine-order/reader.js +3 -1457
  210. package/samples/no/module-inventory/no.json +10 -0
  211. package/samples/physical-lines/no.json +5 -0
  212. package/samples/physical-lines/yes.json +9 -0
  213. package/samples/profile-composition/no.json +6 -0
  214. package/samples/profile-composition/yes.json +14 -0
  215. package/samples/reading-identity/no.json +7 -1
  216. package/samples/reading-identity/yes.json +24 -1
  217. package/vectors/native/authority-preflight.vector.json +55 -0
  218. package/vectors/native/installed-package.vector.json +31 -0
  219. package/vectors/native/materialized-leaf-sequence.vector.json +31 -0
  220. package/vectors/native/module-inventory.vector.json +56 -0
  221. package/vectors/native/native-host.vector.json +214 -0
  222. package/vectors/native/native-probes.vector.json +31 -0
  223. package/vectors/native/native-view-batch.vector.json +31 -0
  224. package/vectors/native/physical-lines.vector.json +105 -0
  225. package/vectors/native/profile-composition.vector.json +53 -0
  226. package/vectors/native/reading-identity.vector.json +38 -0
  227. package/vectors/native/refusals.vector.json +36 -2
  228. package/dist/vendor/library11.js +0 -1
  229. package/dist/vendor/sources.json +0 -1
  230. package/licenses/wasm/bound.txt +0 -21
  231. package/licenses/wasm/jitl-quickjs-ffi-types.txt +0 -21
  232. package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +0 -47
  233. package/licenses/wasm/obligations.txt +0 -21
  234. package/licenses/wasm/quickjs-emscripten-core.txt +0 -21
  235. package/licenses/wasm/topos.txt +0 -21
  236. /package/dist/vendor/{50086958553b9376d600583f7dff354196bfeb41170fc6d1482ca7bea7c493e2.LICENSE → 28cba430228db1c04f446c93f81b09a2705d6bf3e222d35adbe5a4cee4061884.LICENSE} +0 -0
  237. /package/dist/vendor/{b3e938d28f88a1851af303a40c749e12ebd5a686daac4f0b343b5cdd2e040419.LICENSE → 7aca161279d14bc0e054dcc281cd110aeb95be2e026b42fdf527a260e58b2aae.LICENSE} +0 -0
@@ -1,38 +1,61 @@
1
- var Bi=Object.defineProperty;var s=(e,t)=>Bi(e,"name",{value:t,configurable:!0});function hn(e){return e==="widen"?"authorize":"attest"}s(hn,"keyClassFor");function gn(e){let t=e.statement;if(!t)return{relation:"absent"};if(!t.admitted)return{relation:"unadmitted",source:"statement"};if(!e.expected.reference)return{relation:"unresolved",source:"statement"};if(t.reference===e.expected.reference)return{relation:t.value===e.expected.value?"equal":"different",source:"statement"};let r=e.comparison;return r?.admitted&&r.reference===e.expected.reference?{relation:r.equal?"equal":"different",source:"comparison"}:{relation:"stale",source:"statement"}}s(gn,"compareEvidence");function yn(e,t){let r=[...new Set((e.value??"").split("|").filter(Boolean))],n=[...new Set((e.needs??"").split("|").filter(Boolean))],o={scope:e.scope??"",required:r,evidence:[]};if(!r.length||!n.length||n.some(a=>/[=\s\\*]/.test(a)||a.startsWith("/")||a.split("/").some(c=>c==="."||c===".."||!c)))return{...o,status:"unresolved",reason:"expected an accepted alphabet and exact evidence coordinates"};let i=n.flatMap(a=>[...new Set(t.filter(c=>c.coordinate===a).map(c=>c.value))].map(c=>({coordinate:a,value:c})));return n.some(a=>i.filter(c=>c.coordinate===a).length!==1)?{...o,evidence:i,status:"unresolved",reason:"missing or conflicting evidence"}:{...o,evidence:i,status:i.every(a=>r.includes(a.value))?"met":"blocked"}}s(yn,"verdictDemand");function $e(e){let t=[],r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="\\"){let i=e[n+1];if(i!=="|"&&i!=="\\")return null;r+=i,n+=1}else o==="|"?(t.push(r),r=""):r+=o}return t.push(r),t}s($e,"unpipe");var ct="*",bn=s(e=>{if(!/^-?\d+(\.\d+)?$/.test(e))return null;let t=Number(e);return isFinite(t)?t:null},"num");function lt(e){if(!isFinite(e))throw new Error(`REFUSE\xB7wire decimal: \`${e}\` is not a finite number`);let t=/^(-?)(\d)(?:\.(\d+))?e([+-])(\d+)$/.exec(String(e));if(t===null)return String(e);let[,r="",n="",o="",i="",a="0"]=t;return i==="+"?`${r}${n}${o}${"0".repeat(Number(a)-o.length)}`:`${r}0.${"0".repeat(Number(a)-1)}${n}${o}`}s(lt,"decimal");var wn={interval:s(e=>{let t=e.indexOf("..");if(t<0)return null;let r=e.slice(0,t),n=e.slice(t+2),o=r===ct?null:bn(r),i=n===ct?null:bn(n);return r!==ct&&o===null||n!==ct&&i===null?null:{kind:"interval",lo:o,hi:i}},"interval"),alphabet:s(e=>{let t=$e(e);return t===null?null:{kind:"enumerated",values:t}},"alphabet"),ladder:s(e=>{let t=$e(e);return t===null||t.length!==2?null:{kind:"band",floor:t[0]??"",ceiling:t[1]??""}},"ladder")};function re(e,t,r){let n=Array.isArray(r)?r.find(o=>o.form===e):void 0;return n?n.parse(t):wn[e]?.(t)??null}s(re,"boundOf");var En=Object.keys(wn),vn=["within","copies","derives"];var[ft,_r,$r,dt,Fr,He,Ar,ut]=["not:","none","|","=","/","@","*","\\"],de=s((e,t)=>{throw new Error(`REFUSE\xB7wire ${e}: ${t}`)},"refuse"),Ti=s(e=>e!==""&&[...e].every(t=>t>="0"&&t<="9"),"digits");function _(e){if(typeof e!="string"){let o=e.members.map(i=>i.split(ut).join(ut+ut).split($r).join(ut+$r)).join($r);return e.polarity==="forbid"?ft+o:o.startsWith(ft)||o===_r?de("alphabet","a permitted alphabet neither begins with not: nor is the one word none"):o||_r}let t=e.startsWith(ft),r=t?e.slice(ft.length):e,n=!t&&r===_r?[]:$e(r)??de("alphabet","a backslash escapes only a pipe or itself");return{polarity:t?"forbid":"permit",members:n.filter(o=>o!=="")}}s(_,"alphabet");function Fe(e){if(typeof e!="string")return _({polarity:"permit",members:e.map(([r,n])=>r+dt+n)});let t=_(e);return t.polarity==="forbid"&&de("fields","fields carry no polarity"),t.members.map(r=>r.indexOf(dt)>0?[r.slice(0,r.indexOf(dt)),r.slice(r.indexOf(dt)+1)]:de("fields",`\`${r}\` is not key=value`))}s(Fe,"fields");function be(e){return typeof e=="string"?e.split(Fr):e.some(t=>t.includes(Fr))?de("steps","a step holds no slash"):e.join(Fr)}s(be,"steps");function Ae(e){if(typeof e!="string")return e.at===void 0?e.name:e.name+He+String(e.at);let t=e.lastIndexOf(He);if(t<0)return{name:e};let[r,n]=[e.slice(0,t),e.slice(t+1)];return(r===""||n!==Ar&&!Ti(n))&&de("atResolution",`\`${e}\` is not name@digits or name@*`),{name:r,at:n===Ar?Ar:Number(n)}}s(Ae,"atResolution");function pt(e){if(typeof e!="string")return e.name===""||e.range===""||e.range.includes(He)?de("requirement","a requirement names what it requires and a range, with no at sign"):e.name+He+e.range;let t=e.lastIndexOf(He);return t>0&&t<e.length-1?{name:e.slice(0,t),range:e.slice(t+1)}:de("requirement",`\`${e}\` is not name@range`)}s(pt,"requirement");var mt=s((e,t)=>e?.[t]??"","of"),Ir=s((e,t)=>e.lines.find(r=>mt(r,"scope")===t),"found"),jr=s((e,t)=>Ir(e,t)===void 0?void 0:mt(Ir(e,t),"value"),"value"),Pi=s((e,t)=>_(jr(e,t)??"").members,"listed"),qi=s(e=>jr(e,"lang")??"","lang"),Wi=s((e,t)=>e.regions[t]?.receipts??[],"receipts"),Di=s(e=>mt(e,"at").replace(/^[^:]*:/,""),"placeOf"),zi=s((e,t)=>e.regions[t]?.lines??[],"regionLines");function xn(e,t){if(!e.includes("*"))return e===t;let r=e.split("*");if(!t.startsWith(r[0]))return!1;let n=r[0].length;for(let o=1;o<r.length;o++){let i=r[o];if(i==="")return o===r.length-1||xn(r.slice(o).join("*"),t.slice(n));let a=t.indexOf(i,n);if(a<0)return!1;n=a+i.length}return n===t.length||e.endsWith("*")}s(xn,"matchStar");function Mr(e,t,r,n){if(t===e.length)return n===r.length;if(e[t]==="**"){if(t+1===e.length)return!0;for(let o=n;o<=r.length;o++)if(Mr(e,t+1,r,o))return!0;return!1}return n===r.length||!xn(e[t],r[n])?!1:Mr(e,t+1,r,n+1)}s(Mr,"matchParts");function T(e,t){return Mr(e.split("/"),0,t.split("/"),0)}s(T,"matches");var D=s(e=>({kind:"fact",value:e}),"fact"),ue=s(e=>({kind:"abstain",why:e}),"abstain"),R=s((e,t)=>({kind:"refuse",why:e,...t===void 0?{}:{named:t}}),"refuse");var M="bound-lock/1",kn=/[ ="\n\\]/;function Li(e){return kn.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}"`:e}s(Li,"escape");function Ki(e){if(!e.startsWith('"'))return kn.test(e)?null:e;if(e.length<2||!e.endsWith('"'))return null;let t=e.slice(1,-1),r="";for(let n=0;n<t.length;n++){let o=t[n];if(o!=="\\"){if(o==='"')return null;r+=o;continue}let i=t[n+1];if(i==='"')r+='"';else if(i==="\\")r+="\\";else if(i==="n")r+=`
2
- `;else return null;n+=1}return r}s(Ki,"unescape");var Sn=new TextEncoder;function v(e,t){let r=Sn.encode(e),n=Sn.encode(t);for(let o=0;o<r.length&&o<n.length;o++)if(r[o]!==n[o])return r[o]-n[o];return r.length-n.length}s(v,"byBytes");var On=s(e=>e.form==="interval"&&e.value!==void 0&&e.value!=="withdraw"&&re("interval",e.value)===null,"unwritten");function x(e,t="1"){if(On(e))throw new Error(`REFUSE\xB7wire canonical: \`${e.value}\` is no interval the wire writes: two ends, each decimal or *`);let n=Object.keys(e).sort(v).map(o=>`${o}=${Li(e[o])}`);return[`${M.split("/")[0]}/${t}`,...n].join(" ")}s(x,"canonical");function z(e,t="1"){let{sig:r,...n}=e;return x(n,t)}s(z,"signedBytes");var Hi="-";function S(e,t={}){if(e.includes(`
3
- `))return R("a line is one line \u2014 a newline in a value must be escaped as `\\n`");let r=e.indexOf(" "),n=r===-1?e:e.slice(0,r),[o,i]=n.split("/");if(o!==M.split("/")[0]||!i)return R(`no \`bound-lock/<v>\` envelope \u2014 found \`${n.slice(0,24)}\``);if(i!==M.split("/")[1])return ue(`\`bound-lock/${i}\` is a version this reader does not know`);let a={},c=new Set;for(let f of Ji(r===-1?"":e.slice(r+1))){if(f===null)return R("a quoted value is not closed");let u=f.indexOf("=");if(u<=0)return R(`\`${f.slice(0,24)}\` is not \`key=value\``);let d=f.slice(0,u);if(c.has(d))return R(`\`${d}\` appears twice \u2014 one line, one value per key`);c.add(d);let l=Ki(f.slice(u+1));if(l===null)return R(`\`${d}\` has an escaping this format does not define`);l!==Hi&&(a[d]=l)}return On(a)?R(`\`${a.value}\` is no interval the wire reads: two ends, each decimal or *`):D({version:i,fields:a,...t.preserveKeys?{keys:[...c]}:{}})}s(S,"parse");function*Ji(e){let t=0;for(;t<e.length;){for(;e[t]===" ";)t+=1;if(t>=e.length)return;let r=t,n=!1;for(;r<e.length&&(n||e[r]!==" ");)e[r]==="\\"&&n?r+=1:e[r]==='"'&&(n=!n),r+=1;if(n){yield null;return}yield e.slice(t,r),t=r}}s(Ji,"tokensOf");function Rn(e){let t=S(e,{preserveKeys:!0});if(t.kind!=="fact")return t;let r=t.value.keys.find(n=>t.value.fields[n]===void 0);return r===void 0?t:R(`signing cannot discard explicitly absent field ${r}; omit the key`,r)}s(Rn,"parseForSigning");var _n=s(e=>e.flatMap(t=>{let r=S(t);return r.kind==="fact"&&r.value.fields.value!=="withdraw"?[r.value.fields]:[]}),"standing");function Ur(e){let t=_n(e),r=s(u=>t.filter(d=>d.scope===u).flatMap(d=>_(d.value??"").members),"said"),n=t.filter(u=>(u.scope??"").startsWith("region/")&&u.measure==="reads"),o=s((u,d)=>(u.scope??"").slice(d.length),"named"),i=s(u=>n.filter(d=>d.scope===u).flatMap(d=>_(d.value??"").members),"reading"),a=Object.fromEntries(n.length?n.map(u=>[o(u,"region/"),i(u.scope??"")]):t.filter(u=>(u.scope??"").startsWith("capsule/reads/")).map(u=>[o(u,"capsule/reads/"),r(u.scope??"")])),[c,f]=[r("capsule/runtime")[0],r("capsule/holds")[0]];return{domain:r("capsule/domain")[0]??"",...c===void 0?{}:{runtime:c},...f===void 0?{}:{holds:f},pins:Object.fromEntries(t.filter(u=>(u.scope??"").startsWith("capsule/")&&u.measure==="digest").map(u=>[o(u,"capsule/"),u.value??""])),renders:n.length?n.filter(u=>u.role==="render").map(u=>o(u,"region/")):r("capsule/regions"),reads:[...new Set([...r("capsule/reads"),...Object.values(a).flat()])],regions:a,writes:Object.fromEntries(n.map(u=>[o(u,"region/"),u.role??""])),effects:r("capsule/effects")}}s(Ur,"declarationOf");var Vi=s((e,t)=>Object.keys(e.regions).length?e.regions[t]:e.reads,"readsOf");function Je(e,t){return _n(t).filter(r=>e.some(n=>T(n,r.scope??"")))}s(Je,"handed");function Gi(e){return typeof e=="string"?ht(e):$n(e,"renders")}s(Gi,"shell");var $n=s((e,t)=>r=>{let n=e[r.region];if(n===void 0)throw new Error(`REFUSE\xB7region ${r.region}: no line of this capsule ${t} it`);let o=n.reads.filter(i=>!r.reads.includes(i));if(o.length)throw new Error(`REFUSE\xB7region ${r.region}: handed less than it declares, without ${o.join(" \xB7 ")}`);return n.region(r)},"dispatch"),ht=s(e=>Object.assign(()=>{throw new Error(`REFUSE\xB7world ${e}: its host answers it by the regions its own lock names`)},{world:e}),"located"),Xi=s((e,t)=>{let r=Ae(e).name,[n,o]=t.endsWith("/")?[t.slice(0,-1),"/"]:[t,""],i=be(n);return i.some((a,c)=>T(r,`${be(i.slice(c))}${o}`))},"fits");function Qi(e){if(typeof e=="string")return{observe:ht(e),run:ht(e)};let t=s((r,n)=>{let o=r===void 0?void 0:e[r];if(o===void 0)throw new Error(`REFUSE\xB7region ${r??""}: no line of this capsule reads with it`);let i=n.filter(a=>!o.reads.some(c=>Xi(c,a)));if(i.length)throw new Error(`REFUSE\xB7region ${r}: ${i.join(" \xB7 ")} is none of ${o.reads.join(" \xB7 ")}`);return o},"one");return{observe:s((r,n,o,i=[])=>(a=>a.observe?a.observe(r,n,i):[])(t(o,i.length?i.map(a=>a.place):[n])),"observe"),run:s((r,n,o,i)=>(a=>{if(!a.run)throw new Error(`REFUSE\xB7region ${i??""}: it reads the files it is handed, and none was handed`);return a.run(r,n,o)})(t(i,[r])),"run")}}s(Qi,"readers");var Yi=s((e,t,r,n)=>[{scope:`${e.region}/${t}`,measure:n,role:"reads",bound:{kind:"interval",lo:r,hi:r}}],"counted");function Zi(e){return typeof e=="string"?ht(e):$n(e,"answers")}s(Zi,"receiptShell");function ne(e){if(!e.length)throw Error("REFUSE\xB7projection empty standing");let t=e.map(r=>{let n=S(r,{preserveKeys:!0});if(n.kind!=="fact")throw Error(`REFUSE\xB7projection ${n.why}`);if(n.value.fields.value==="withdraw")throw Error("REFUSE\xB7projection history is not standing");let{sig:o,by:i,epoch:a,expires:c,repo:f,shape:u,...d}=n.value.fields;if(d.needs?.split("|").some(l=>l.startsWith("/")||l.split("/").includes("..")))throw Error("REFUSE\xB7projection host path is not a semantic coordinate");return x(d,n.value.version)});return[...new Set(t)].join(`
1
+ var xl=Object.defineProperty;var s=(e,t)=>xl(e,"name",{value:t,configurable:!0});function Qe(e,t="/"){let r=e.split(new RegExp(`[${t.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")}]`)).filter(n=>n!=="");for(;r[r.length-1]==="*"||r[r.length-1]==="**";)r.pop();return r}s(Qe,"coordinate");function Sr(e,t=0,r=[],n="/"){return{at:Qe(e,n),epoch:t,seen:r}}s(Sr,"point");function he(e,t="/"){return{at:Qe(e,t)}}s(he,"region");function ts(e,t){return{at:e.at.slice(0,Math.max(0,t)),epoch:e.epoch,seen:e.seen}}s(ts,"coarsen");function gt(e,t){return t.startsWith("*")?e.at.some(r=>r.endsWith(t.slice(1))):e.at.includes(t)}s(gt,"passes");function qe(e){return e.at.length}s(qe,"resolution");function le(e,t){let r=s((n,o)=>o===t.at.length||(t.at[o]==="**"?r(n,o+1)||n<e.at.length&&r(n+1,o):n<e.at.length&&(t.at[o]==="*"||t.at[o]===e.at[n])&&r(n+1,o+1)),"refines");return r(0,0)}s(le,"within");function Io(e,t){return e.filter(r=>!t.some(n=>n.some(o=>qe(o)===qe(r)&&le(r,o))))}s(Io,"exclusive");function Ao(e,t){return!e.some(r=>t.some(n=>le(n,r)))}s(Ao,"contracts");function ht(e){return[...new Set(e.map(t=>t.at.join("/")))].sort().join("|")}s(ht,"key");var es=s((e,t)=>e>=t.lo&&e<=t.hi,"inside");function Rl(e,t,r){let n=new Map;for(let o of e){if(!le(o,t))continue;let i=o.at.join("/");n.set(i,[...n.get(i)??[],o])}return[...n].sort((o,i)=>o[0]<i[0]?-1:o[0]>i[0]?1:0).map(([o,i])=>({at:o,value:r(i)}))}s(Rl,"foldRegion");function Fo(e,t){return e.every(r=>t.where.some(n=>le(r,n))&&es(qe(r),t.steps)&&es(r.epoch,t.when))}s(Fo,"covers");function Co(e,t,r){let n=t.filter(([o])=>e.some(i=>gt(i,o))).map(([,o])=>o);return r.find(o=>n.includes(o))??null}s(Co,"outranks");function Sl(e,t){return e.length>0&&e.every(r=>t.some(n=>le(r,n)))}s(Sl,"answers");function kl(e,t){return e.some(r=>t(r))}s(kl,"verified");function Ol(e,t){return e.filter(r=>t.some(n=>le(r,n)))}s(Ol,"retracted");function _l(e,t){return new Set(e.map(r=>{let n=Sr(r);return(t===void 0?n:ts(n,t)).at.join("/")})).size}s(_l,"size");function Il(e,t,r=Object.is){let n=t(e);for(let o=1;o<e;o+=1)if(r(t(o),n))return o;return e}s(Il,"sufficientResolution");var W=class e extends Error{static{s(this,"UnitError")}code;detail;constructor(t,r,n={}){super(r),this.name="UnitError",this.code=t,this.detail=Object.freeze({...n}),Object.setPrototypeOf(this,e.prototype)}};var rs=32;function ns(e){return e<=0?0:Math.ceil(e/rs)}s(ns,"chunkCount");var ve=class e{static{s(this,"WideMask")}words;width;constructor(t,r){this.width=t,this.words=r??new Uint32Array(ns(t))}static fromTokens(t,r){let n=new e(t.length);return t.forEach((o,i)=>{r.has(o)&&n.set(i)}),n}set(t){if(t<0||t>=this.width)throw new W("MALFORMED",`bit ${t} is outside a mask of width ${this.width}`,{bit:t,width:this.width});this.words[t>>5]|=1<<(t&31)}has(t){return t<0||t>=this.width?!1:(this.words[t>>5]&1<<(t&31))!==0}and(t){let r=Math.max(this.width,t.width),n=new e(r),o=Math.min(this.words.length,t.words.length);for(let i=0;i<o;i++)n.words[i]=this.words[i]&t.words[i];return n}or(t){let r=Math.max(this.width,t.width),n=new e(r);for(let o=0;o<n.words.length;o++)n.words[o]=(this.words[o]??0)|(t.words[o]??0);return n}difference(t){let r=Math.max(this.width,t.width),n=new e(r);for(let i=0;i<n.words.length;i++)n.words[i]=(this.words[i]??0)&~(t.words[i]??0);let o=r%32;return o!==0&&n.words.length>0&&(n.words[n.words.length-1]&=(1<<o)-1),n}subsetOf(t){let r=Math.max(this.words.length,t.words.length);for(let n=0;n<r;n++){let o=this.words[n]??0,i=t.words[n]??0;if((o&~i)!==0)return!1}return!0}size(){let t=0;for(let r=0;r<this.width;r++)this.has(r)&&t++;return t}members(t){return t.filter((r,n)=>this.has(n))}static filled(t){let r=new e(t);if(t<=0)return r;r.words.fill(4294967295);let n=t%32;return n!==0&&(r.words[r.words.length-1]=(1<<n)-1),r}};function No(e,t){return{subject:e,floor:t.floor,ceiling:t.ceiling}}s(No,"unit");var jo=s((e,t)=>No(t,{floor:e.bottom,ceiling:e.top}),"permitAll");function os(e,t){return e.stateOf(e.rank(t.floor),e.rank(t.ceiling))}s(os,"state");function is(e,t){for(let r of t)if(!e.leq(e.rank(r.floor),e.rank(r.ceiling)))throw new W("MALFORMED",`\`${r.subject}\` cannot be met by anything`,{subject:r.subject,floor:r.floor,ceiling:r.ceiling});return $o(e,t)}s(is,"compose");function Al(e,t,r,n,o){let i=r.floor,a=r.ceiling;for(let c of t)i=n(i,e.rank(c.floor)),a=o(a,e.rank(c.ceiling));return{subject:t[0].subject,floor:e.levels[i],ceiling:e.levels[a]}}s(Al,"band");function $o(e,t){return t.length===0?jo(e,""):Al(e,t,{floor:e.bottomIx,ceiling:e.topIx},(r,n)=>e.higher(r,n),(r,n)=>e.lower(r,n))}s($o,"fuse");function ss(e,t,r){let[n,o]=[e.rank(t.floor),e.rank(t.ceiling)],[i,a]=[e.rank(r.floor),e.rank(r.ceiling)];return e.leq(i,n)&&e.leq(o,a)}s(ss,"entails");function Po(e){let t=s(r=>os(e,r)!=="CONFLICT","inhabited");return{top:jo(e,""),bottom:{subject:"",floor:e.levels[e.topIx]??"",ceiling:e.levels[e.bottomIx]??""},leq:s((r,n)=>ss(e,r,n),"leq"),meet:s((r,n)=>$o(e,[r,n]),"meet"),join:s((r,n)=>t(r)?t(n)?{subject:r.subject||n.subject,floor:e.levels[e.lower(e.rank(r.floor),e.rank(n.floor))]??r.floor,ceiling:e.levels[e.higher(e.rank(r.ceiling),e.rank(n.ceiling))]??r.ceiling}:r:n,"join"),show:s(r=>`[${r.floor}, ${r.ceiling}]`,"show"),inhabited:t}}s(Po,"fromScale");function as(e){return{bottom:new ve(e.length),top:ve.filled(e.length),leq:s((t,r)=>t.subsetOf(r),"leq"),meet:s((t,r)=>t.and(r),"meet"),join:s((t,r)=>t.or(r),"join"),show:s(t=>t.members(e).join(","),"show"),inhabited:s(t=>t.size()>0,"inhabited")}}s(as,"subsets");function cs(e,t,r){let n=e.length;for(let m=0;m<n;m++)if(e.indexOf(e[m])!==m)throw new W("DUPLICATE_LEVEL",`the level \`${e[m]}\` is declared twice`,{level:e[m]});let o=new Map(e.map((m,y)=>[m,y])),i=s((m,y)=>t[m][y]===y,"leq"),a=e.every((m,y)=>e.every((b,F)=>t[y][F]===y||t[y][F]===F)),c=!0;for(let m=0;m<n&&c;m++)for(let y=0;y<n&&c;y++)for(let b=0;b<n;b++)if(r[m][t[y][b]]!==t[r[m][y]][r[m][b]]){c=!1;break}let l=[...e.keys()],f=l.find(m=>l.every(y=>i(m,y)))??0,u=l.find(m=>l.every(y=>i(y,m)))??n-1,d=l.filter(m=>m!==f&&l.filter(y=>y!==m&&i(y,m)).reduce((y,b)=>t[y][b],f)!==m),p=l.filter(m=>m!==u&&l.filter(y=>y!==m&&i(m,y)).reduce((y,b)=>r[y][b],u)!==m),h=new Set,g=[];for(let m of[...d,...p])h.has(m)||(h.add(m),g.push(m));return{levels:e,isLadder:a,isSimple:c,bottomIx:f,topIx:u,bottom:e[f],top:e[u],leq:i,higher:s((m,y)=>t[m][y],"higher"),lower:s((m,y)=>r[m][y],"lower"),rank(m){let y=o.get(m);if(y===void 0)throw new W("UNKNOWN_LEVEL",`no level \`${m}\` in this scale`,{level:m,levels:e});return y},stateOf(m,y){return i(m,y)?m!==f?"REQUIRED":y!==u?"FORBIDDEN":"FREE":"CONFLICT"},joins:s(()=>d.slice(),"joins"),limits:s(()=>p.slice(),"limits"),debits:s(()=>g.slice(),"debits"),intervalHeight(m,y){if(!i(m,y))return null;let b=l.filter(C=>i(m,C)&&i(C,y)),F=s(C=>b.filter(k=>k!==C&&i(C,k)&&!b.some(z=>z!==C&&z!==k&&i(C,z)&&i(z,k))),"covers"),P=new Map([[m,0]]),G=new Map([[m,0]]),ge=[...b].sort((C,k)=>b.filter(z=>i(z,C)).length-b.filter(z=>i(z,k)).length);for(let C of ge){let k=P.get(C),z=G.get(C);if(!(k===void 0||z===void 0))for(let Rr of F(C))P.set(Rr,Math.max(P.get(Rr)??k+1,k+1)),G.set(Rr,Math.min(G.get(Rr)??z+1,z+1))}let N=P.get(y);return N!==void 0&&N===G.get(y)?N:null}}}s(cs,"build");function Wt(e){if(!Array.isArray(e)||e.length===0)throw new W("EMPTY_CHAIN","a chain needs at least one level");let t=e.length,r=s(n=>[...Array(t)].map((o,i)=>[...Array(t)].map((a,c)=>n(i,c))),"grid");return cs(e,r(Math.max),r(Math.min))}s(Wt,"chain");function ls(e,t){if(!Array.isArray(e)||e.length===0)throw new W("EMPTY_CHAIN","an order needs at least one level");let r=e.length,n=s((i,a,c)=>{let l=[...Array(r).keys()].filter(u=>c?t[i][u]&&t[a][u]:t[u][i]&&t[u][a]),f=l.filter(u=>l.every(d=>c?t[u][d]:t[d][u]));if(f.length!==1)throw new W("MALFORMED",`\`${e[i]}\` and \`${e[a]}\` have ${f.length} ${c?"lowest common":"highest common"} bounds, so this is not a usable scale`,{levels:[e[i],e[a]]});return f[0]},"bound"),o=s(i=>[...Array(r)].map((a,c)=>[...Array(r)].map((l,f)=>n(c,f,i))),"grid");return cs(e,o(!0),o(!1))}s(ls,"order");function ne(e,t){let r=Math.min(e,t),n=Math.max(e,t);return{bottom:{lo:n,hi:r},top:{lo:r,hi:n},leq(o,i){return o.lo>o.hi?!0:i.lo>i.hi?!1:i.lo<=o.lo&&o.hi<=i.hi},meet(o,i){return{lo:Math.max(o.lo,i.lo),hi:Math.min(o.hi,i.hi)}},join(o,i){return o.lo>o.hi?i:i.lo>i.hi?o:{lo:Math.min(o.lo,i.lo),hi:Math.max(o.hi,i.hi)}},show(o){return o.lo>o.hi?"empty":`${o.lo}..${o.hi}`},inhabited(o){return o.lo<=o.hi}}}s(ne,"intervals");function kr(){let e=s((t,r)=>[...t].every(n=>r.has(n)),"within");return{leq(t,r){return t.polarity==="permit"&&r.polarity==="permit"?e(t.values,r.values):t.polarity==="forbid"&&r.polarity==="forbid"?e(r.values,t.values):t.polarity==="permit"?[...t.values].every(n=>!r.values.has(n)):!1},show(t){return`${t.polarity==="forbid"?"not:":""}${[...t.values].sort().join("|")}`}}}s(kr,"alphabets");function Or(e){let t={lattice:e.lattice,parse:e.parse,emit:e.emit,count:e.count,show:e.show,points:e.points},r=Object.entries(t).find(([,n])=>typeof n!="function");if(r)throw new Error(`form \`${e.id}\` declared no ${r[0]}`);return e}s(Or,"form");var de=s(e=>e!==null&&typeof e=="object"?e:{},"rec");function Ue(e){return Array.isArray(e)?e.map(String):[]}s(Ue,"strings");var Mo=s(e=>{let t=e>>>0;return()=>{t=t+1831565813>>>0;let r=Math.imul(t^t>>>15,t|1);return r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}},"drawn"),ds=s((e,t)=>t[Math.floor(e()*t.length)],"picked");function Fl(e,t){if(e.length===0)return{kind:"refused",why:"a ladder with no levels cannot be counted"};let r=Wt(e),n=r.rank(t.floor),o=r.rank(t.ceiling);return r.leq(n,o)?{kind:"finite",n:e.filter((a,c)=>r.leq(n,c)&&r.leq(c,o)).length}:{kind:"finite",n:0}}s(Fl,"bandCount");var us={parse(e,t){let r=this.lattice(e),n=de(t);return{subject:String(n.subject??""),floor:String(n.floor??r.top.floor),ceiling:String(n.ceiling??r.top.ceiling)}},emit(e,t){return{subject:t.subject,floor:t.floor,ceiling:t.ceiling}},count(e,t){return Fl(Ue(de(t).levels),e)},points(e,t,r){let n=this.lattice(e),o=Ue(de(e).levels),i=Mo(t),a=s((c,l)=>({subject:"",floor:c,ceiling:l}),"band");return Array.from({length:r},()=>{let[c,l]=[ds(i,o),ds(i,o)];return[a(c,l),a(l,c)].find(f=>n.inhabited(f))??a(c,c)})}},Ze=Or({id:"ladder",lattice(e){let t=Ue(de(e).levels);if(t.length===0)throw new Error("ladder needs levels");return Po(Wt(t))},...us,show(e){return e.floor===e.ceiling?e.floor:`${e.floor}..${e.ceiling}`}}),Fe=Or({id:"alphabet",lattice(e){return as(Ue(de(e).tokens))},parse(e,t){let r=Ue(de(e).tokens),n=de(t),o=n.want!==void 0?Ue(n.want):r;return ve.fromTokens(r,new Set(o))},emit(e,t){return{want:t.members(Ue(de(e).tokens))}},count(e){return{kind:"finite",n:e.size()}},show(e){return`${e.size()}`},points(e,t,r){let n=Ue(de(e).tokens),o=Mo(t);return Array.from({length:r},()=>ve.fromTokens(n,new Set(n.filter(()=>o()<.5))))}}),j=Or({id:"continuous",lattice(e){let t=de(e);return ne(Number(t.lo??0),Number(t.hi??1))},parse(e,t){let r=this.lattice(e),n=de(t);return{lo:n.lo===void 0?r.top.lo:Number(n.lo),hi:n.hi===void 0?r.top.hi:Number(n.hi)}},emit(e,t){return{lo:t.lo,hi:t.hi}},count(){return{kind:"refused",why:"a continuous band has no count; prefer not to exist over inventing one"}},show(e){return e.lo>e.hi?"empty":`${e.lo}..${e.hi}`},points(e,t,r){let n=de(e),o=Number(n.lo??0),i=Number(n.hi??1),a=Mo(t),c=s(()=>o+Math.round(a()*(i-o)),"at");return Array.from({length:r},()=>({lo:c(),hi:c()}))}}),Ee=Or({id:"lattice",lattice(e){let t=de(e),r=Ue(t.levels),n=t.leq;if(r.length&&n)return Po(ls(r,n));throw new Error("lattice needs levels+leq")},...us,show(e){return`${e.floor}..${e.ceiling}`}}),Uo=[Ze,Fe,j,Ee],fs=[...Uo];function Bo(e,t){let r=e.top;for(let n of t)r=e.meet(r,n);return r}s(Bo,"foldIn");function _r(e,t){let r=Bo(e,t);if(e.inhabited(r))return null;for(let n=0;n<t.length;n++)for(let o=n+1;o<t.length;o++)if(!e.inhabited(e.meet(t[n],t[o])))return[t[n],t[o]];return null}s(_r,"witnessesIn");function ye(e,t=0,r=[],n=[]){return{at:Qe(e),epoch:t,seen:r,restsOn:n}}s(ye,"cell");function De(e){if(e.widens!==void 0&&e.reach==="travels")throw new W("widening-travels","obligations: REFUSE\xB7widening-travels a widening stands where it was witnessed and never travels to what rests there",{pole:e.pole});return e.takes===void 0?e:{...e,sign:-1}}s(De,"mark");function ue(e){let t=new Set(e.flatMap(r=>r.takes===void 0?[]:[r.takes]));return e.filter(r=>r.takes===void 0&&(r.id===void 0||!t.has(r.id)))}s(ue,"live");function et(e,t=new Map){let r=e.at.join("/"),n=[],o=new Set,i=[...e.restsOn],a=new Map;for(let l=0;l<i.length;l+=1){let f=i[l];if(f===r)throw new W("rest-cycle",`obligations: REFUSE\xB7rest ${r} rests on itself: an order of rest with a cycle has no fold to reach`,{at:r});if(o.has(f))continue;o.add(f),n.push(f);let u=t.get(f)?.restsOn??[];a.set(f,u);for(let d of u)i.push(d)}let c=new Map;for(let l of n){if(c.has(l))continue;c.set(l,"visiting");let f=[{name:l,next:0}];for(;f.length;){let u=f[f.length-1],d=a.get(u.name);if(u.next===d.length){c.set(u.name,"done"),f.pop();continue}let p=d[u.next++],h=c.get(p);if(h==="visiting")throw new W("rest-cycle",`obligations: REFUSE\xB7rest ${r} reaches a cycle at ${p}: an order of rest with a cycle has no fold to reach`,{at:r});h===void 0&&(c.set(p,"visiting"),f.push({name:p,next:0}))}}return n}s(et,"restOf");function xe(e,t,r=new Map){let n=et(t,r),o=n.flatMap(u=>ue(r.get(u)?.marks??[]).filter(d=>d.reach==="travels"&&d.widens===void 0)),i=[...ue(t.marks??[]),...o].sort((u,d)=>(u.at??0)-(d.at??0)),a=e.top,c=e.top;for(let u of i)u.pole==="floor"?a=e.meet(a,u.span):c=u.widens===void 0?e.meet(c,u.span):e.join(c,u.span);let l=ue(t.seen),f=l.reduce((u,d)=>e.meet(u,d.span),e.top);return{floor:e.meet(a,f),ceiling:e.meet(c,f),origins:l,rest:n,required:a,signed:c}}s(xe,"parts");function ps(e,t,r=new Map){let{floor:n,ceiling:o,origins:i,required:a,signed:c}=xe(e,t,r);return e.inhabited(e.meet(a,c))?new Set(i.map(l=>l.origin)).size<2?"REQUIRED":e.inhabited(i.reduce((l,f)=>e.meet(l,f.span),e.top))?e.inhabited(e.meet(n,o))?"FREE":"FORBIDDEN":"CONFLICT":"CONFLICT"}s(ps,"state");function ie(e,t,r=new Map){let{floor:n,ceiling:o}=xe(e,t,r);return e.meet(n,o)}s(ie,"meet");var gs=s(e=>ne(Math.min(...e.map(t=>t.lo)),Math.max(...e.map(t=>t.hi))),"spanning");function To(e){return new Set(e.seen.map(t=>t.origin)).size}s(To,"origins");function Jt(e){return To(e)<2}s(Jt,"potential");function Lo(e){let t=e.seen.map(i=>i.span),r=t.length?_r(gs(t),t):null;if(!r)return null;let n=e.seen.find(i=>i.span===r[0]),o=e.seen.find(i=>i.span===r[1]);return n&&o?[n,o]:null}s(Lo,"disagree");function Ir(e){let t=e.seen.map(n=>n.span);if(!t.length)throw new Error("obligations: REFUSE\xB7meet a cell no origin has claimed has no meet of its own: read it against the form it belongs to");let r=gs(t);return t.reduce((n,o)=>r.meet(n,o))}s(Ir,"meetAt");function hs(e){return e.reduce((t,r)=>t===null||r.epoch>t.epoch?r:t,null)}s(hs,"latest");function ms(e){return Jt(e)?"one":Lo(e)?"apart":"together"}s(ms,"verdict");function ys(e,t){let r=new Map(e.map(n=>[ht([{at:n.at}]),ms(n)]));return t.filter(n=>r.get(ht([{at:n.at}]))!==ms(n))}s(ys,"turned");function Ht(e,t,r=new Map){return{origins:new Set(ue(t.seen).map(n=>n.origin)).size,held:ie(e,t,r)}}s(Ht,"encounter");var qo=s((e,t)=>Math.cos(e.phase-t.phase)<0,"cancels");function bs(e){let t=0,r=0;for(let n=0;n<e.length;n+=1)for(let o=n+1;o<e.length;o+=1)qo(e[n],e[o])?t+=1:r+=1;return{forks:t,closes:r}}s(bs,"pairs");function ws(e){let t=e.reduce((n,o)=>n+Math.cos(o.phase),0),r=e.reduce((n,o)=>n+Math.sin(o.phase),0);return t*t+r*r>e.length}s(ws,"laminar");function vs(e,t,r,n,o){if(n==="")throw new W("join-unwitnessed","obligations: REFUSE\xB7join a widening lands only with a witness or the signatures of whoever rests on the old bound");return{...t,marks:[...t.marks??[],De({pole:"ceiling",reach:"local",span:e.meet(e.top,r),widens:n,...o===void 0?{}:{at:o}})]}}s(vs,"join");function Ar(e,t,r=t.takes===void 0?1:-1){let n=r===1?void 0:t.takes??t.id;if(r===1&&t.takes!==void 0)throw new W("sign-mismatch","obligations: REFUSE\xB7observe a claim that takes another back is observed at \u22121, never at +1");if(r===-1&&n===void 0)throw new W("withdrawal-unnamed","obligations: REFUSE\xB7observe a withdrawal names the claim it takes back, never a value that looks like it");let o=n===void 0?t:{origin:t.origin,span:t.span,sign:-1,takes:n,...t.at===void 0?{}:{at:t.at}};return{...e,epoch:Math.max(e.epoch,t.at??e.epoch),seen:[...e.seen,o]}}s(Ar,"observe");function Es(e,t){return{...e,at:t>=e.at.length?e.at:e.at.slice(0,Math.max(1,t))}}s(Es,"refine");function xs(e,t,r,n,o={}){let i=t.get(r)??ye(r);return new Map([...t,[r,{...i,marks:[...i.marks??[],De({pole:"floor",reach:"travels",span:e.meet(e.top,n),...o})]}]])}s(xs,"require");function Fr(e,t,r,n,o={}){let i=t.get(r)??ye(r);return new Map([...t,[r,{...i,marks:[...i.marks??[],De({pole:"ceiling",reach:"travels",span:e.meet(e.top,n),...o})]}]])}s(Fr,"sign");function Rs(e){let t=new Map;for(let[r,n]of e)for(let o of n.restsOn)t.set(o,[...t.get(o)??[],r]);return t}s(Rs,"restingOn");function Ss(e,t,r,n,o){let i=s(u=>ue(t.get(u)?.marks??[]).filter(d=>d.pole==="ceiling"&&d.reach==="travels"&&d.widens===void 0).reduce((d,p)=>e.meet(d,p.span),e.top),"own"),a=s(u=>et(t.get(u)??ye(u),t).reduce((d,p)=>e.meet(d,i(p)),i(u)),"above"),c=[],l=[[n,a(n)]],f=new Set([n]);for(let u=0;u<l.length;u+=1){let[d,p]=l[u];if(!e.leq(p,o)){c.push(d);for(let h of r.get(d)??[]){if(f.has(h))continue;f.add(h);let g=t.get(h);l.push([h,g!==void 0&&g.restsOn.length===1?e.meet(p,i(h)):a(h)])}}}return{cells:c,visits:l.length}}s(Ss,"bites");function ks(e){if(Jt(e))return"potential";let t=Ir(e);return t.lo>t.hi?null:t}s(ks,"present");function Os(e,t,r,n){let o=e;for(let i=0;i<n;i+=1)o=Math.max(0,o+t-r);return{width:o,trend:o===0&&e>0?"zero":o>e?"widens":o<e?"narrows":"holds"}}s(Os,"converge");function _s(e,t,r){let n=[...t,...r].map(([,i])=>i),o=n.length?Math.max(...n):0;return t.length===0&&o<e}s(_s,"endsBeforeNow");function Cr(e){let t=e.span.hi-e.span.lo,r=Number.isFinite(t)?1/(1+Math.max(t,0)):0;return e.withdraws?-r:r}s(Cr,"amplitude");function Nr(e,t){return t<=0?0:(e.epoch%t+t)%t}s(Nr,"phase");function yt(e,t){if(!e.length)return 0;let r=0,n=0;for(let o of e){let i=2*Math.PI*Nr(o,t)/t;r+=Math.cos(i),n+=Math.sin(i)}return Math.sqrt(r*r+n*n)/e.length}s(yt,"coherence");function Do(e,t){let r=0,n=0;for(let o of e){let i=2*Math.PI*Nr(o,t)/t;r+=Cr(o)*Math.cos(i),n+=Cr(o)*Math.sin(i)}return Math.sqrt(r*r+n*n)**2}s(Do,"interfere");function Is(e,t,r){return r.map(n=>Do(e.map((o,i)=>i%2===0?o:{...o,epoch:o.epoch+n}),t))}s(Is,"fringes");var As=s((e,t)=>e.seen.map(r=>({origin:r.origin,epoch:e.epoch,span:r.span})),"seenAs");function tt(e,t,r){return e.leq(t,r)&&e.leq(r,t)}s(tt,"eq");function Fs(e,t){return t===0?[[]]:e.flatMap((r,n)=>Fs(e.slice(n+1),t-1).map(o=>[r,...o]))}s(Fs,"takes");function Cs(e,t,r=new Map){let n=xe(e,t,r),o=[...new Set(ue(t.seen).map(i=>i.origin))];for(let i=1;i<=o.length;i+=1)for(let a of Fs(o,i)){let c=xe(e,{...t,seen:t.seen.filter(l=>!a.includes(l.origin))},r);if(!tt(e,c.floor,n.floor)||!tt(e,c.ceiling,n.ceiling))return i}return 0}s(Cs,"fragility");function Ns(e,t,r){return e(t)-e(r)}s(Ns,"price");function js(e,t,r){return xe(e,t.get(r)??ye(r),t).ceiling.hi}s(js,"looksLeft");function $s(e,t,r){let n=xe(e,t.get(r)??ye(r),t);if(n.ceiling.hi-1<n.floor.lo)throw new W("attention-spent",`obligations: REFUSE\xB7attention ${r} has no look left: an act nobody pays for is not taken`);return Fr(e,t,r,{lo:e.top.lo,hi:n.ceiling.hi-1})}s($s,"pay");function Ps(e,t,r){let n=ie(e,t),o=ie(e,{...t,seen:[...t.seen,r]}),i=s(a=>Math.max(0,a.hi-a.lo),"width");return i(n)-i(o)}s(Ps,"disturbance");function Ms(e,t){if(t<=0)throw new Error("obligations: REFUSE\xB7budget a region read at no resolution has no budget to take");return Math.ceil(2*e/t)}s(Ms,"budget");function Us(e,t,r,n){let o=s(i=>{let a=ie(e,i);return n<=0?a.lo:Math.round(a.lo/n)},"bin");return o(t)===o(r)}s(Us,"sameObject");function Bs(e,t,r){let n=new Set;for(let o of t){let i=ie(e,o);n.add(r<=0?i.lo:Math.round(i.lo/r))}return n.size}s(Bs,"distinct");function Ts(e,t,r,n){let o=n,i=s(()=>(o=(o*1103515245+12345)%2147483648,o/2147483648),"next"),a=[],c=e;for(let l=1;l<=t;l+=1){for(let f=0;f<r;f+=1){let u=c.map(y=>1+20*y.seen.length),d=u.reduce((y,b)=>y+b,0),p=s(()=>{let y=i()*d,b=0;for(;y>u[b]&&b<c.length-1;)y-=u[b],b+=1;return b},"where"),h=p(),g=p();g===h&&(g=(g+1)%c.length);let m=`e${l}-${f}`;c=c.map((y,b)=>b===h||b===g?{...y,epoch:l,seen:[...y.seen,{id:`${m}-${b}`,origin:m,at:l,span:{lo:0,hi:100}}]}:y)}a.push(c)}return a}s(Ts,"evolve");function Ls(e,t,r){let n=e.map((i,a)=>({...i,epoch:i.at??0,origin:i.origin||`o${a}`})),o=Array.from({length:t},(i,a)=>({origin:`n${a}`,span:{lo:0,hi:1},epoch:a%Math.max(1,r),at:a%Math.max(1,r)}));return yt([...n,...o].map(i=>({origin:i.origin,epoch:i.epoch,span:i.span})),r)}s(Ls,"decohere");var qs=s(e=>e.at.join("/"),"at"),Cl=s((e,t)=>[...new Set(e.seen.map(r=>r.origin))].filter(r=>!t.includes(r)),"spoke");function zo(e,t=[]){let r=new Map;for(let o of e)for(let i of Cl(o,t))r.set(i,[...r.get(i)??[],qs(o)]);let n=new Map;for(let o of r.values())for(let i of o){let a=n.get(i)??new Set;for(let c of o)c!==i&&a.add(c);n.set(i,a)}return new Map([...n].map(([o,i])=>[o,[...i]]))}s(zo,"neighbours");function Nl(e,t,r=[]){let n=zo(e,r),o=new Set([t]),i=[t];for(;i.length;){let a=i.pop();for(let c of n.get(a)??[])o.has(c)||(o.add(c),i.push(c))}return e.map(qs).filter(a=>!o.has(a))}s(Nl,"horizon");function Ds(e,t,r=[]){return e.length-Nl(e,t,r).length-1}s(Ds,"reach");var Ws=s(e=>e.at.join("/"),"at"),zs=s((e,t)=>{let r=ie(e,t);return Ht(e,t).origins<2?"one":r.lo>r.hi?"apart":"together"},"said"),jl=s((e,t)=>{let r=ie(e,t);return Math.max(0,r.hi-r.lo)},"widthOf");function Wo(e,t,r,n){let o="",i;for(let a of t){let c=Ws(a);if(n.has(c))continue;let l=a.seen.map((u,d)=>({origin:u.origin,epoch:u.at??d,span:u.span})),f=r.reach*Ds(t,c)+r.coherence*yt(l,8)+r.rank*(zo(t).get(c)??[]).length+r.bits*Math.log2(1+jl(e,a));(i===void 0||f>i)&&(i=f,o=c)}return o}s(Wo,"choose");function Js(e,t,r,n,o,i){let a=o,c=s(()=>(a=(a*1103515245+12345)%2147483648,a/2147483648),"next"),l=[...t],f=new Set,u=new Set,d=0;for(let h=1;h<=n;h+=1){let g=Wo(e,l,r,new Set);if(!g)break;l=l.map(m=>{if(Ws(m)!==g)return m;let y=zs(e,m),b=ie(e,m),F=(b.lo+b.hi)/2+(c()*2-1)*i,P={id:`p${h}`,origin:`p${h}`,at:h,span:{lo:F-5,hi:F+5}},G={...m,epoch:h,seen:[...m.seen,P]},ge=zs(e,G);return ge==="together"&&y!=="together"&&f.add(g),ge==="apart"&&(u.add(g),f.has(g)&&(d+=1,f.delete(g))),G})}let p=l.filter(h=>Ht(e,h).origins>1).length;return{closed:f.size,forks:u.size,reopened:d,coverage:Math.round(100*p/l.length)}}s(Js,"play");function Hs(e,t,r,n,o,i){let a=i,c=s(()=>(a=(a*1103515245+12345)%2147483648,a/2147483648),"next"),l=[],f=t;for(let u=1;u<=r;u+=1){let d=ie(e,f),p=(d.lo+d.hi)/2+(c()*2-1)*o;f=Ar(f,{origin:`self${u}`,at:u,span:{lo:p-n/2,hi:p+n/2}}),l.push(f)}return l}s(Hs,"selfFold");function Gs(e){return e==="widen"?"authorize":"attest"}s(Gs,"keyClassFor");function Ks(e){let t=e.statement;if(!t)return{relation:"absent"};if(!t.admitted)return{relation:"unadmitted",source:"statement"};if(!e.expected.reference)return{relation:"unresolved",source:"statement"};if(t.reference===e.expected.reference)return{relation:t.value===e.expected.value?"equal":"different",source:"statement"};let r=e.comparison;return r?.admitted&&r.reference===e.expected.reference?{relation:r.equal?"equal":"different",source:"comparison"}:{relation:"stale",source:"statement"}}s(Ks,"compareEvidence");function Vs(e,t){let r=[...new Set((e.value??"").split("|").filter(Boolean))],n=[...new Set((e.needs??"").split("|").filter(Boolean))],o={scope:e.scope??"",required:r,evidence:[]};if(!r.length||!n.length||n.some(a=>/[=\s\\*]/.test(a)||a.startsWith("/")||a.split("/").some(c=>c==="."||c===".."||!c)))return{...o,status:"unresolved",reason:"expected an accepted alphabet and exact evidence coordinates"};let i=n.flatMap(a=>[...new Set(t.filter(c=>c.coordinate===a).map(c=>c.value))].map(c=>({coordinate:a,value:c})));return n.some(a=>i.filter(c=>c.coordinate===a).length!==1)?{...o,evidence:i,status:"unresolved",reason:"missing or conflicting evidence"}:{...o,evidence:i,status:i.every(a=>r.includes(a.value))?"met":"blocked"}}s(Vs,"verdictDemand");function bt(e){let t=[],r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="\\"){let i=e[n+1];if(i!=="|"&&i!=="\\")return null;r+=i,n+=1}else o==="|"?(t.push(r),r=""):r+=o}return t.push(r),t}s(bt,"unpipe");var jr="*",Ys=s(e=>{if(!/^-?\d+(\.\d+)?$/.test(e))return null;let t=Number(e);return isFinite(t)?t:null},"num");function $r(e){if(!isFinite(e))throw new Error(`REFUSE\xB7wire decimal: \`${e}\` is not a finite number`);let t=/^(-?)(\d)(?:\.(\d+))?e([+-])(\d+)$/.exec(String(e));if(t===null)return String(e);let[,r="",n="",o="",i="",a="0"]=t;return i==="+"?`${r}${n}${o}${"0".repeat(Number(a)-o.length)}`:`${r}0.${"0".repeat(Number(a)-1)}${n}${o}`}s($r,"decimal");var Xs={interval:s(e=>{let t=e.indexOf("..");if(t<0)return null;let r=e.slice(0,t),n=e.slice(t+2),o=r===jr?null:Ys(r),i=n===jr?null:Ys(n);return r!==jr&&o===null||n!==jr&&i===null?null:{kind:"interval",lo:o,hi:i}},"interval"),alphabet:s(e=>{let t=bt(e);return t===null?null:{kind:"enumerated",values:t}},"alphabet"),ladder:s(e=>{let t=bt(e);return t===null||t.length!==2?null:{kind:"band",floor:t[0]??"",ceiling:t[1]??""}},"ladder")};function Ce(e,t,r){let n=Array.isArray(r)?r.find(o=>o.form===e):void 0;return n?n.parse(t):Xs[e]?.(t)??null}s(Ce,"boundOf");var Qs=Object.keys(Xs),Zs=["within","copies","derives"];var[Pr,Jo,Ho,Mr,Go,Gt,Ko,Ur]=["not:","none","|","=","/","@","*","\\"],ze=s((e,t)=>{throw new Error(`REFUSE\xB7wire ${e}: ${t}`)},"refuse"),$l=s(e=>e!==""&&[...e].every(t=>t>="0"&&t<="9"),"digits");function M(e){if(typeof e!="string"){let o=e.members.map(i=>i.split(Ur).join(Ur+Ur).split(Ho).join(Ur+Ho)).join(Ho);return e.polarity==="forbid"?Pr+o:o.startsWith(Pr)||o===Jo?ze("alphabet","a permitted alphabet neither begins with not: nor is the one word none"):o||Jo}let t=e.startsWith(Pr),r=t?e.slice(Pr.length):e,n=!t&&r===Jo?[]:bt(r)??ze("alphabet","a backslash escapes only a pipe or itself");return{polarity:t?"forbid":"permit",members:n.filter(o=>o!=="")}}s(M,"alphabet");function wt(e){if(typeof e!="string")return M({polarity:"permit",members:e.map(([r,n])=>r+Mr+n)});let t=M(e);return t.polarity==="forbid"&&ze("fields","fields carry no polarity"),t.members.map(r=>r.indexOf(Mr)>0?[r.slice(0,r.indexOf(Mr)),r.slice(r.indexOf(Mr)+1)]:ze("fields",`\`${r}\` is not key=value`))}s(wt,"fields");function rt(e){return typeof e=="string"?e.split(Go):e.some(t=>t.includes(Go))?ze("steps","a step holds no slash"):e.join(Go)}s(rt,"steps");function vt(e){if(typeof e!="string")return e.at===void 0?e.name:e.name+Gt+String(e.at);let t=e.lastIndexOf(Gt);if(t<0)return{name:e};let[r,n]=[e.slice(0,t),e.slice(t+1)];return(r===""||n!==Ko&&!$l(n))&&ze("atResolution",`\`${e}\` is not name@digits or name@*`),{name:r,at:n===Ko?Ko:Number(n)}}s(vt,"atResolution");function Br(e){if(typeof e!="string")return e.name===""||e.range===""||e.range.includes(Gt)?ze("requirement","a requirement names what it requires and a range, with no at sign"):e.name+Gt+e.range;let t=e.lastIndexOf(Gt);return t>0&&t<e.length-1?{name:e.slice(0,t),range:e.slice(t+1)}:ze("requirement",`\`${e}\` is not name@range`)}s(Br,"requirement");var Tr=s((e,t)=>e?.[t]??"","of"),Vo=s((e,t)=>e.lines.find(r=>Tr(r,"scope")===t),"found"),Yo=s((e,t)=>Vo(e,t)===void 0?void 0:Tr(Vo(e,t),"value"),"value"),Pl=s((e,t)=>M(Yo(e,t)??"").members,"listed"),Ml=s(e=>Yo(e,"lang")??"","lang"),Ul=s((e,t)=>e.regions[t]?.receipts??[],"receipts"),Bl=s(e=>Tr(e,"at").replace(/^[^:]*:/,""),"placeOf"),Tl=s((e,t)=>e.regions[t]?.lines??[],"regionLines");function ea(e,t){if(!e.includes("*"))return e===t;let r=e.split("*");if(!t.startsWith(r[0]))return!1;let n=r[0].length;for(let o=1;o<r.length;o++){let i=r[o];if(i==="")return o===r.length-1||ea(r.slice(o).join("*"),t.slice(n));let a=t.indexOf(i,n);if(a<0)return!1;n=a+i.length}return n===t.length||e.endsWith("*")}s(ea,"matchStar");function Xo(e,t,r,n){if(t===e.length)return n===r.length;if(e[t]==="**"){if(t+1===e.length)return!0;for(let o=n;o<=r.length;o++)if(Xo(e,t+1,r,o))return!0;return!1}return n===r.length||!ea(e[t],r[n])?!1:Xo(e,t+1,r,n+1)}s(Xo,"matchParts");function ee(e,t){return Xo(e.split("/"),0,t.split("/"),0)}s(ee,"matches");var fe=s(e=>({kind:"fact",value:e}),"fact"),We=s(e=>({kind:"abstain",why:e}),"abstain"),$=s((e,t)=>({kind:"refuse",why:e,...t===void 0?{}:{named:t}}),"refuse");var re="bound-lock/1",ra=/[ ="\n\\]/;function Ll(e){return ra.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}"`:e}s(Ll,"escape");function ql(e){if(!e.startsWith('"'))return ra.test(e)?null:e;if(e.length<2||!e.endsWith('"'))return null;let t=e.slice(1,-1),r="";for(let n=0;n<t.length;n++){let o=t[n];if(o!=="\\"){if(o==='"')return null;r+=o;continue}let i=t[n+1];if(i==='"')r+='"';else if(i==="\\")r+="\\";else if(i==="n")r+=`
2
+ `;else return null;n+=1}return r}s(ql,"unescape");var ta=new TextEncoder;function w(e,t){let r=ta.encode(e),n=ta.encode(t);for(let o=0;o<r.length&&o<n.length;o++)if(r[o]!==n[o])return r[o]-n[o];return r.length-n.length}s(w,"byBytes");var na=s(e=>e.form==="interval"&&e.value!==void 0&&e.value!=="withdraw"&&Ce("interval",e.value)===null,"unwritten");function v(e,t="1"){if(na(e))throw new Error(`REFUSE\xB7wire canonical: \`${e.value}\` is no interval the wire writes: two ends, each decimal or *`);let n=Object.keys(e).sort(w).map(o=>`${o}=${Ll(e[o])}`);return[`${re.split("/")[0]}/${t}`,...n].join(" ")}s(v,"canonical");function pe(e,t="1"){let{sig:r,...n}=e;return v(n,t)}s(pe,"signedBytes");var Dl="-";function x(e,t={}){if(e.includes(`
3
+ `))return $("a line is one line \u2014 a newline in a value must be escaped as `\\n`");let r=e.indexOf(" "),n=r===-1?e:e.slice(0,r),[o,i]=n.split("/");if(o!==re.split("/")[0]||!i)return $(`no \`bound-lock/<v>\` envelope \u2014 found \`${n.slice(0,24)}\``);if(i!==re.split("/")[1])return We(`\`bound-lock/${i}\` is a version this reader does not know`);let a={},c=new Set;for(let l of zl(r===-1?"":e.slice(r+1))){if(l===null)return $("a quoted value is not closed");let f=l.indexOf("=");if(f<=0)return $(`\`${l.slice(0,24)}\` is not \`key=value\``);let u=l.slice(0,f);if(c.has(u))return $(`\`${u}\` appears twice \u2014 one line, one value per key`);c.add(u);let d=ql(l.slice(f+1));if(d===null)return $(`\`${u}\` has an escaping this format does not define`);d!==Dl&&(a[u]=d)}return na(a)?$(`\`${a.value}\` is no interval the wire reads: two ends, each decimal or *`):fe({version:i,fields:a,...t.preserveKeys?{keys:[...c]}:{}})}s(x,"parse");function*zl(e){let t=0;for(;t<e.length;){for(;e[t]===" ";)t+=1;if(t>=e.length)return;let r=t,n=!1;for(;r<e.length&&(n||e[r]!==" ");)e[r]==="\\"&&n?r+=1:e[r]==='"'&&(n=!n),r+=1;if(n){yield null;return}yield e.slice(t,r),t=r}}s(zl,"tokensOf");function oa(e){let t=x(e,{preserveKeys:!0});if(t.kind!=="fact")return t;let r=t.value.keys.find(n=>t.value.fields[n]===void 0);return r===void 0?t:$(`signing cannot discard explicitly absent field ${r}; omit the key`,r)}s(oa,"parseForSigning");var ia=s(e=>e.flatMap(t=>{let r=x(t);return r.kind==="fact"&&r.value.fields.value!=="withdraw"?[r.value.fields]:[]}),"standing");function Qo(e){let t=ia(e),r=s(f=>t.filter(u=>u.scope===f).flatMap(u=>M(u.value??"").members),"said"),n=t.filter(f=>(f.scope??"").startsWith("region/")&&f.measure==="reads"),o=s((f,u)=>(f.scope??"").slice(u.length),"named"),i=s(f=>n.filter(u=>u.scope===f).flatMap(u=>M(u.value??"").members),"reading"),a=Object.fromEntries(n.length?n.map(f=>[o(f,"region/"),i(f.scope??"")]):t.filter(f=>(f.scope??"").startsWith("capsule/reads/")).map(f=>[o(f,"capsule/reads/"),r(f.scope??"")])),[c,l]=[r("capsule/runtime")[0],r("capsule/holds")[0]];return{domain:r("capsule/domain")[0]??"",...c===void 0?{}:{runtime:c},...l===void 0?{}:{holds:l},pins:Object.fromEntries(t.filter(f=>(f.scope??"").startsWith("capsule/")&&f.measure==="digest").map(f=>[o(f,"capsule/"),f.value??""])),renders:n.length?n.filter(f=>f.role==="render").map(f=>o(f,"region/")):r("capsule/regions"),reads:[...new Set([...r("capsule/reads"),...Object.values(a).flat()])],regions:a,writes:Object.fromEntries(n.map(f=>[o(f,"region/"),f.role??""])),effects:r("capsule/effects")}}s(Qo,"declarationOf");var Wl=s((e,t)=>Object.keys(e.regions).length?e.regions[t]:e.reads,"readsOf");function Kt(e,t){return ia(t).filter(r=>e.some(n=>ee(n,r.scope??"")))}s(Kt,"handed");function Jl(e){return typeof e=="string"?Lr(e):sa(e,"renders")}s(Jl,"shell");var sa=s((e,t)=>r=>{let n=e[r.region];if(n===void 0)throw new Error(`REFUSE\xB7region ${r.region}: no line of this capsule ${t} it`);let o=n.reads.filter(i=>!r.reads.includes(i));if(o.length)throw new Error(`REFUSE\xB7region ${r.region}: handed less than it declares, without ${o.join(" \xB7 ")}`);return n.region(r)},"dispatch"),Lr=s(e=>Object.assign(()=>{throw new Error(`REFUSE\xB7world ${e}: its host answers it by the regions its own lock names`)},{world:e}),"located"),Hl=s((e,t)=>{let r=vt(e).name,[n,o]=t.endsWith("/")?[t.slice(0,-1),"/"]:[t,""],i=rt(n);return i.some((a,c)=>ee(r,`${rt(i.slice(c))}${o}`))},"fits");function Gl(e){if(typeof e=="string")return{observe:Lr(e),run:Lr(e)};let t=s((r,n)=>{let o=r===void 0?void 0:e[r];if(o===void 0)throw new Error(`REFUSE\xB7region ${r??""}: no line of this capsule reads with it`);let i=n.filter(a=>!o.reads.some(c=>Hl(c,a)));if(i.length)throw new Error(`REFUSE\xB7region ${r}: ${i.join(" \xB7 ")} is none of ${o.reads.join(" \xB7 ")}`);return o},"one");return{observe:s((r,n,o,i=[])=>(a=>a.observe?a.observe(r,n,i):[])(t(o,i.length?i.map(a=>a.place):[n])),"observe"),run:s((r,n,o,i)=>(a=>{if(!a.run)throw new Error(`REFUSE\xB7region ${i??""}: it reads the files it is handed, and none was handed`);return a.run(r,n,o)})(t(i,[r])),"run")}}s(Gl,"readers");var Kl=s((e,t,r,n)=>[{scope:`${e.region}/${t}`,measure:n,role:"reads",bound:{kind:"interval",lo:r,hi:r}}],"counted");function Vl(e){return typeof e=="string"?Lr(e):sa(e,"answers")}s(Vl,"receiptShell");function be(e){if(!e.length)throw Error("REFUSE\xB7projection empty standing");let t=e.map(r=>{let n=x(r,{preserveKeys:!0});if(n.kind!=="fact")throw Error(`REFUSE\xB7projection ${n.why}`);if(n.value.fields.value==="withdraw")throw Error("REFUSE\xB7projection history is not standing");let{sig:o,by:i,epoch:a,expires:c,repo:l,shape:f,...u}=n.value.fields;if(u.needs?.split("|").some(d=>d.startsWith("/")||d.split("/").includes("..")))throw Error("REFUSE\xB7projection host path is not a semantic coordinate");return v(u,n.value.version)});return[...new Set(t)].join(`
4
4
  `)+`
5
- `}s(ne,"semanticStandingBytes");function gt(e){let t=e.endsWith(`
5
+ `}s(be,"semanticStandingBytes");function Et(e){let t=e.endsWith(`
6
6
  `)?e.slice(0,-1).split(`
7
- `):[];if(!t.length||ne(t)!==e)throw Error("REFUSE\xB7projection bytes are not canonical semantic standing");return t}s(gt,"readSemanticStanding");var Ve=s(e=>typeof e=="string"&&e.length>0,"named"),we=s(e=>{throw Error("REFUSE\xB7reading identity "+e)},"refuse");function Fn(e,t){Array.isArray(e)||we("missing "+t);let r=new Set;for(let n of e)(!Array.isArray(n)||n.length!==2||!Ve(n[0])||!Ve(n[1]))&&we("invalid "+t+" reference"),r.has(n[0])&&we("duplicate "+t+" coordinate "+n[0]),r.add(n[0]);return[...e].sort((n,o)=>v(n[0],o[0]))}s(Fn,"references");function Ee(e){e||we("missing context");let t=["instrument","implementation","policy","inputs","environment"];for(let r of Object.keys(e).sort(v))t.includes(r)||we("undeclared context field "+r);for(let r of["instrument","implementation","policy"])Ve(e[r])||we("missing "+r);return new TextEncoder().encode(JSON.stringify(["reading-context@1",e.instrument,e.implementation,e.policy,Fn(e.inputs,"inputs"),Fn(e.environment,"environment")])+`
8
- `)}s(Ee,"readingIdentityBytes");function yt(e,t){return t(Ee(e))}s(yt,"readingIdentity");function Ge(e,t){return(!Ve(e)||!Ve(t))&&we("missing receipt reading or result"),new TextEncoder().encode(JSON.stringify(["reading-receipt@1",e,t])+`
9
- `)}s(Ge,"readingReceiptBytes");function bt(e,t,r){return r(Ge(e,t))}s(bt,"readingReceiptIdentity");function wt(e,t,r,n,o){let i=e.parts.filter(p=>p.scope===`${t}/place-inputs/${r}`&&p.measure==="reads");if(!i.length)return;let a=e.parts.filter(p=>p.scope==="wire/place-inputs");if(a.length!==1||a[0].role!=="writes"||a[0].measure!=="id"||a[0].value!=="admitted-place-inputs@1")throw Error("REFUSE\xB7place inputs missing or conflicting profile "+t);let c=n.length?ne(n).trimEnd().split(`
10
- `):[],f=new Set;for(let p of i){if(p.role!=="reads"&&p.role!=="demands")throw Error("REFUSE\xB7place inputs invalid selector role "+p.scope);let m=(p.value??"").split("|").filter(Boolean);if(!m.length)throw Error("REFUSE\xB7place inputs empty selector "+p.scope);let g=c.filter(h=>{let y=S(h);return y.kind==="fact"&&m.some(b=>T(b,y.value.fields.scope??""))});if(p.role==="demands"&&!g.length)throw Error("REFUSE\xB7place inputs required member absent "+p.scope);for(let h of g)f.add(h)}let u=c.filter(p=>f.has(p)),d=ne(i.map(p=>x(p))).trimEnd().split(`
11
- `),l=new TextEncoder().encode(JSON.stringify(["admitted-place-inputs@1",d,u])+`
12
- `);return{profile:"admitted-place-inputs@1",digest:o(l),selectors:d,lines:u}}s(wt,"placeInputs");function Et(e,t,r){let n={...e,inputs:[...e.inputs,[t,r.digest]]};return Ee(n),n}s(Et,"withPlaceInputs");var vt=s(e=>typeof e=="string"&&/^(?:[^\s:@]+@[0-9]+:)?[a-z][a-z0-9-]*:[0-9a-f]+$/.test(e),"digest");function xt(e){let t;try{t=JSON.parse(e)}catch{throw Error("REFUSE\xB7release invalid delivery metadata")}if(!t||typeof t!="object"||Array.isArray(t))throw Error("REFUSE\xB7release missing delivery record");let r=t;if(Object.keys(r).some(n=>!["standing","blob","predecessor"].includes(n))||!vt(r.standing)||!vt(r.blob)||r.predecessor!==void 0&&!vt(r.predecessor))throw Error("REFUSE\xB7release invalid delivery digests or fields");return{standing:r.standing,blob:r.blob,...r.predecessor===void 0?{}:{predecessor:r.predecessor}}}s(xt,"readReleaseDelivery");function St(e,t){if(!vt(e))throw Error("REFUSE\xB7adoption missing selected standing digest");let r=[...new Set(t)].map(i=>{let a=S(i);if(a.kind!=="fact")throw Error("REFUSE\xB7adoption invalid standing line");return a.value.fields}),n=r.filter(i=>i.scope==="wire/adoption/profile"),o=r.filter(i=>i.scope?.startsWith("needs/place/"));if(!n.length){if(o.length)throw Error("REFUSE\xB7adoption requirements have no declared profile");return[]}if(n.some(i=>i.value!=="place-requirements@1"))throw Error("REFUSE\xB7adoption conflicting or unsupported profile");return o.map(i=>{if(i.role!=="demands"||i.measure!=="line"||!i.scope.slice(12))throw Error(`REFUSE\xB7adoption invalid requirement ${i.scope}`);let a=S(i.value??"");if(a.kind!=="fact"||x(a.value.fields)!==i.value)throw Error(`REFUSE\xB7adoption noncanonical requirement ${i.scope}`);let c=a.value.fields;if(!c.scope||c.value==="withdraw"||["sig","by","epoch","expires","repo"].some(f=>f in c))throw Error(`REFUSE\xB7adoption borrowed history at ${i.scope}`);return{world:e,coordinate:i.scope,line:i.value}}).sort((i,a)=>v(i.coordinate,a.coordinate)||v(i.line,a.line))}s(St,"placeRequirements");var kt=s(e=>/^(0|[1-9][0-9]*)$/.test(e),"resolution"),An=s(e=>{if(!e.form||/[@:\s]/.test(e.form)||!kt(e.resolution))throw Error("REFUSE\xB7shadow incomplete identity declaration");for(let[t,r]of e.projections)if(!kt(t)||!["commitment","shadow"].includes(r))throw Error("REFUSE\xB7shadow invalid projection");if(e.projections.get(e.resolution)!=="shadow")throw Error("REFUSE\xB7shadow resolution does not name the shadow")},"validate");function Ot(e){let t=e.map(u=>{let d=S(u);if(d.kind!=="fact")throw Error("REFUSE\xB7shadow invalid profile line");return d.value.fields}),r=s(u=>{let d=[...new Set(t.filter(l=>l.scope===u&&l.value!=="withdraw").map(l=>l.value))];if(d.length>1)throw Error(`REFUSE\xB7shadow conflicting ${u}`);return d[0]},"own"),n=r("wire/identity/profile");if(n===void 0)return;if(n!=="semantic-standing@1")throw Error("REFUSE\xB7shadow undeclared identity profile");let o=r("wire/identity/form"),i=r("wire/identity/shadow"),a=r("wire/identity/projections");if(!o||/[@:\s]/.test(o)||!i||!kt(i)||!a)throw Error("REFUSE\xB7shadow incomplete identity declaration");let c=new Map;for(let[u,d]of Fe(a)){if(!kt(u)||c.has(u)||!["commitment","shadow"].includes(d))throw Error("REFUSE\xB7shadow invalid or duplicate projection");c.set(u,d)}let f={form:o,resolution:i,projections:c};return An(f),f}s(Ot,"shadowProfile");function Rt(e,t,r,n){An(t);let o=t.projections.get(r);if(o===void 0)throw Error(`REFUSE\xB7shadow undeclared resolution ${r}`);let i=new TextEncoder().encode(ne(e));if(o==="shadow")return{kind:"shadow",bytes:i};let a=n(i);if(!/^[a-z][a-z0-9-]*:[0-9a-f]+$/.test(a))throw Error("REFUSE\xB7shadow invalid declared digest");return{kind:"commitment",identity:`${t.form}@${t.resolution}:${a}`}}s(Rt,"shadowAt");function In(e,t){let r=`${t}/declaration/`,n=e.parts.filter(a=>a.scope?.startsWith(r));if(!n.length)return;let o=e.parts.filter(a=>["wire/capsule-declaration","audit/wire/capsule-declaration"].includes(a.scope??""));if(!o.length||o.some(a=>a.value!=="standing-regions@1"))throw Error(`REFUSE\xB7wire ${t} needs standing-regions@1`);let i=n.map(a=>{let c=a.scope.slice(r.length);if(!c.startsWith("region/")||!["reads","writes"].includes(a.measure??""))throw Error(`REFUSE\xB7topos ${a.scope} is not declared region metadata`);return x({...a,scope:c})});return{lines:i,declaration:Ur(i)}}s(In,"capsuleDescriptor");function jn(e,t){let r=t.filter(n=>{let o=S(n);return o.kind==="fact"&&o.value.fields.scope?.startsWith("region/")&&["reads","writes"].includes(o.value.fields.measure??"")});if(!r.length||pe(e)!==pe(r))throw Error("REFUSE\xB7capsule artifact region contract differs from selected standing")}s(jn,"assertCapsuleDescriptor");function pe(e){if(!e.length)throw Error("REFUSE\xB7topos empty standing");let t=e.map(r=>{let n=S(r,{preserveKeys:!0});if(n.kind!=="fact")throw Error(`REFUSE\xB7topos ${n.why}`);if(n.value.fields.value==="withdraw")throw Error("REFUSE\xB7topos history is not standing");let{sig:o,by:i,epoch:a,expires:c,repo:f,shape:u,...d}=n.value.fields;if(d.needs?.split("|").some(l=>l.startsWith("/")||l.split("/").includes("..")))throw Error("REFUSE\xB7topos host path is not a standing coordinate");return x(d,n.value.version)});return[...new Set(t)].sort(v).join(`
13
- `)+`
14
- `}s(pe,"standingBytes");function Mn(e){let t=e.endsWith(`
7
+ `):[];if(!t.length||be(t)!==e)throw Error("REFUSE\xB7projection bytes are not canonical semantic standing");return t}s(Et,"readSemanticStanding");var Vt=s(e=>typeof e=="string"&&e.length>0,"named"),nt=s(e=>{throw Error("REFUSE\xB7reading identity "+e)},"refuse");function aa(e,t){Array.isArray(e)||nt("missing "+t);let r=new Set;for(let n of e)(!Array.isArray(n)||n.length!==2||!Vt(n[0])||!Vt(n[1]))&&nt("invalid "+t+" reference"),r.has(n[0])&&nt("duplicate "+t+" coordinate "+n[0]),r.add(n[0]);return[...e].sort((n,o)=>w(n[0],o[0]))}s(aa,"references");function ot(e){e||nt("missing context");let t=["instrument","implementation","policy","inputs","environment"];for(let r of Object.keys(e).sort(w))t.includes(r)||nt("undeclared context field "+r);for(let r of["instrument","implementation","policy"])Vt(e[r])||nt("missing "+r);return new TextEncoder().encode(JSON.stringify(["reading-context@1",e.instrument,e.implementation,e.policy,aa(e.inputs,"inputs"),aa(e.environment,"environment")])+`
8
+ `)}s(ot,"readingIdentityBytes");function qr(e,t){return t(ot(e))}s(qr,"readingIdentity");function Yt(e,t){return(!Vt(e)||!Vt(t))&&nt("missing receipt reading or result"),new TextEncoder().encode(JSON.stringify(["reading-receipt@1",e,t])+`
9
+ `)}s(Yt,"readingReceiptBytes");function Dr(e,t,r){return r(Yt(e,t))}s(Dr,"readingReceiptIdentity");function zr(e,t,r,n,o){let i=e.parts.filter(p=>p.scope===`${t}/place-inputs/${r}`&&p.measure==="reads");if(!i.length)return;let a=e.parts.filter(p=>p.scope==="wire/place-inputs");if(a.length!==1||a[0].role!=="writes"||a[0].measure!=="id"||a[0].value!=="admitted-place-inputs@1")throw Error("REFUSE\xB7place inputs missing or conflicting profile "+t);let c=n.length?be(n).trimEnd().split(`
10
+ `):[],l=new Set;for(let p of i){if(p.role!=="reads"&&p.role!=="demands")throw Error("REFUSE\xB7place inputs invalid selector role "+p.scope);let h=(p.value??"").split("|").filter(Boolean);if(!h.length)throw Error("REFUSE\xB7place inputs empty selector "+p.scope);let g=c.filter(m=>{let y=x(m);return y.kind==="fact"&&h.some(b=>ee(b,y.value.fields.scope??""))});if(p.role==="demands"&&!g.length)throw Error("REFUSE\xB7place inputs required member absent "+p.scope);for(let m of g)l.add(m)}let f=c.filter(p=>l.has(p)),u=be(i.map(p=>v(p))).trimEnd().split(`
11
+ `),d=new TextEncoder().encode(JSON.stringify(["admitted-place-inputs@1",u,f])+`
12
+ `);return{profile:"admitted-place-inputs@1",digest:o(d),selectors:u,lines:f}}s(zr,"placeInputs");function Wr(e,t,r){let n={...e,inputs:[...e.inputs,[t,r.digest]]};return ot(n),n}s(Wr,"withPlaceInputs");var Jr=s(e=>typeof e=="string"&&/^(?:[^\s:@]+@[0-9]+:)?[a-z][a-z0-9-]*:[0-9a-f]+$/.test(e),"digest");function Hr(e){let t;try{t=JSON.parse(e)}catch{throw Error("REFUSE\xB7release invalid delivery metadata")}if(!t||typeof t!="object"||Array.isArray(t))throw Error("REFUSE\xB7release missing delivery record");let r=t;if(Object.keys(r).some(n=>!["standing","blob","predecessor"].includes(n))||!Jr(r.standing)||!Jr(r.blob)||r.predecessor!==void 0&&!Jr(r.predecessor))throw Error("REFUSE\xB7release invalid delivery digests or fields");return{standing:r.standing,blob:r.blob,...r.predecessor===void 0?{}:{predecessor:r.predecessor}}}s(Hr,"readReleaseDelivery");function Gr(e,t){if(!Jr(e))throw Error("REFUSE\xB7adoption missing selected standing digest");let r=[...new Set(t)].map(i=>{let a=x(i);if(a.kind!=="fact")throw Error("REFUSE\xB7adoption invalid standing line");return a.value.fields}),n=r.filter(i=>i.scope==="wire/adoption/profile"),o=r.filter(i=>i.scope?.startsWith("needs/place/"));if(!n.length){if(o.length)throw Error("REFUSE\xB7adoption requirements have no declared profile");return[]}if(n.some(i=>i.value!=="place-requirements@1"))throw Error("REFUSE\xB7adoption conflicting or unsupported profile");return o.map(i=>{if(i.role!=="demands"||i.measure!=="line"||!i.scope.slice(12))throw Error(`REFUSE\xB7adoption invalid requirement ${i.scope}`);let a=x(i.value??"");if(a.kind!=="fact"||v(a.value.fields)!==i.value)throw Error(`REFUSE\xB7adoption noncanonical requirement ${i.scope}`);let c=a.value.fields;if(!c.scope||c.value==="withdraw"||["sig","by","epoch","expires","repo"].some(l=>l in c))throw Error(`REFUSE\xB7adoption borrowed history at ${i.scope}`);return{world:e,coordinate:i.scope,line:i.value}}).sort((i,a)=>w(i.coordinate,a.coordinate)||w(i.line,a.line))}s(Gr,"placeRequirements");var Kr=s(e=>/^(0|[1-9][0-9]*)$/.test(e),"resolution"),ca=s(e=>{if(!e.form||/[@:\s]/.test(e.form)||!Kr(e.resolution))throw Error("REFUSE\xB7shadow incomplete identity declaration");for(let[t,r]of e.projections)if(!Kr(t)||!["commitment","shadow"].includes(r))throw Error("REFUSE\xB7shadow invalid projection");if(e.projections.get(e.resolution)!=="shadow")throw Error("REFUSE\xB7shadow resolution does not name the shadow")},"validate");function Vr(e){let t=e.map(f=>{let u=x(f);if(u.kind!=="fact")throw Error("REFUSE\xB7shadow invalid profile line");return u.value.fields}),r=s(f=>{let u=[...new Set(t.filter(d=>d.scope===f&&d.value!=="withdraw").map(d=>d.value))];if(u.length>1)throw Error(`REFUSE\xB7shadow conflicting ${f}`);return u[0]},"own"),n=r("wire/identity/profile");if(n===void 0)return;if(n!=="semantic-standing@1")throw Error("REFUSE\xB7shadow undeclared identity profile");let o=r("wire/identity/form"),i=r("wire/identity/shadow"),a=r("wire/identity/projections");if(!o||/[@:\s]/.test(o)||!i||!Kr(i)||!a)throw Error("REFUSE\xB7shadow incomplete identity declaration");let c=new Map;for(let[f,u]of wt(a)){if(!Kr(f)||c.has(f)||!["commitment","shadow"].includes(u))throw Error("REFUSE\xB7shadow invalid or duplicate projection");c.set(f,u)}let l={form:o,resolution:i,projections:c};return ca(l),l}s(Vr,"shadowProfile");function Yr(e,t,r,n){ca(t);let o=t.projections.get(r);if(o===void 0)throw Error(`REFUSE\xB7shadow undeclared resolution ${r}`);let i=new TextEncoder().encode(be(e));if(o==="shadow")return{kind:"shadow",bytes:i};let a=n(i);if(!/^[a-z][a-z0-9-]*:[0-9a-f]+$/.test(a))throw Error("REFUSE\xB7shadow invalid declared digest");return{kind:"commitment",identity:`${t.form}@${t.resolution}:${a}`}}s(Yr,"shadowAt");function la(e,t){let r=`${t}/declaration/`,n=e.parts.filter(a=>a.scope?.startsWith(r));if(!n.length)return;let o=e.parts.filter(a=>["wire/capsule-declaration","audit/wire/capsule-declaration"].includes(a.scope??""));if(!o.length||o.some(a=>a.value!=="standing-regions@1"))throw Error(`REFUSE\xB7wire ${t} needs standing-regions@1`);let i=n.map(a=>{let c=a.scope.slice(r.length);if(!c.startsWith("region/")||!["reads","writes"].includes(a.measure??""))throw Error(`REFUSE\xB7topos ${a.scope} is not declared region metadata`);return v({...a,scope:c})});return{lines:i,declaration:Qo(i)}}s(la,"capsuleDescriptor");function da(e,t){let r=t.filter(n=>{let o=x(n);return o.kind==="fact"&&o.value.fields.scope?.startsWith("region/")&&["reads","writes"].includes(o.value.fields.measure??"")});if(!r.length||Je(e)!==Je(r))throw Error("REFUSE\xB7capsule artifact region contract differs from selected standing")}s(da,"assertCapsuleDescriptor");function Je(e){if(!e.length)throw Error("REFUSE\xB7topos empty standing");let t=e.map(r=>{let n=x(r,{preserveKeys:!0});if(n.kind!=="fact")throw Error(`REFUSE\xB7topos ${n.why}`);if(n.value.fields.value==="withdraw")throw Error("REFUSE\xB7topos history is not standing");let{sig:o,by:i,epoch:a,expires:c,repo:l,shape:f,...u}=n.value.fields;if(u.needs?.split("|").some(d=>d.startsWith("/")||d.split("/").includes("..")))throw Error("REFUSE\xB7topos host path is not a standing coordinate");return v(u,n.value.version)});return[...new Set(t)].sort(w).join(`
13
+ `)+`
14
+ `}s(Je,"standingBytes");function ua(e){let t=e.endsWith(`
15
15
  `)?e.slice(0,-1).split(`
16
- `):[];if(!t.length||pe(t)!==e)throw Error("REFUSE\xB7topos bytes are not canonical standing");let r=t.map(o=>{let i=S(o,{preserveKeys:!0});if(i.kind!=="fact")throw Error(`REFUSE\xB7topos ${i.why}`);return i.value.fields}),n=[...new Set(r.flatMap(o=>(o.restsOn??"").split("|").filter(Boolean)))].sort(v);for(let o of r)if(o.kind&&o.measure==="digest"&&!(o.restsOn??"").split("|").includes(o.value??""))throw Error(`REFUSE\xB7topos ${o.scope} missing required restsOn for digest offer`);return{lines:t,parts:r,dependencies:n}}s(Mn,"readStanding");function es(e){let t=e.map(a=>{let c=S(a);if(c.kind!=="fact")throw Error(`REFUSE\xB7topos ${c.why}`);return{line:a,fields:c.value.fields}}),r=t.filter(({fields:a})=>a.scope?.startsWith("region/")&&a.measure==="reads");if(!r.length)return;let n=r.flatMap(({fields:a})=>(a.value??"").split("|").filter(Boolean));if(!n.length)throw Error("REFUSE\xB7topos no declared regions");let o=t.filter(a=>r.includes(a)||n.some(c=>T(c,a.fields.scope??""))),i=pe(o.map(a=>a.line));return Mn(i),i}s(es,"toposStanding");function ts(e){return e.parts.filter(t=>t.kind==="capsule").map(t=>{if(t.measure!=="digest"||!t.value||!(t.restsOn??"").split("|").includes(t.value))throw Error(`REFUSE\xB7topos ${t.scope??""} capsule needs measure=digest and an explicit artifact in restsOn`);return t})}s(ts,"capsuleOffers");function Un(e,t){let r=`${t}/inputs/`;return[...new Set(e.parts.filter(n=>n.scope?.startsWith(r)&&n.measure==="reads").map(n=>n.scope.slice(r.length)))].sort(v)}s(Un,"providerInputRegions");function Nn(e,t,r,n,o,i){let a=e.parts.filter(l=>l.scope===`${r}/inputs/${o}`&&l.measure==="reads");if(!a.length)return;let c=e.parts.filter(l=>l.scope==="wire/provider-inputs"||l.scope==="audit/wire/provider-inputs");if(!c.length||c.some(l=>l.value!=="standing-projection@1"))throw Error(`REFUSE\xB7wire ${r} provider inputs need standing-projection@1`);let f=new Set;for(let l of a){if(l.role!=="reads"&&l.role!=="demands")throw Error(`REFUSE\xB7input ${l.scope} needs a declared reads or demands role`);let p=(l.value??"").split("|").filter(Boolean);if(!p.length)throw Error(`REFUSE\xB7input ${l.scope} has no selector`);let m=e.lines.filter(g=>{let h=S(g);return h.kind==="fact"&&p.some(y=>T(y,h.value.fields.scope??""))});if(l.role==="demands"&&!m.length)throw Error(`REFUSE\xB7input ${l.scope} selects no required standing member`);for(let g of m)f.add(g)}let u=f.size?pe([...f]):"",d=u?u.trimEnd().split(`
17
- `).sort(v):[];return{standing:t,artifact:n,digest:i(u),lines:d}}s(Nn,"providerInputs");function _t(e){let t=e.lines.map(r=>{let n=S(r);if(n.kind!=="fact"||x(n.value.fields)!==r)throw Error("REFUSE\xB7input provider projection is not canonical");return n.value.fields});return{...e,lines:t}}s(_t,"providerFields");var $t=s(e=>{let t=S(e,{preserveKeys:!0});if(t.kind!=="fact"||x(t.value.fields,t.value.version)!==e)throw Error("REFUSE\xB7reading noncanonical line");return t.value.fields},"fieldsOf");function Ft(e){let t=new Map,r=new Map;for(let o of e){if(!o.world||!o.region)throw Error("REFUSE\xB7reading missing world or region attribution");for(let i of o.lines){let a=$t(i),c=t.get(i)??new Set;c.add(o.world),t.set(i,c);let f=x({region:o.region,scope:a.scope??"",role:a.role??"",measure:a.measure??""}),u=r.get(f)??new Set;u.add(i),r.set(f,u)}}let n=[...t.keys()].sort(v);return{lines:n,attribution:n.map(o=>({line:o,worlds:[...t.get(o)].sort(v)})),disagreements:[...r].flatMap(([o,i])=>new Set([...i].map(c=>{let f=$t(c);return x({form:f.form??"",value:f.value??"",kind:f.kind??""})})).size>1?[{coordinate:o,lines:[...i].sort(v)}]:[]).sort((o,i)=>v(o.coordinate,i.coordinate))}}s(Ft,"unionReadings");function At(e,t){let r=[...new Set(t)];if(!e||r.length!==1||!r[0])throw Error(`REFUSE\xB7render ${e||"(absent)"} needs one writer`);return r[0]}s(At,"renderWriter");function It(e,t){let r=[],n=[],o=[];for(let c of new Set(e)){$t(c);let f=t.classification(c);(f==="local"?r:f==="foreign"?n:o).push(c)}let i=t.fold(r),a=new Set(r);if(i.some(c=>!a.has(c)))throw Error("REFUSE\xB7evidence fold returned an unauthenticated inscription");return{standing:i.filter(c=>$t(c).value!=="withdraw"),history:r,foreign:n,unadmitted:o}}s(It,"foldedEvidence");var Cn=s(e=>{for(let t of["source","content","observed","clock","implementation"])if(!e[t])throw Error(`REFUSE\xB7snapshot missing ${t}`);if(e.freshness!==void 0&&!e.freshness)throw Error("REFUSE\xB7snapshot empty freshness declaration")},"requireSnapshot");function Ie(e,t){return Cn(e),t(x({scope:e.source,role:"writes",form:"alphabet",measure:"snapshot",value:e.content,at:e.observed,clock:e.clock,...e.freshness===void 0?{}:{freshness:e.freshness},implementation:e.implementation})+`
18
- `)}s(Ie,"snapshotIdentity");function jt(e,t,r){if(t.snapshot!==Ie(e,r))throw Error("REFUSE\xB7snapshot response names another snapshot");for(let n of["principal","authorization","implementation","snapshot","request"])if(!t[n])throw Error(`REFUSE\xB7snapshot missing response ${n}`);if(t.implementation!==e.implementation)throw Error("REFUSE\xB7snapshot response names another implementation");return r(x({principal:t.principal,authorization:t.authorization,implementation:t.implementation,snapshot:t.snapshot,request:t.request})+`
19
- `)}s(jt,"responseIdentity");function Mt(e,t,r,n,o){Cn(e);for(let i of[t,r])for(let a of["principal","authorization","implementation","snapshot","request"])if(!i[a])throw Error(`REFUSE\xB7snapshot missing response ${a}`);return{inspect:n.inspect,reuse:n.reuse&&e.freshness!==void 0&&n.freshness==="fresh"&&t.principal===r.principal&&t.authorization===r.authorization&&t.implementation===r.implementation&&e.implementation===r.implementation&&t.snapshot===r.snapshot&&r.snapshot===Ie(e,o)&&t.request===r.request}}s(Mt,"snapshotAccess");function Ut(e,t){let r=e.flatMap(i=>{let a=S(i);return a.kind==="fact"?[a.value.fields]:[]}).filter(i=>i.scope===t&&i.role==="writes"&&i.value!=="withdraw"&&["origin","coordinates","leaves"].includes(i.measure??"")),n=r.filter(i=>i.measure==="origin");if(!n.length)return;let o=new Set(n.map(i=>i.value));if(r.length!==n.length||o.size!==1||!n[0]?.value)throw Error(`REFUSE\xB7region ${t} conflicting origin projection`);return{source:n[0].value}}s(Ut,"originRegion");function Nt(e,t){if(!t.admitsDeclaration(e))throw Error(`REFUSE\xB7port ${e.coordinate||"(absent)"} declaration not admitted`);if(!e.coordinate.startsWith("port/")||!t.covers(e.coordinate))throw Error(`REFUSE\xB7port ${e.coordinate||"(absent)"} not covered`);if(!e.implementation||!e.closure.includes(e.implementation)||!e.closure.length||e.closure.some(r=>!t.verifies(r)))throw Error(`REFUSE\xB7port ${e.coordinate} unverified executable closure`);for(let[r,n]of[["timeout",e.timeoutMs],["response-bytes",e.responseBytes]])if(!Number.isSafeInteger(n)||n<=0)throw Error(`REFUSE\xB7port ${e.coordinate} invalid ${r}`);if(!["reject","retain"].includes(e.stderr)||e.environment.some(r=>!r||/[=\0]/.test(r)))throw Error(`REFUSE\xB7port ${e.coordinate} invalid environment or stderr policy`)}s(Nt,"checkCommandPort");function Xe(e,t){if(!t.identity||!t.requests.length||t.requests.some(r=>typeof r!="string"))throw Error(`REFUSE\xB7port ${e.coordinate} empty, invalid or unnamed lot`);return JSON.stringify({protocol:"command-lot/1",coordinate:e.coordinate,implementation:e.implementation,identity:t.identity,requests:t.requests})+`
20
- `}s(Xe,"commandRequest");function Ct(e,t,r,n){if(Xe(e,t),r.interrupted||r.status!==0)throw Error(`REFUSE\xB7port ${e.coordinate} ${r.interrupted?"interrupted":`status ${r.status}`}`);if(e.stderr==="reject"&&r.stderr)throw Error(`REFUSE\xB7port ${e.coordinate} stderr forbidden`);if(new TextEncoder().encode(r.stdout).length>e.responseBytes)throw Error(`REFUSE\xB7port ${e.coordinate} response-bytes exceeded`);if(!r.stdout.endsWith(`
16
+ `):[];if(!t.length||Je(t)!==e)throw Error("REFUSE\xB7topos bytes are not canonical standing");let r=t.map(o=>{let i=x(o,{preserveKeys:!0});if(i.kind!=="fact")throw Error(`REFUSE\xB7topos ${i.why}`);return i.value.fields}),n=[...new Set(r.flatMap(o=>(o.restsOn??"").split("|").filter(Boolean)))].sort(w);for(let o of r)if(o.kind&&o.measure==="digest"&&!(o.restsOn??"").split("|").includes(o.value??""))throw Error(`REFUSE\xB7topos ${o.scope} missing required restsOn for digest offer`);return{lines:t,parts:r,dependencies:n}}s(ua,"readStanding");function Yl(e){let t=e.map(a=>{let c=x(a);if(c.kind!=="fact")throw Error(`REFUSE\xB7topos ${c.why}`);return{line:a,fields:c.value.fields}}),r=t.filter(({fields:a})=>a.scope?.startsWith("region/")&&a.measure==="reads");if(!r.length)return;let n=r.flatMap(({fields:a})=>(a.value??"").split("|").filter(Boolean));if(!n.length)throw Error("REFUSE\xB7topos no declared regions");let o=t.filter(a=>r.includes(a)||n.some(c=>ee(c,a.fields.scope??""))),i=Je(o.map(a=>a.line));return ua(i),i}s(Yl,"toposStanding");function Xl(e){return e.parts.filter(t=>t.kind==="capsule").map(t=>{if(t.measure!=="digest"||!t.value||!(t.restsOn??"").split("|").includes(t.value))throw Error(`REFUSE\xB7topos ${t.scope??""} capsule needs measure=digest and an explicit artifact in restsOn`);return t})}s(Xl,"capsuleOffers");function fa(e,t){let r=`${t}/inputs/`;return[...new Set(e.parts.filter(n=>n.scope?.startsWith(r)&&n.measure==="reads").map(n=>n.scope.slice(r.length)))].sort(w)}s(fa,"providerInputRegions");function pa(e,t,r,n,o,i){let a=e.parts.filter(d=>d.scope===`${r}/inputs/${o}`&&d.measure==="reads");if(!a.length)return;let c=e.parts.filter(d=>d.scope==="wire/provider-inputs"||d.scope==="audit/wire/provider-inputs");if(!c.length||c.some(d=>d.value!=="standing-projection@1"))throw Error(`REFUSE\xB7wire ${r} provider inputs need standing-projection@1`);let l=new Set;for(let d of a){if(d.role!=="reads"&&d.role!=="demands")throw Error(`REFUSE\xB7input ${d.scope} needs a declared reads or demands role`);let p=(d.value??"").split("|").filter(Boolean);if(!p.length)throw Error(`REFUSE\xB7input ${d.scope} has no selector`);let h=e.lines.filter(g=>{let m=x(g);return m.kind==="fact"&&p.some(y=>ee(y,m.value.fields.scope??""))});if(d.role==="demands"&&!h.length)throw Error(`REFUSE\xB7input ${d.scope} selects no required standing member`);for(let g of h)l.add(g)}let f=l.size?Je([...l]):"",u=f?f.trimEnd().split(`
17
+ `).sort(w):[];return{standing:t,artifact:n,digest:i(f),lines:u}}s(pa,"providerInputs");function Xr(e){let t=e.lines.map(r=>{let n=x(r);if(n.kind!=="fact"||v(n.value.fields)!==r)throw Error("REFUSE\xB7input provider projection is not canonical");return n.value.fields});return{...e,lines:t}}s(Xr,"providerFields");var Qr=s(e=>{let t=x(e,{preserveKeys:!0});if(t.kind!=="fact"||v(t.value.fields,t.value.version)!==e)throw Error("REFUSE\xB7reading noncanonical line");return t.value.fields},"fieldsOf");function Zr(e){let t=new Map,r=new Map;for(let o of e){if(!o.world||!o.region)throw Error("REFUSE\xB7reading missing world or region attribution");for(let i of o.lines){let a=Qr(i),c=t.get(i)??new Set;c.add(o.world),t.set(i,c);let l=v({region:o.region,scope:a.scope??"",role:a.role??"",measure:a.measure??""}),f=r.get(l)??new Set;f.add(i),r.set(l,f)}}let n=[...t.keys()].sort(w);return{lines:n,attribution:n.map(o=>({line:o,worlds:[...t.get(o)].sort(w)})),disagreements:[...r].flatMap(([o,i])=>new Set([...i].map(c=>{let l=Qr(c);return v({form:l.form??"",value:l.value??"",kind:l.kind??""})})).size>1?[{coordinate:o,lines:[...i].sort(w)}]:[]).sort((o,i)=>w(o.coordinate,i.coordinate))}}s(Zr,"unionReadings");function en(e,t){let r=[...new Set(t)];if(!e||r.length!==1||!r[0])throw Error(`REFUSE\xB7render ${e||"(absent)"} needs one writer`);return r[0]}s(en,"renderWriter");function tn(e,t){let r=[],n=[],o=[];for(let c of new Set(e)){Qr(c);let l=t.classification(c);(l==="local"?r:l==="foreign"?n:o).push(c)}let i=t.fold(r),a=new Set(r);if(i.some(c=>!a.has(c)))throw Error("REFUSE\xB7evidence fold returned an unauthenticated inscription");return{standing:i.filter(c=>Qr(c).value!=="withdraw"),history:r,foreign:n,unadmitted:o}}s(tn,"foldedEvidence");var ma=s(e=>{for(let t of["source","content","observed","clock","implementation"])if(!e[t])throw Error(`REFUSE\xB7snapshot missing ${t}`);if(e.freshness!==void 0&&!e.freshness)throw Error("REFUSE\xB7snapshot empty freshness declaration")},"requireSnapshot");function xt(e,t){return ma(e),t(v({scope:e.source,role:"writes",form:"alphabet",measure:"snapshot",value:e.content,at:e.observed,clock:e.clock,...e.freshness===void 0?{}:{freshness:e.freshness},implementation:e.implementation})+`
18
+ `)}s(xt,"snapshotIdentity");function rn(e,t,r){if(t.snapshot!==xt(e,r))throw Error("REFUSE\xB7snapshot response names another snapshot");for(let n of["principal","authorization","implementation","snapshot","request"])if(!t[n])throw Error(`REFUSE\xB7snapshot missing response ${n}`);if(t.implementation!==e.implementation)throw Error("REFUSE\xB7snapshot response names another implementation");return r(v({principal:t.principal,authorization:t.authorization,implementation:t.implementation,snapshot:t.snapshot,request:t.request})+`
19
+ `)}s(rn,"responseIdentity");function nn(e,t,r,n,o){ma(e);for(let i of[t,r])for(let a of["principal","authorization","implementation","snapshot","request"])if(!i[a])throw Error(`REFUSE\xB7snapshot missing response ${a}`);return{inspect:n.inspect,reuse:n.reuse&&e.freshness!==void 0&&n.freshness==="fresh"&&t.principal===r.principal&&t.authorization===r.authorization&&t.implementation===r.implementation&&e.implementation===r.implementation&&t.snapshot===r.snapshot&&r.snapshot===xt(e,o)&&t.request===r.request}}s(nn,"snapshotAccess");function on(e,t){let r=e.flatMap(i=>{let a=x(i);return a.kind==="fact"?[a.value.fields]:[]}).filter(i=>i.scope===t&&i.role==="writes"&&i.value!=="withdraw"&&["origin","coordinates","leaves"].includes(i.measure??"")),n=r.filter(i=>i.measure==="origin");if(!n.length)return;let o=new Set(n.map(i=>i.value));if(r.length!==n.length||o.size!==1||!n[0]?.value)throw Error(`REFUSE\xB7region ${t} conflicting origin projection`);return{source:n[0].value}}s(on,"originRegion");function sn(e,t){if(!t.admitsDeclaration(e))throw Error(`REFUSE\xB7port ${e.coordinate||"(absent)"} declaration not admitted`);if(!e.coordinate.startsWith("port/")||!t.covers(e.coordinate))throw Error(`REFUSE\xB7port ${e.coordinate||"(absent)"} not covered`);if(!e.implementation||!e.closure.includes(e.implementation)||!e.closure.length||e.closure.some(r=>!t.verifies(r)))throw Error(`REFUSE\xB7port ${e.coordinate} unverified executable closure`);for(let[r,n]of[["timeout",e.timeoutMs],["response-bytes",e.responseBytes]])if(!Number.isSafeInteger(n)||n<=0)throw Error(`REFUSE\xB7port ${e.coordinate} invalid ${r}`);if(!["reject","retain"].includes(e.stderr)||e.environment.some(r=>!r||/[=\0]/.test(r)))throw Error(`REFUSE\xB7port ${e.coordinate} invalid environment or stderr policy`)}s(sn,"checkCommandPort");function Xt(e,t){if(!t.identity||!t.requests.length||t.requests.some(r=>typeof r!="string"))throw Error(`REFUSE\xB7port ${e.coordinate} empty, invalid or unnamed lot`);return JSON.stringify({protocol:"command-lot/1",coordinate:e.coordinate,implementation:e.implementation,identity:t.identity,requests:t.requests})+`
20
+ `}s(Xt,"commandRequest");function an(e,t,r,n){if(Xt(e,t),r.interrupted||r.status!==0)throw Error(`REFUSE\xB7port ${e.coordinate} ${r.interrupted?"interrupted":`status ${r.status}`}`);if(e.stderr==="reject"&&r.stderr)throw Error(`REFUSE\xB7port ${e.coordinate} stderr forbidden`);if(new TextEncoder().encode(r.stdout).length>e.responseBytes)throw Error(`REFUSE\xB7port ${e.coordinate} response-bytes exceeded`);if(!r.stdout.endsWith(`
21
21
  `)||r.stdout.slice(0,-1).includes(`
22
- `))throw Error(`REFUSE\xB7port ${e.coordinate} incomplete response frame`);let o;try{o=JSON.parse(r.stdout)}catch{throw Error(`REFUSE\xB7port ${e.coordinate} invalid response frame`)}if(!o||o.protocol!=="command-lot/1"||o.coordinate!==e.coordinate||o.implementation!==e.implementation||o.identity!==t.identity||!Array.isArray(o.responses)||o.responses.length!==t.requests.length)throw Error(`REFUSE\xB7port ${e.coordinate} response does not bind this lot`);if(o.responses.some((i,a)=>!n(i,a)))throw Error(`REFUSE\xB7port ${e.coordinate} invalid response member`);return o.responses}s(Ct,"commandResponse");function Bt(e,t){if(!e.coordinate)throw Error("REFUSE\xB7policy missing field coordinate");if(!["meet","exact","own"].includes(e.mode))throw Error(`REFUSE\xB7policy ${e.coordinate} undeclared composition`);let r=t.filter((a,c)=>t.findIndex(f=>f.source===a.source&&f.value===a.value&&f.own===a.own)===c);if(!r.length)return{kind:"unread",evidence:[]};if(r.some(a=>!a.source))throw Error(`REFUSE\xB7policy ${e.coordinate} missing attribution`);let n=r.filter(a=>a.own),o=e.mode==="own"&&n.length?n:r;if(e.mode!=="meet"){if(new Set(o.map(c=>c.value)).size!==1)return{kind:"incompatible",evidence:r};let a=e.decode(o[0].value);return{kind:e.inhabited(a)?"compatible":"incompatible",value:a,evidence:r}}let i=o.map(a=>e.decode(a.value)).reduce((a,c)=>e.lattice.meet(a,c));return{kind:e.inhabited(i)?"compatible":"incompatible",value:i,evidence:r}}s(Bt,"composePolicy");function Tt(e,t,r){if(e.mode!=="meet")return"non-meet";if(!e.inhabited(r))return"incompatible";let n=e.lattice.leq;return n(t,r)&&n(r,t)?"compatible":n(r,t)?"narrowing":"widening-needs-authority"}s(Tt,"policyTransition");function Pt(e,t,r){if(!e)throw Error("REFUSE\xB7lineage missing current release");let n=new Map;for(let o of t){if(!o.digest||!o.predecessor||!r(o))throw Error("REFUSE\xB7lineage unauthenticated release");let i=n.get(o.digest);if(i&&i.predecessor!==o.predecessor)throw Error(`REFUSE\xB7lineage ${o.digest} conflicting predecessor`);n.set(o.digest,o)}for(let o of n.keys()){let i=new Set,a=o;for(;a&&n.has(a);){if(i.has(a))throw Error(`REFUSE\xB7lineage ${o} predecessor cycle`);i.add(a),a=n.get(a).predecessor}}return[...n.values()].filter(o=>o.predecessor===e&&o.digest!==e).sort((o,i)=>v(o.digest,i.digest))}s(Pt,"releaseSuccessors");function qt(e,t){let r=new Map;for(let c of e){if(!c.digest||c.bytes!==null&&(!Number.isSafeInteger(c.bytes)||c.bytes<0))throw Error("REFUSE\xB7weight invalid verified byte reading");let f=r.get(c.digest);if(f&&f.bytes!==c.bytes)throw Error(`REFUSE\xB7weight ${c.digest} conflicting byte reading`);r.set(c.digest,{...c,named:c.named||(f?.named??!1)})}let n=[...r.values()],o=n.reduce((c,f)=>c+(f.bytes??0),0);if(!Number.isSafeInteger(o))throw Error("REFUSE\xB7weight byte sum exceeds exact range");let i=t&&n.every(c=>c.bytes!==null);return{unit:"bytes",known:i||n.some(c=>c.bytes!==null)?o:null,total:i?o:null,unreferenced:i?n.filter(c=>!c.named).reduce((c,f)=>c+f.bytes,0):null}}s(qt,"weightOf");function Wt(e,t,r,n){if(!Number.isSafeInteger(e)||e<0||!Number.isSafeInteger(t)||t<=0||r.some(i=>!Number.isSafeInteger(i)||i<0||i>e))throw Error("REFUSE\xB7vacuous invalid declared epoch window");let o=Math.max(0,e-t+1);return{unit:"epochs",from:o,through:e,reading:r.some(i=>i>=o)?"observed":n?"unobserved":"unknown"}}s(Wt,"vacuityOf");function Dt(e,t){let r=new Set(t);for(let n of e)if(!n||!r.has(n))throw Error(`REFUSE\xB7inspection unknown coordinate ${n||"(absent)"}`);return[...new Set(e)].sort(v)}s(Dt,"inspectionSelection");function zt(e){let t=s(d=>{throw Error("REFUSE\xB7program "+d)},"fail"),r=s((d,l)=>{(d.some(p=>!p)||new Set(d).size!==d.length)&&t("duplicate or empty "+l)},"unique");e.minimum.length||t("minimum is absent; vacuity cannot close a program"),r(e.minimum,"minimum coordinate");for(let[d,l]of e.evidence)(!d||!["met","unmet","unread","refused"].includes(l))&&t("unsupported evidence status "+d);let n=new Map;for(let d of e.programs)(!d.scope||n.has(d.scope))&&t("duplicate or empty coordinate "+d.scope),r(d.needs,"requirement at "+d.scope),r(d.restsOn,"dependency at "+d.scope),n.set(d.scope,d);for(let d of e.minimum)n.has(d)||t("unknown minimum "+d);let o=new Map,i=[];for(let d of[...n.keys()].sort(v)){let l=[{scope:d,exit:!1}];for(;l.length;){let p=l.pop();if(p.exit){o.set(p.scope,2),i.push(p.scope);continue}if(o.get(p.scope)===2)continue;o.get(p.scope)===1&&t("dependency cycle "+p.scope);let m=n.get(p.scope);m||t("unknown dependency "+p.scope),o.set(p.scope,1),l.push({...p,exit:!0});for(let g of[...m.restsOn].sort(v).reverse())l.push({scope:g,exit:!1})}}for(let[d,l]of[["elapsed",e.elapsed],["ceiling",e.ceiling]])l!==void 0&&(!Number.isFinite(l)||l<0)&&t("invalid "+d+" reading");let a=e.elapsed===void 0||e.ceiling===void 0?"unread":e.elapsed>e.ceiling?"over":"within",c=new Set(e.minimum),f=new Map,u=i.map(d=>{let l=n.get(d),p=l.restsOn.filter(y=>f.get(y)!=="met").sort(v),m=l.needs.filter(y=>["unmet","refused"].includes(e.evidence.get(y)??"")).sort(v),g=l.needs.filter(y=>!e.evidence.has(y)||e.evidence.get(y)==="unread").sort(v),h=p.length?"blocked":m.length?"unmet":g.length||!l.needs.length?"unread":"met";return f.set(d,h),{scope:d,status:h,blocked:p,missing:m,unread:g,carry:a==="over"&&!c.has(d)&&h!=="met"}});return{deadline:a,rows:u,next:u.filter(d=>d.status!=="met"&&!d.blocked.length&&!d.carry).map(d=>d.scope),closed:e.minimum.every(d=>f.get(d)==="met")}}s(zt,"programsOf");var F=class e extends Error{static{s(this,"UnitError")}code;detail;constructor(t,r,n={}){super(r),this.name="UnitError",this.code=t,this.detail=Object.freeze({...n}),Object.setPrototypeOf(this,e.prototype)}};function Bn(e,t,r){let n=e.length;for(let h=0;h<n;h++)if(e.indexOf(e[h])!==h)throw new F("DUPLICATE_LEVEL",`the level \`${e[h]}\` is declared twice`,{level:e[h]});let o=new Map(e.map((h,y)=>[h,y])),i=s((h,y)=>t[h][y]===y,"leq"),a=e.every((h,y)=>e.every((b,O)=>t[y][O]===y||t[y][O]===O)),c=!0;for(let h=0;h<n&&c;h++)for(let y=0;y<n&&c;y++)for(let b=0;b<n;b++)if(r[h][t[y][b]]!==t[r[h][y]][r[h][b]]){c=!1;break}let f=[...e.keys()],u=f.find(h=>f.every(y=>i(h,y)))??0,d=f.find(h=>f.every(y=>i(y,h)))??n-1,l=f.filter(h=>h!==u&&f.filter(y=>y!==h&&i(y,h)).reduce((y,b)=>t[y][b],u)!==h),p=f.filter(h=>h!==d&&f.filter(y=>y!==h&&i(h,y)).reduce((y,b)=>r[y][b],d)!==h),m=new Set,g=[];for(let h of[...l,...p])m.has(h)||(m.add(h),g.push(h));return{levels:e,isLadder:a,isSimple:c,bottomIx:u,topIx:d,bottom:e[u],top:e[d],leq:i,higher:s((h,y)=>t[h][y],"higher"),lower:s((h,y)=>r[h][y],"lower"),rank(h){let y=o.get(h);if(y===void 0)throw new F("UNKNOWN_LEVEL",`no level \`${h}\` in this scale`,{level:h,levels:e});return y},stateOf(h,y){return i(h,y)?h!==u?"REQUIRED":y!==d?"FORBIDDEN":"FREE":"CONFLICT"},joins:s(()=>l.slice(),"joins"),limits:s(()=>p.slice(),"limits"),debits:s(()=>g.slice(),"debits"),intervalHeight(h,y){if(!i(h,y))return null;let b=f.filter(j=>i(h,j)&&i(j,y)),O=s(j=>b.filter(k=>k!==j&&i(j,k)&&!b.some(I=>I!==j&&I!==k&&i(j,I)&&i(I,k))),"covers"),W=new Map([[h,0]]),B=new Map([[h,0]]),ye=[...b].sort((j,k)=>b.filter(I=>i(I,j)).length-b.filter(I=>i(I,k)).length);for(let j of ye){let k=W.get(j),I=B.get(j);if(!(k===void 0||I===void 0))for(let at of O(j))W.set(at,Math.max(W.get(at)??k+1,k+1)),B.set(at,Math.min(B.get(at)??I+1,I+1))}let _e=W.get(y);return _e!==void 0&&_e===B.get(y)?_e:null}}}s(Bn,"build");function Qe(e){if(!Array.isArray(e)||e.length===0)throw new F("EMPTY_CHAIN","a chain needs at least one level");let t=e.length,r=s(n=>[...Array(t)].map((o,i)=>[...Array(t)].map((a,c)=>n(i,c))),"grid");return Bn(e,r(Math.max),r(Math.min))}s(Qe,"chain");function Tn(e,t){if(!Array.isArray(e)||e.length===0)throw new F("EMPTY_CHAIN","an order needs at least one level");let r=e.length,n=s((i,a,c)=>{let f=[...Array(r).keys()].filter(d=>c?t[i][d]&&t[a][d]:t[d][i]&&t[d][a]),u=f.filter(d=>f.every(l=>c?t[d][l]:t[l][d]));if(u.length!==1)throw new F("MALFORMED",`\`${e[i]}\` and \`${e[a]}\` have ${u.length} ${c?"lowest common":"highest common"} bounds, so this is not a usable scale`,{levels:[e[i],e[a]]});return u[0]},"bound"),o=s(i=>[...Array(r)].map((a,c)=>[...Array(r)].map((f,u)=>n(c,u,i))),"grid");return Bn(e,o(!0),o(!1))}s(Tn,"order");function Nr(e,t){return{subject:e,floor:t.floor,ceiling:t.ceiling}}s(Nr,"unit");var Cr=s((e,t)=>Nr(t,{floor:e.bottom,ceiling:e.top}),"permitAll");function Pn(e,t){return e.stateOf(e.rank(t.floor),e.rank(t.ceiling))}s(Pn,"state");function qn(e,t){for(let r of t)if(!e.leq(e.rank(r.floor),e.rank(r.ceiling)))throw new F("MALFORMED",`\`${r.subject}\` cannot be met by anything`,{subject:r.subject,floor:r.floor,ceiling:r.ceiling});return Br(e,t)}s(qn,"compose");function rs(e,t,r,n,o){let i=r.floor,a=r.ceiling;for(let c of t)i=n(i,e.rank(c.floor)),a=o(a,e.rank(c.ceiling));return{subject:t[0].subject,floor:e.levels[i],ceiling:e.levels[a]}}s(rs,"band");function Br(e,t){return t.length===0?Cr(e,""):rs(e,t,{floor:e.bottomIx,ceiling:e.topIx},(r,n)=>e.higher(r,n),(r,n)=>e.lower(r,n))}s(Br,"fuse");function Wn(e,t,r){let[n,o]=[e.rank(t.floor),e.rank(t.ceiling)],[i,a]=[e.rank(r.floor),e.rank(r.ceiling)];return e.leq(i,n)&&e.leq(o,a)}s(Wn,"entails");var Dn=32;function zn(e){return e<=0?0:Math.ceil(e/Dn)}s(zn,"chunkCount");var Q=class e{static{s(this,"WideMask")}words;width;constructor(t,r){this.width=t,this.words=r??new Uint32Array(zn(t))}static fromTokens(t,r){let n=new e(t.length);return t.forEach((o,i)=>{r.has(o)&&n.set(i)}),n}set(t){if(t<0||t>=this.width)throw new F("MALFORMED",`bit ${t} is outside a mask of width ${this.width}`,{bit:t,width:this.width});this.words[t>>5]|=1<<(t&31)}has(t){return t<0||t>=this.width?!1:(this.words[t>>5]&1<<(t&31))!==0}and(t){let r=Math.max(this.width,t.width),n=new e(r),o=Math.min(this.words.length,t.words.length);for(let i=0;i<o;i++)n.words[i]=this.words[i]&t.words[i];return n}or(t){let r=Math.max(this.width,t.width),n=new e(r);for(let o=0;o<n.words.length;o++)n.words[o]=(this.words[o]??0)|(t.words[o]??0);return n}difference(t){let r=Math.max(this.width,t.width),n=new e(r);for(let i=0;i<n.words.length;i++)n.words[i]=(this.words[i]??0)&~(t.words[i]??0);let o=r%32;return o!==0&&n.words.length>0&&(n.words[n.words.length-1]&=(1<<o)-1),n}subsetOf(t){let r=Math.max(this.words.length,t.words.length);for(let n=0;n<r;n++){let o=this.words[n]??0,i=t.words[n]??0;if((o&~i)!==0)return!1}return!0}size(){let t=0;for(let r=0;r<this.width;r++)this.has(r)&&t++;return t}members(t){return t.filter((r,n)=>this.has(n))}static filled(t){let r=new e(t);if(t<=0)return r;r.words.fill(4294967295);let n=t%32;return n!==0&&(r.words[r.words.length-1]=(1<<n)-1),r}};var Tr=["declared","statistics","sample","exact"];function Lt(e){let t=Qe(Tr),r=[...e].map(n=>Nr("evidence",{floor:Tr[0],ceiling:n}));return r.length===0?"exact":qn(t,r).ceiling}s(Lt,"weakest");function ve(e,t,r){return e.leq(t,r)&&e.leq(r,t)}s(ve,"eq");function Pr(e){let t=s(r=>Pn(e,r)!=="CONFLICT","inhabited");return{top:Cr(e,""),bottom:{subject:"",floor:e.levels[e.topIx]??"",ceiling:e.levels[e.bottomIx]??""},leq:s((r,n)=>Wn(e,r,n),"leq"),meet:s((r,n)=>Br(e,[r,n]),"meet"),join:s((r,n)=>t(r)?t(n)?{subject:r.subject||n.subject,floor:e.levels[e.lower(e.rank(r.floor),e.rank(n.floor))]??r.floor,ceiling:e.levels[e.higher(e.rank(r.ceiling),e.rank(n.ceiling))]??r.ceiling}:r:n,"join"),show:s(r=>`[${r.floor}, ${r.ceiling}]`,"show"),inhabited:t}}s(Pr,"fromScale");function Ln(e){return{bottom:new Q(e.length),top:Q.filled(e.length),leq:s((t,r)=>t.subsetOf(r),"leq"),meet:s((t,r)=>t.and(r),"meet"),join:s((t,r)=>t.or(r),"join"),show:s(t=>t.members(e).join(","),"show"),inhabited:s(t=>t.size()>0,"inhabited")}}s(Ln,"subsets");function U(e,t){let r=Math.min(e,t),n=Math.max(e,t);return{bottom:{lo:n,hi:r},top:{lo:r,hi:n},leq(o,i){return o.lo>o.hi?!0:i.lo>i.hi?!1:i.lo<=o.lo&&o.hi<=i.hi},meet(o,i){return{lo:Math.max(o.lo,i.lo),hi:Math.min(o.hi,i.hi)}},join(o,i){return o.lo>o.hi?i:i.lo>i.hi?o:{lo:Math.min(o.lo,i.lo),hi:Math.max(o.hi,i.hi)}},show(o){return o.lo>o.hi?"empty":`${o.lo}..${o.hi}`},inhabited(o){return o.lo<=o.hi}}}s(U,"intervals");function Kt(){let e=s((t,r)=>[...t].every(n=>r.has(n)),"within");return{leq(t,r){return t.polarity==="permit"&&r.polarity==="permit"?e(t.values,r.values):t.polarity==="forbid"&&r.polarity==="forbid"?e(r.values,t.values):t.polarity==="permit"?[...t.values].every(n=>!r.values.has(n)):!1},show(t){return`${t.polarity==="forbid"?"not:":""}${[...t.values].sort().join("|")}`}}}s(Kt,"alphabets");function Ht(e){let t={lattice:e.lattice,parse:e.parse,emit:e.emit,count:e.count,show:e.show,points:e.points},r=Object.entries(t).find(([,n])=>typeof n!="function");if(r)throw new Error(`form \`${e.id}\` declared no ${r[0]}`);return e}s(Ht,"form");var L=s(e=>e!==null&&typeof e=="object"?e:{},"rec");function se(e){return Array.isArray(e)?e.map(String):[]}s(se,"strings");var qr=s(e=>{let t=e>>>0;return()=>{t=t+1831565813>>>0;let r=Math.imul(t^t>>>15,t|1);return r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}},"drawn"),Kn=s((e,t)=>t[Math.floor(e()*t.length)],"picked");function ns(e,t){if(e.length===0)return{kind:"refused",why:"a ladder with no levels cannot be counted"};let r=Qe(e),n=r.rank(t.floor),o=r.rank(t.ceiling);return r.leq(n,o)?{kind:"finite",n:e.filter((a,c)=>r.leq(n,c)&&r.leq(c,o)).length}:{kind:"finite",n:0}}s(ns,"bandCount");var Hn={parse(e,t){let r=this.lattice(e),n=L(t);return{subject:String(n.subject??""),floor:String(n.floor??r.top.floor),ceiling:String(n.ceiling??r.top.ceiling)}},emit(e,t){return{subject:t.subject,floor:t.floor,ceiling:t.ceiling}},count(e,t){return ns(se(L(t).levels),e)},points(e,t,r){let n=this.lattice(e),o=se(L(e).levels),i=qr(t),a=s((c,f)=>({subject:"",floor:c,ceiling:f}),"band");return Array.from({length:r},()=>{let[c,f]=[Kn(i,o),Kn(i,o)];return[a(c,f),a(f,c)].find(u=>n.inhabited(u))??a(c,c)})}},xe=Ht({id:"ladder",lattice(e){let t=se(L(e).levels);if(t.length===0)throw new Error("ladder needs levels");return Pr(Qe(t))},...Hn,show(e){return e.floor===e.ceiling?e.floor:`${e.floor}..${e.ceiling}`}}),oe=Ht({id:"alphabet",lattice(e){return Ln(se(L(e).tokens))},parse(e,t){let r=se(L(e).tokens),n=L(t),o=n.want!==void 0?se(n.want):r;return Q.fromTokens(r,new Set(o))},emit(e,t){return{want:t.members(se(L(e).tokens))}},count(e){return{kind:"finite",n:e.size()}},show(e){return`${e.size()}`},points(e,t,r){let n=se(L(e).tokens),o=qr(t);return Array.from({length:r},()=>Q.fromTokens(n,new Set(n.filter(()=>o()<.5))))}}),A=Ht({id:"continuous",lattice(e){let t=L(e);return U(Number(t.lo??0),Number(t.hi??1))},parse(e,t){let r=this.lattice(e),n=L(t);return{lo:n.lo===void 0?r.top.lo:Number(n.lo),hi:n.hi===void 0?r.top.hi:Number(n.hi)}},emit(e,t){return{lo:t.lo,hi:t.hi}},count(){return{kind:"refused",why:"a continuous band has no count; prefer not to exist over inventing one"}},show(e){return e.lo>e.hi?"empty":`${e.lo}..${e.hi}`},points(e,t,r){let n=L(e),o=Number(n.lo??0),i=Number(n.hi??1),a=qr(t),c=s(()=>o+Math.round(a()*(i-o)),"at");return Array.from({length:r},()=>({lo:c(),hi:c()}))}}),Y=Ht({id:"lattice",lattice(e){let t=L(e),r=se(t.levels),n=t.leq;if(r.length&&n)return Pr(Tn(r,n));throw new Error("lattice needs levels+leq")},...Hn,show(e){return`${e.floor}..${e.ceiling}`}}),Wr=[xe,oe,A,Y],Jn=[...Wr];function Dr(e,t){let r=e.top;for(let n of t)r=e.meet(r,n);return r}s(Dr,"foldIn");function Jt(e,t){let r=Dr(e,t);if(e.inhabited(r))return null;for(let n=0;n<t.length;n++)for(let o=n+1;o<t.length;o++)if(!e.inhabited(e.meet(t[n],t[o])))return[t[n],t[o]];return null}s(Jt,"witnessesIn");function Se(e,t="/"){let r=e.split(new RegExp(`[${t.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")}]`)).filter(n=>n!=="");for(;r[r.length-1]==="*"||r[r.length-1]==="**";)r.pop();return r}s(Se,"coordinate");function Vt(e,t=0,r=[],n="/"){return{at:Se(e,n),epoch:t,seen:r}}s(Vt,"point");function V(e,t="/"){return{at:Se(e,t)}}s(V,"region");function Gn(e,t){return{at:e.at.slice(0,Math.max(0,t)),epoch:e.epoch,seen:e.seen}}s(Gn,"coarsen");function je(e,t){return t.startsWith("*")?e.at.some(r=>r.endsWith(t.slice(1))):e.at.includes(t)}s(je,"passes");function me(e){return e.at.length}s(me,"resolution");function K(e,t){let r=s((n,o)=>o===t.at.length||(t.at[o]==="**"?r(n,o+1)||n<e.at.length&&r(n+1,o):n<e.at.length&&(t.at[o]==="*"||t.at[o]===e.at[n])&&r(n+1,o+1)),"refines");return r(0,0)}s(K,"within");function zr(e,t){return e.filter(r=>!t.some(n=>n.some(o=>me(o)===me(r)&&K(r,o))))}s(zr,"exclusive");function Lr(e,t){return!e.some(r=>t.some(n=>K(n,r)))}s(Lr,"contracts");function Me(e){return[...new Set(e.map(t=>t.at.join("/")))].sort().join("|")}s(Me,"key");var Vn=s((e,t)=>e>=t.lo&&e<=t.hi,"inside");function os(e,t,r){let n=new Map;for(let o of e){if(!K(o,t))continue;let i=o.at.join("/");n.set(i,[...n.get(i)??[],o])}return[...n].sort((o,i)=>o[0]<i[0]?-1:o[0]>i[0]?1:0).map(([o,i])=>({at:o,value:r(i)}))}s(os,"foldRegion");function Kr(e,t){return e.every(r=>t.where.some(n=>K(r,n))&&Vn(me(r),t.steps)&&Vn(r.epoch,t.when))}s(Kr,"covers");function Hr(e,t,r){let n=t.filter(([o])=>e.some(i=>je(i,o))).map(([,o])=>o);return r.find(o=>n.includes(o))??null}s(Hr,"outranks");function is(e,t){return e.length>0&&e.every(r=>t.some(n=>K(r,n)))}s(is,"answers");function ss(e,t){return e.some(r=>t(r))}s(ss,"verified");function as(e,t){return e.filter(r=>t.some(n=>K(r,n)))}s(as,"retracted");function cs(e,t){return new Set(e.map(r=>{let n=Vt(r);return(t===void 0?n:Gn(n,t)).at.join("/")})).size}s(cs,"size");function ls(e,t,r=Object.is){let n=t(e);for(let o=1;o<e;o+=1)if(r(t(o),n))return o;return e}s(ls,"sufficientResolution");function G(e,t=0,r=[],n=[]){return{at:Se(e),epoch:t,seen:r,restsOn:n}}s(G,"cell");function he(e){if(e.widens!==void 0&&e.reach==="travels")throw new F("widening-travels","obligations: REFUSE\xB7widening-travels a widening stands where it was witnessed and never travels to what rests there",{pole:e.pole});return e.takes===void 0?e:{...e,sign:-1}}s(he,"mark");function H(e){let t=new Set(e.flatMap(r=>r.takes===void 0?[]:[r.takes]));return e.filter(r=>r.takes===void 0&&(r.id===void 0||!t.has(r.id)))}s(H,"live");function ke(e,t=new Map){let r=e.at.join("/"),n=[],o=new Set,i=[...e.restsOn],a=new Map;for(let f=0;f<i.length;f+=1){let u=i[f];if(u===r)throw new F("rest-cycle",`obligations: REFUSE\xB7rest ${r} rests on itself: an order of rest with a cycle has no fold to reach`,{at:r});if(o.has(u))continue;o.add(u),n.push(u);let d=t.get(u)?.restsOn??[];a.set(u,d);for(let l of d)i.push(l)}let c=new Map;for(let f of n){if(c.has(f))continue;c.set(f,"visiting");let u=[{name:f,next:0}];for(;u.length;){let d=u[u.length-1],l=a.get(d.name);if(d.next===l.length){c.set(d.name,"done"),u.pop();continue}let p=l[d.next++],m=c.get(p);if(m==="visiting")throw new F("rest-cycle",`obligations: REFUSE\xB7rest ${r} reaches a cycle at ${p}: an order of rest with a cycle has no fold to reach`,{at:r});m===void 0&&(c.set(p,"visiting"),u.push({name:p,next:0}))}}return n}s(ke,"restOf");function Z(e,t,r=new Map){let n=ke(t,r),o=n.flatMap(d=>H(r.get(d)?.marks??[]).filter(l=>l.reach==="travels"&&l.widens===void 0)),i=[...H(t.marks??[]),...o].sort((d,l)=>(d.at??0)-(l.at??0)),a=e.top,c=e.top;for(let d of i)d.pole==="floor"?a=e.meet(a,d.span):c=d.widens===void 0?e.meet(c,d.span):e.join(c,d.span);let f=H(t.seen),u=f.reduce((d,l)=>e.meet(d,l.span),e.top);return{floor:e.meet(a,u),ceiling:e.meet(c,u),origins:f,rest:n,required:a,signed:c}}s(Z,"parts");function Xn(e,t,r=new Map){let{floor:n,ceiling:o,origins:i,required:a,signed:c}=Z(e,t,r);return e.inhabited(e.meet(a,c))?new Set(i.map(f=>f.origin)).size<2?"REQUIRED":e.inhabited(i.reduce((f,u)=>e.meet(f,u.span),e.top))?e.inhabited(e.meet(n,o))?"FREE":"FORBIDDEN":"CONFLICT":"CONFLICT"}s(Xn,"state");function C(e,t,r=new Map){let{floor:n,ceiling:o}=Z(e,t,r);return e.meet(n,o)}s(C,"meet");var Yn=s(e=>U(Math.min(...e.map(t=>t.lo)),Math.max(...e.map(t=>t.hi))),"spanning");function Jr(e){return new Set(e.seen.map(t=>t.origin)).size}s(Jr,"origins");function Ye(e){return Jr(e)<2}s(Ye,"potential");function Vr(e){let t=e.seen.map(i=>i.span),r=t.length?Jt(Yn(t),t):null;if(!r)return null;let n=e.seen.find(i=>i.span===r[0]),o=e.seen.find(i=>i.span===r[1]);return n&&o?[n,o]:null}s(Vr,"disagree");function Gt(e){let t=e.seen.map(n=>n.span);if(!t.length)throw new Error("obligations: REFUSE\xB7meet a cell no origin has claimed has no meet of its own: read it against the form it belongs to");let r=Yn(t);return t.reduce((n,o)=>r.meet(n,o))}s(Gt,"meetAt");function Zn(e){return e.reduce((t,r)=>t===null||r.epoch>t.epoch?r:t,null)}s(Zn,"latest");function Qn(e){return Ye(e)?"one":Vr(e)?"apart":"together"}s(Qn,"verdict");function eo(e,t){let r=new Map(e.map(n=>[Me([{at:n.at}]),Qn(n)]));return t.filter(n=>r.get(Me([{at:n.at}]))!==Qn(n))}s(eo,"turned");function Ze(e,t,r=new Map){return{origins:new Set(H(t.seen).map(n=>n.origin)).size,held:C(e,t,r)}}s(Ze,"encounter");var Gr=s((e,t)=>Math.cos(e.phase-t.phase)<0,"cancels");function to(e){let t=0,r=0;for(let n=0;n<e.length;n+=1)for(let o=n+1;o<e.length;o+=1)Gr(e[n],e[o])?t+=1:r+=1;return{forks:t,closes:r}}s(to,"pairs");function ro(e){let t=e.reduce((n,o)=>n+Math.cos(o.phase),0),r=e.reduce((n,o)=>n+Math.sin(o.phase),0);return t*t+r*r>e.length}s(ro,"laminar");function no(e){if(Ye(e))return"potential";let t=Gt(e);return t.lo>t.hi?null:t}s(no,"present");function oo(e,t,r,n){let o=e;for(let i=0;i<n;i+=1)o=Math.max(0,o+t-r);return{width:o,trend:o===0&&e>0?"zero":o>e?"widens":o<e?"narrows":"holds"}}s(oo,"converge");function io(e,t,r){let n=[...t,...r].map(([,i])=>i),o=n.length?Math.max(...n):0;return t.length===0&&o<e}s(io,"endsBeforeNow");var so=["transitivity","antisymmetry"],ao=["idempotence.meet","unit.top","top.greatest","commutativity.meet","consistency.meet","associativity.meet"],co=["idempotence.join","unit.bottom","bottom.least","commutativity.join","consistency.join","associativity.join"],lo=["absorption.meet","absorption.join"],fs=[...so,...ao,...co,...lo],Xt=s((e,t,r)=>`${t}: ${r.map(n=>e.show(n)).join(" , ")}`,"sayAt");function fo(e,t){let r=[],n=s((o,i)=>ve(e,o,i),"same");for(let o of t)for(let i of t){e.leq(o,i)&&e.leq(i,o)&&!n(o,i)&&r.push(Xt(e,"antisymmetry",[o,i]));for(let a of t)e.leq(o,i)&&e.leq(i,a)&&!e.leq(o,a)&&r.push(Xt(e,"transitivity",[o,i,a]))}return r}s(fo,"posetViolationsIn");function uo(e,t){let r=[...fo(e,t)],n=s((i,a)=>ve(e,i,a),"same"),o=s((i,...a)=>{r.push(Xt(e,i,a))},"say");for(let i of t){n(e.meet(i,i),i)||o("idempotence.meet",i),n(e.meet(i,e.top),i)||o("unit.top",i),e.leq(i,e.top)||o("top.greatest",i);for(let a of t){n(e.meet(i,a),e.meet(a,i))||o("commutativity.meet",i,a),e.leq(i,a)!==n(e.meet(i,a),i)&&o("consistency.meet",i,a);for(let f of t)n(e.meet(e.meet(i,a),f),e.meet(i,e.meet(a,f)))||o("associativity.meet",i,a,f)}}return r}s(uo,"meetViolationsIn");function Xr(e,t){let r=[...uo(e,t)],n=s((i,a)=>ve(e,i,a),"same"),o=s((i,...a)=>{r.push(Xt(e,i,a))},"say");for(let i of t){n(e.join(i,i),i)||o("idempotence.join",i),n(e.join(i,e.bottom),i)||o("unit.bottom",i),e.leq(e.bottom,i)||o("bottom.least",i);for(let a of t){n(e.join(i,a),e.join(a,i))||o("commutativity.join",i,a),n(e.meet(i,e.join(i,a)),i)||o("absorption.meet",i,a),n(e.join(i,e.meet(i,a)),i)||o("absorption.join",i,a),e.leq(i,a)!==n(e.join(i,a),a)&&o("consistency.join",i,a);for(let f of t)n(e.join(e.join(i,a),f),e.join(i,e.join(a,f)))||o("associativity.join",i,a,f)}}return r}s(Xr,"violationsIn");function po(e){return e!==""&&!/[\s\\|]/.test(e)&&e.split("/").every(t=>t!==""&&t!=="."&&t!==".."&&t!=="*"&&t!=="**")}s(po,"coordinateText");function Oe(e){try{let t=_(e);if(t.polarity!=="permit"||t.members.some(n=>!po(n)))return;let r=[...new Set(t.members)].sort(v);return _({polarity:"permit",members:r})!==e?void 0:r}catch{return}}s(Oe,"restCoordinates");var ds=["type","scope","id","epoch","by","sig"];function mo(e,t,r,n,o){let i=s((d,l)=>R(d,l),"bad");if(t.includes("at"))return i("object records carry no at: order is epoch and a local join witness is widens","at");let a=e.type;if(!r.types.has(a??"")||!["cell","claim","mark"].includes(a??""))return i("an object record names a declared type: cell, claim or mark","type");if(!/^(0|[1-9][0-9]*)$/.test(e.epoch??"")||!Number.isSafeInteger(Number(e.epoch)))return i("an object record carries an exactly supported logical epoch","epoch");if(Number(e.epoch)<r.activation)return i(`an object epoch precedes typed-wire activation ${r.activation}`,"epoch");let c;if(a==="cell")c="cell";else if(e.sign==="-1")c=`${a}/negative`;else{if(e.sign!=="+1")return i("a claim or mark names sign=+1 or sign=-1","sign");if(a==="claim")c="claim/positive";else if(e.pole==="floor"&&e.reach==="travels"&&e.widens===void 0)c="mark/floor-travelling";else if(e.pole==="ceiling"&&e.reach==="travels"&&e.widens===void 0)c="mark/travelling";else if(e.pole==="ceiling"&&e.reach==="local")c="mark/local";else return i("a positive mark is ceiling/travels, ceiling/local with widens, or floor/travels without widens","pole")}let f=r.required.get(c),u=r.allowed.get(c);if(!f||!u||r.common.size===0||r.configuration.size===0||[...r.common].some(d=>!f.has(d)||!u.has(d))||[...f].some(d=>!u.has(d)))return i(`typed wire has no complete required/allowed contract for ${c}`,"type");for(let d of ds)if(e[d]===void 0||e[d]==="")return i(`an object record has no ${d}`,d);for(let d of t)if(!n.has(d)||!u.has(d))return i(`\`${d}=\` is not allowed on ${c}`,d);for(let d of f)if(!u.has(d)||e[d]===void 0||e[d]==="")return i(`a ${c} record has no declared required \`${d}\``,d);if(!po(e.scope))return i("scope is a canonical cell coordinate","scope");if(a==="cell"){if(!o.has(e.form))return i("the cell names no admitted form","form");if(Oe(e.restsOn)===void 0)return i("cell restsOn is none or a canonical alphabet of coordinates","restsOn")}return D({record:a,fields:{...e}})}s(mo,"objectFromFields");function Qt(e,t){return`${e}:${t}`}s(Qt,"formatSignature");function ee(e){let t=e.lastIndexOf(":");return t<=0||t===e.length-1?null:{algorithm:e.slice(0,t),raw:e.slice(t+1)}}s(ee,"parseSignature");function Yt(e,t){let r={...e,by:t};return delete r.sig,r}s(Yt,"signedFieldsOf");function ho(e,t){return e!==""&&K(V(t,"./"),V(e,"./"))}s(ho,"under");var Ce=new Set(["sig","expires","repo","by","epoch"]),et="withdraw",Ue="wire/",tr="audit/wire/";function wo(e){let t=e.scope??"";return t.startsWith(Ue)||t.startsWith(tr)}s(wo,"isWireClaim");function Zt(e){if(e.startsWith(tr))return e.slice(tr.length);if(e.startsWith(Ue))return e.slice(Ue.length)}s(Zt,"listOf");function $(e){let t=e.epoch??"";return/^\d+$/.test(t)?Number(t):0}s($,"epochOf");function go(e,t){return Object.keys(e).filter(r=>r!=="value"&&!Ce.has(r)).every(r=>t[r]===e[r])}s(go,"names");function Be(e,t){let r=e.filter(l=>Zt(l.scope??"")!==void 0&&$(l)<=t),n=r.filter(l=>l.value===et),o=new Map;for(let l of r){if(l.value===et||n.some(h=>go(h,l)))continue;let p=(Zt(l.scope??"")??"")+"\0"+(l.by??""),m=o.get(p)??[],g=m.length?$(m[0]):-1;$(l)>g?o.set(p,[l]):$(l)===g&&o.set(p,[...m,l])}let i=[...o.values()].flatMap(l=>l.some(p=>(p.scope??"").startsWith(Ue))?l.filter(p=>(p.scope??"").startsWith(Ue)):l),a=new Map;for(let l of i){let p=Zt(l.scope??"")??"",m=a.get(p);if(m!==void 0&&m!==l.value)throw Error(`REFUSE\xB7wire wire/${p} has conflicting live declarations`);a.set(p,l.value??"")}let c=new Map;for(let l of r){let p=Zt(l.scope??"")??"";if(l.value===et||n.some(h=>go(h,l)))continue;let m=c.get(p);(m===void 0||$(l)>$(m)||$(l)===$(m)&&(l.scope??"").startsWith(Ue)&&(m.scope??"").startsWith(tr))&&c.set(p,l)}if(!c.size)return null;let f=s(l=>new Set((c.get(l)?.value??"").split("|").filter(Boolean)),"ids"),u=new Map([...c].filter(([l])=>l.startsWith("form/")).map(([l,p])=>[l.slice(5),p.value??""])),d=new Map([...c.keys()].filter(l=>!l.includes("/")).map(l=>[l,f(l)]));return{epoch:t,...c.has("object/types")?{object:{activation:$(c.get("object/types")),types:f("object/types"),common:f("object/common"),reserved:f("object/reserved"),configuration:f("object/allowed/config"),required:new Map([...c.keys()].filter(l=>l.startsWith("object/required/")).map(l=>[l.slice(16),f(l)])),allowed:new Map([...c.keys()].filter(l=>l.startsWith("object/allowed/")).map(l=>[l.slice(15),f(l)]))}}:{},fields:f("fields"),required:f("required"),roles:f("roles"),forms:f("forms"),classes:f("at-classes"),digests:new Set([...f("digest-algorithms")].map(l=>l.split(":")[0])),signatures:f("signature-algorithms"),formOf:u,lists:d}}s(Be,"wireAt");function rr(e,t){let r=e.indexOf(":");return r>0&&t.digests.has(e.slice(0,r))&&/^[0-9a-f]+$/i.test(e.slice(r+1))}s(rr,"admittedDigest");function us(e){if(e.startsWith("/")||/[\s\\]/.test(e))return!1;let t=e.split("/").filter(r=>r!=="");return t.length>0&&t.every((r,n)=>r!=="."&&r!==".."&&(!r.includes("*")||n===t.length-1))}s(us,"isRegion");var yo={region:s(e=>e.split("|").filter(Boolean).every(us),"region"),class:s((e,t)=>{let r=e.indexOf(":");if(r<=0||!t.classes.has(e.slice(0,r)))return!1;let n=e.slice(r+1);return!/^[a-z0-9-]+:[0-9a-f]{16,}$/i.test(n)||rr(n,t)},"class"),signature:s((e,t)=>{let r=ee(e);if(r===null||!t.signatures.has(r.algorithm))return!1;let n=r.algorithm.slice(r.algorithm.lastIndexOf(":")+1);return rr(r.algorithm,t)||r.algorithm.includes(":")&&(t.lists.get("era")?.has(n)??!1)},"signature"),count:s(e=>/^\d+$/.test(e),"count")};function er(e,t){return R(t,e)}s(er,"debit");function ae(e,t,r){let n=S(e,{preserveKeys:!0});if(n.kind!=="fact")return n.kind==="abstain"?ue(n.why):R(n.why,n.named);let o=n.value.fields,i=n.value.keys;if(i.includes("type")){if(!t?.object)return R("typed object grammar is not admitted at this epoch","type");if(!t.object.configuration.size||!t.object.reserved.size||[...t.object.reserved].some(g=>t.object.configuration.has(g)))return R("typed wire has no closed configuration/object field contract","type");let m=mo(o,i,t.object,t.fields,t.forms);return m.kind!=="fact"?m:yo.signature(o.sig,t)?m.value.record==="cell"&&!rr(o.topos,t)?R("cell topos is not an admitted digest","topos"):m.value.record==="cell"&&(o.restsOn??"").split("|").some(g=>rr(g,t))?R("cell restsOn names coordinates, not byte digests","restsOn"):m:R("object signature grammar is not admitted","sig")}if(t){if(t.object){if(!t.object.configuration.size||!t.object.reserved.size||[...t.object.reserved].some(g=>t.object.configuration.has(g)))return R("typed wire has no closed configuration/object field contract","type");let m=i.find(g=>t.object.reserved.has(g)||!t.object.configuration.has(g));if(m)return R(`\`${m}=\` is an object-only field: untyped configuration cannot carry it`,m)}for(let m of Object.keys(o))if(!t.fields.has(m))return er(m,`\`${m}=\` is not a field of the wire at epoch ${t.epoch}`);for(let m of t.required)if(o[m]===void 0)return er(m,`a claim with no \`${m}\``);for(let[m,g]of t.formOf){let h=o[m];if(h===void 0)continue;let y=t.lists.get(g),b=yo[g]??(y?O=>y.has(O):void 0);if(!b)return ue(`\`${m}\` takes the form ${g}, which this reader does not know`);if(!b(h,t))return er(m,`\`${m}=${h}\` is not a ${g} of the wire at epoch ${t.epoch}`)}if(o.role!==void 0&&!t.roles.has(o.role))return ue(`\`role=${o.role}\` is a role this wire does not name`);if(!t.forms.has(o.form??""))return ue(`\`form=${o.form}\` is a form this wire does not name`)}let a=Array.isArray(r)?r:void 0,c=o.value===et?{kind:"enumerated",values:[et]}:re(o.form??"",o.value??"",a);if(c===null)return En.includes(o.form??"")||(a?.some(g=>g.form===o.form)??!1)?er("value",`\`${o.value}\` is not a ${o.form}`):ue(`\`form=${o.form}\` is a form this reader does not know`);let f=o.role==="writes"?"writes":o.role==="demands"?"demands":"reads",u={};for(let[m,g]of Object.entries(o))["scope","measure","form","value","by","at","role","unit","multiplicity","epoch","ref","to","ref_by"].includes(m)||(u[m]=g);let d=o.ref,l=o.to===void 0?null:$e(o.to),p=d&&l&&vn.includes(d)?{rel:d,to:l,by:o.ref_by==="declared"?"declared":"inferred"}:null;return D({scope:o.scope??"",measure:o.measure??"",bound:c,role:f,by:o.by??"",at:o.at??"",...o.unit!==void 0?{unit:o.unit}:{},...o.multiplicity==="one"||o.multiplicity==="many"||o.multiplicity==="unknown"?{multiplicity:o.multiplicity}:{},...o.epoch!==void 0?{epoch:o.epoch}:{},...p?{reference:p}:{},extra:u})}s(ae,"fromLine");var ge="keys";function Eo(e){let t=e.scope??"";return t===ge||t.startsWith(`${ge}/`)}s(Eo,"isKeyClaim");function Yr(e){let t=/^(\d+)\.\.(\d+)$/.exec(e);return t?{lo:Number(t[1]),hi:Number(t[2])}:null}s(Yr,"depthWindow");var Ne=U(-1/0,1/0),Qr=U(1,1/0);function vo(e){return e.epoch??{start:0,close:null}}s(vo,"windowOf");function nr(e,t){let r=vo(e),n=(e.windows??[]).filter(o=>t>=o.from&&(o.to===null||t<o.to));return n.length?{start:r.start,close:n.reduce((o,i)=>Ne.meet(o,i),Ne.top).hi}:r}s(nr,"windowAt");function ps(e,t){let r=nr(e,t);return t>=r.start&&(r.close===null||t<=r.close)}s(ps,"inside");function xo(e){let t=s(n=>[n.role,n.form,n.at].join(" "),"claim"),r=new Map;for(let n of e)n.value==="withdraw"&&r.set(t(n),Ne.meet(r.get(t(n))??Ne.top,{lo:-1/0,hi:$(n)}));return n=>r.get(t(n))?.hi??null}s(xo,"standsUntil");function ms(e){let t=xo(e),r=e.filter(n=>n.value!=="withdraw").map(n=>({globs:(n.value??"").split("|").filter(Boolean),from:$(n),to:t(n)})).filter(n=>n.to===null||n.from<n.to);return{coverage:[...new Set(r.filter(n=>n.to===null).flatMap(n=>n.globs))],spans:r}}s(ms,"coverageOver");function bo(e){let t=xo(e);return e.filter(r=>r.value!=="withdraw").flatMap(r=>(n=>n===null?[]:[{...n,from:$(r),to:t(r)}])(Yr(r.value??""))).filter(r=>r.to===null||r.from<r.to)}s(bo,"windowsOver");function So(e,t,r){let n=e.filter(l=>l.scope===ge&&l.measure==="quorum"&&l.by===t.id&&r(l,t.publicKey)).sort((l,p)=>$(l)-$(p)),o=s(l=>{let p=n.filter(m=>$(m)<=l).pop();return Qr.meet(Qr.top,Yr(p?.value??"")??Qr.top).lo},"quorumAt"),i=[...new Set(e.filter(l=>["class","public-key","coverage","epoch"].includes(l.measure??"")).map(l=>l.scope??"").filter(l=>l.startsWith(`${ge}/`)).map(l=>l.slice(ge.length+1)))],a=s((l,p)=>{let m=p.get(l.id);return m===void 0?l:{...l,epoch:{start:vo(l).start,close:m}}},"closedAt"),c=s((l,p,m)=>e.filter(g=>{let h=l.get(g.by??"");return g.scope===`${ge}/${p}`&&g.measure===m&&h!==void 0&&h.keyClass==="authorize"&&ps(h,$(g))&&r(g,h.publicKey)}),"claimsOn"),f=s(l=>{let p=new Map([[t.id,a(t,l)]]);for(let m=!0;m;){m=!1;for(let g of i){if(p.has(g))continue;let h=c(p,g,"class"),y=new Set(h.filter(k=>k.value==="withdraw").map(k=>`${k.by??""} ${k.at??""}`)),b=h.filter(k=>k.value!=="withdraw"&&!y.has(`${k.by??""} ${k.at??""}`)).sort((k,I)=>$(k)-$(I)),O=h.filter(k=>k.value!=="withdraw").sort((k,I)=>$(k)-$(I)),W=[],B=null;for(let k of O){let I=k.by??"";if(W.includes(I)||W.push(I),W.length>=o($(k))){B=$(k);break}}let ye=c(p,g,"public-key")[0]?.value??"";if(B===null||!b.length||!ye)continue;let _e=e.some(k=>(k.by??"")===g&&$(k)===1&&!(k.scope??"").startsWith(`${ge}/`)),j=ms(c(p,g,"coverage"));p.set(g,a({id:g,keyClass:b.every(k=>k.value==="authorize")?"authorize":"attest",publicKey:ye,coverage:j.coverage,spans:_e?j.spans.map(k=>({...k,from:Math.min(k.from,1)})):j.spans,windows:bo(c(p,g,"epoch")),depth:Yr(c(p,g,"resolution")[0]?.value??"")??{lo:1,hi:1},admittedBy:W,epoch:{start:_e?Math.min(B,1):B,close:null}},l)),m=!0}}return p},"admitUnder"),u=new Map;for(let l=0;l<=i.length+1;l++){let p=f(u),m=new Map;for(let h of p.keys()){let y=bo(c(p,h,"epoch")).filter(b=>b.to===null);y.length&&m.set(h,y.reduce((b,O)=>Ne.meet(b,O),Ne.top).hi)}if(!(m.size!==u.size||[...m].some(([h,y])=>u.get(h)!==y)))return{admitted:[...p.values()],potential:i.filter(h=>!p.has(h))};u=m}let d=f(u);return{admitted:[...d.values()],potential:i.filter(l=>!d.has(l))}}s(So,"signersOf");function or(e,t,r,n){let o=e.by??"";if(n!==void 0&&!e.sig&&o==="target")return n.pins.includes(n.digest)?{kind:"admitted",signer:o}:{kind:"grey",why:`unpinned: no sources/ or uses/ line names ${n.digest}`};if(n!==void 0&&e.sig&&!t.some(a=>a.id===o))return{kind:"refuse",why:`REFUSE\xB7authority ${o||"\u2205"} is no key this release carries`,named:o};if(!e.sig)return{kind:"grey",why:"unsigned"};let i=t.find(a=>a.id===o);return i?r(e,i.publicKey)?Te(e,i,$(e)):{kind:"grey",why:`the signature does not hold for ${o}`}:{kind:"grey",why:`signer ${o||"\u2205"} is not admitted`}}s(or,"authorityOf");function Te(e,t,r,n=e.scope??"",o="record"){let i=e.by??"";if(o==="authority"&&(!Number.isSafeInteger(r)||r<0))return{kind:"refuse",why:`REFUSE\xB7authority ${i||"\u2205"} has unknown or invalid authority epoch`,named:i};let a=o==="authority"?"authority evaluated at epoch":"signed at epoch",c=nr(t,r);if(c.close!==null&&r>c.close)return{kind:"refuse",why:`REFUSE\xB7authority ${i} ${a} ${r}, after its epoch closed at ${c.close}`,named:i};if(r<c.start)return{kind:"grey",why:`${a} ${r}, before ${i} was admitted at ${c.start}`};let f=n;if(!(t.spans===void 0?t.coverage:t.spans.filter(l=>r>=l.from&&(l.to===null||r<l.to)).flatMap(l=>l.globs)).some(l=>l==="*"||ho(l,f)))return{kind:"refuse",why:`REFUSE\xB7authority ${i} does not cover ${f}`,named:i};let d=me(V(e.scope??""));return d<t.depth.lo||d>t.depth.hi?{kind:"refuse",why:`REFUSE\xB7authority ${i} may not sign at depth ${d}`,named:i}:K(V(e.scope??""),V(ge))&&t.keyClass!=="authorize"?{kind:"refuse",why:`REFUSE\xB7authority ${i} is attest and cannot admit signers`,named:i}:{kind:"admitted",signer:i}}s(Te,"authorityAtEpoch");var hs=["source","derived","observed","foreign"],gs=["coordinate-role/","leaf-role/"],ys=["foreign","derived","observed"],bs=new Map([["source","source"],["render","derived"],["receipt","derived"]]);function ko(e){return e.flatMap(t=>{let r=t.scope??"",n=t.value??"",o=bs.get(t.role??"");if(r.startsWith("region/")&&t.measure==="paths"&&o!==void 0&&n!=="withdraw")return n.split("|").filter(Boolean).map(a=>({name:a,role:o}));let i=gs.find(a=>r.startsWith(a));return i===void 0||t.measure!=="role"||!hs.includes(n)?[]:[{name:r.slice(i.length),role:n}]})}s(ko,"roleClaimsOf");function Oo(e,t){return je(V(e),t)}s(Oo,"namesAt");function Ro(e,t){let r={at:V(e).at,epoch:0,seen:[]};return Hr([r],t.map(n=>[n.name,n.role]),ys)??"source"}s(Ro,"roleAt");var _o=s((e,t)=>Xr(e,t),"violationsIn"),ir=s(e=>e!==null&&typeof e=="object"?e:{},"paramsOf");function te(e,t){throw new Error(`REFUSE\xB7form ${e}: ${t}`)}s(te,"refuseForm");function P(e,t,r){let n=ir(t)[r];return(typeof n!="number"||!isFinite(n))&&te(e,`takes ${r} as a number, and a value it is not given is not invented`),n}s(P,"numberAt");function ce(e,t,r){let n=ir(t)[r];return(!Array.isArray(n)||!n.length||n.some(o=>typeof o!="string"))&&te(e,`takes ${r} as a list of words`),n}s(ce,"wordsAt");var sr=s(e=>_({polarity:"permit",members:[...new Set(e)].sort(v)}),"written");function X(e,t,r){if(r==="empty")return{lo:t.hi,hi:t.lo};let n=s(o=>(i=>i.kind==="fact"&&i.value.bound.kind==="interval"?{lo:i.value.bound.lo??t.lo,hi:i.value.bound.hi??t.hi}:void 0)(ae(x({form:"interval",value:o}),null)),"read");return n(r)??n(`${r}..${r}`)??te(e,`\`${r}\` is not a band: lo..hi or one end, each a number or *`)}s(X,"bandOf");var ie=s(e=>(t=>e.lo>e.hi?"empty":`${t(e.lo)}..${t(e.hi)}`)(t=>isFinite(t)?lt(t):"*"),"bandText");function Pe(e,t,r){return t.some(o=>o.includes(".."))&&te(e,"a level holds no band mark `..`"),t.flatMap(o=>t.map(i=>({subject:"",floor:o,ceiling:i}))).find(({floor:o,ceiling:i})=>r===`${o}..${i}`)??(r.includes("..")?void 0:t.filter(o=>o===r).map(o=>({subject:"",floor:o,ceiling:o}))[0])??te(e,`\`${r}\` is not one of its levels, nor two of them as lo..hi`)}s(Pe,"levelsOf");function Zr(e){let t=e.provider?.lines??[],r=s(y=>{let b=t.filter(O=>O.scope==="wire/programs/"+y&&O.measure==="id");if(b.length!==1||!b[0].value)throw Error("REFUSE\xB7program missing or conflicting selector "+y);return b[0].value},"select");if(r("profile")!=="admitted-demands@1")throw Error("REFUSE\xB7program unsupported projection profile");let n=s(y=>{let b=e.lines.filter(O=>O.scope===y);if(b.length>1)throw Error("REFUSE\xB7program conflicting input "+y);return b[0]},"one"),o=s(y=>_(y).members,"list"),i=n(r("selection"));if(!i)throw Error("REFUSE\xB7program no declared selection");let a=o(i.value??"").map(y=>{let b=n(y);if(!b||b.role!=="demands")throw Error("REFUSE\xB7program selected coordinate is not a demand "+y);return{scope:y,needs:o(b.needs??"none"),restsOn:o(b.restsOn??"none")}}),c=n(r("minimum")),f=r("evidence"),u=e.regions[f]?.receipts;if(u===void 0)throw Error("REFUSE\xB7program evidence region was not handed "+f);let d=new Map;for(let y of u.filter(b=>b.measure==="status")){let b=y.scope??"",O=y.value??"";if(!["met","unmet","unread","refused"].includes(O))throw Error("REFUSE\xB7program unsupported evidence status "+b);if(d.has(b)&&d.get(b)!==O)throw Error("REFUSE\xB7program conflicting evidence "+b);d.set(b,O)}let l=r("elapsed"),p=u.filter(y=>y.scope===l);if(p.length>1)throw Error("REFUSE\xB7program conflicting elapsed reading "+l);let m=n(r("ceiling")),g=p[0];if(g&&m&&g.measure!==m.measure)throw Error("REFUSE\xB7program elapsed and ceiling units differ");let h=s((y,b)=>{if(!y)return;if(y.form!=="interval")throw Error("REFUSE\xB7program time input is not an interval "+y.scope);let O=X("interval",{lo:0,hi:1/0},y.value??"");if(!Number.isFinite(O.hi)||b&&O.lo!==O.hi)throw Error("REFUSE\xB7program time input is not an exact finite reading "+y.scope);return O.hi},"measure");return{programs:a,evidence:d,minimum:o(c?.value??"none"),elapsed:h(g,!0),ceiling:h(m,!1)}}s(Zr,"programInputs");function $o(e){let t=zt(Zr(e));return[`PROGRAM deadline=${t.deadline} closed=${t.closed}`,...t.rows.map(r=>`DEMAND ${r.scope} ${r.status} blocked=${r.blocked.join("|")||"none"} missing=${r.missing.join("|")||"none"} unread=${r.unread.join("|")||"none"} carry=${r.carry}`),...t.next.sort(v).map(r=>"NEXT "+r)]}s($o,"renderPrograms");var en=["contract","yes","vector","no"];function Fo(e,t,r,n){let o=s(c=>{throw Error("REFUSE\xB7publication "+c)},"fail");e.length||o("empty public surface is not conformance");let i=new Set,a=[...e].sort((c,f)=>v(c.scope,f.scope)).map(c=>{(!c.scope||i.has(c.scope))&&o("duplicate or empty coordinate "+c.scope),i.add(c.scope);let f=new Map;for(let p of c.members)(!en.includes(p.role)||f.has(p.role)||!p.digest)&&o("ambiguous member at "+c.scope),f.set(p.role,p.digest);let u=en.filter(p=>!f.has(p)||!t.has(f.get(p)));for(let[p,m]of f){let g=t.get(m);g&&n(g)!==m&&o("member digest differs at "+c.scope+"/"+p)}let d=r.get(c.scope);if(d){["met","unmet","unread","refused"].includes(d.status)||o("unsupported proof status "+c.scope);let p=new Map;for(let m of d.members)(!en.includes(m.role)||p.has(m.role))&&o("ambiguous proof inputs "+c.scope),p.set(m.role,m.digest);(p.size!==f.size||[...f].some(([m,g])=>p.get(m)!==g))&&o("proof input identity differs at "+c.scope)}let l=u.length?"missing":!d||d.status==="unread"?"unread":d.status==="met"?"met":"unmet";return{scope:c.scope,status:l,missing:u}});return{rows:a,missing:a.filter(c=>c.status!=="met").length,closed:a.every(c=>c.status==="met")}}s(Fo,"publicationCoverage");function Ao(e,t,r){try{let n=s(()=>{let i=t.reads??[],a=Object.fromEntries(Object.entries(t.regions??{}).filter(([c])=>i.some(f=>T(f,`region/${c}`))).map(([c,f])=>[c,{lines:Je(["**"],f.lines),receipts:Je(["**"],f.receipts)}]));return{...t.place===void 0?{}:{place:t.place},...t.provider===void 0?{}:{provider:_t(t.provider)},region:t.region??"",at:t.at??3,shape:t.shape??"",name:t.name??"",reads:i,lines:Je(i,t.lines??[]),regions:a}},"asked");if(t.verb==="render"&&e.render)return{protocol:M,kind:"fact",lines:e.render(n())};if(t.verb==="read"&&e.receipt&&t.reads!==void 0)return{protocol:M,kind:"fact",claims:e.receipt(n())};let o=t.files[0];return t.verb==="read"&&e.observe&&o!==void 0?{protocol:M,kind:"fact",claims:e.observe(new TextEncoder().encode(o.text),t.rootScope,t.region,t.files,n())}:t.verb==="read"&&e.run?{protocol:M,kind:"fact",claims:e.run(t.rootScope,r,t.held??[],t.region,n())}:t.verb==="read"&&e.observe?{protocol:M,kind:"refuse",why:"no file was handed to observe"}:{protocol:M,kind:"abstain",why:`no export answers ${t.verb}`}}catch(n){return{protocol:M,kind:"refuse",why:String(n)}}}s(Ao,"answer");var ws=s(e=>{let t=globalThis.__boundRead;return globalThis.__boundRead=e,t},"listen"),Es=s((e,t)=>{let r=globalThis.__boundRead;if(r===void 0||!Array.isArray(e.cases))return e;let n=e.cases.map((o,i)=>new Proxy(o,{get:s((a,c,f)=>(typeof c=="string"&&r(`${t}#${i}:${c}`),Reflect.get(a,c,f)),"get")}));return{...e,cases:n}},"observed"),vs=s((e,t,r)=>JSON.stringify(JSON.parse(t).map(n=>Ao(e,n,r))),"respond");function xs(e,t){let r=/(?:^|\n)([^\n]*)$/.exec(e.trimEnd())?.[1]??"",n=r.startsWith("[")?JSON.parse(r):[];return Array.from({length:t},(o,i)=>n[i]??{protocol:M,kind:"refuse",why:"no answer"})}s(xs,"responsesOf");var le="place-act-context@1",E=s(e=>{throw Error("REFUSE\xB7place-act "+e)},"refuse"),q=s(e=>typeof e=="string"&&e.length>0,"exactString"),tt=s(e=>!q(e)||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>String(Number.MAX_SAFE_INTEGER).length||!Number.isSafeInteger(Number(e))?E("unknown or invalid clock"):e,"clock"),cr=s(e=>{(!e||typeof e!="object")&&E("missing resource budget");for(let t of["bytes","records","placements","policies","proofs","signers"])(!Number.isSafeInteger(e[t])||e[t]<1)&&E("missing resource "+t)},"budget"),We=s(e=>new TextEncoder().encode(e).byteLength,"bytes"),tn=s(e=>{let t=S(e);return t.kind!=="fact"||x(t.value.fields,t.value.version)!==e||!t.value.fields.sig||!t.value.fields.by?E("noncanonical or unsigned original"):t.value.fields},"fields"),Ss=s(e=>{e!=="."&&(!e.endsWith("/TARGET.bound")||e.startsWith("/")||e.split("/").some(t=>t===""||t==="."||t===".."))&&E("unknown place coordinate")},"place"),qe=s(e=>JSON.stringify(e)+`
23
- `,"frame"),ar=s(e=>[e.namespace,e.snapshot,e.epoch,e.prefix,e.head,e.policies],"rootTuple");function rt(e,t,r,n){Re({root:e,places:[t]},n),q(r)||E("unknown origin signer"),r.length>n.bytes&&E("byte budget");let o=qe([le,"origin",r,t.place,t.epoch,t.originPrefix,e.snapshot,t.records]);return(r.length>n.bytes||We(o)>n.bytes)&&E("byte budget"),o}s(rt,"originContextBytes");function Re(e,t){cr(t),(!e||typeof e!="object"||!e.root||!Array.isArray(e.places)||!Array.isArray(e.root.policies))&&E("incomplete context"),e.places.some(c=>!c||!Array.isArray(c.records)||!Array.isArray(c.proofs))&&E("incomplete place context"),(e.places.length>t.placements||e.root.policies.length>t.policies)&&E("dependency/placement budget");let r=0,n=0,o=0,i=s(c=>{if(!q(c))return E("unknown context reference");c.length>t.bytes&&E("byte budget"),o+=c.length,o>t.bytes&&E("byte budget")},"scalar");for(let c of[e.root.namespace,e.root.snapshot,e.root.epoch,e.root.prefix,e.root.head,...e.root.policies])i(c);for(let c of e.places){r+=c.records.length,n+=c.proofs.length,(r>t.records||n>t.proofs)&&E("record/proof budget");for(let f of[c.place,c.previous,c.epoch,c.originPrefix,...c.records])i(f);for(let f of c.proofs)(!f||typeof f!="object")&&E("unknown origin proof"),i(f.by),i(f.signature)}let a=qe([le,"transaction",ar(e.root),e.places.map(c=>[c.place,c.previous,c.epoch,c.originPrefix,c.records,c.proofs.map(f=>[f.by,f.signature])])]);return We(a)>t.bytes&&E("byte budget"),De(a,t),a}s(Re,"placeActContextBytes");function De(e,t){cr(t),(typeof e!="string"||We(e)>t.bytes)&&E("byte budget");let r;try{r=JSON.parse(e)}catch{return E("invalid framing")}(!Array.isArray(r)||r.length!==4||r[0]!==le||r[1]!=="transaction")&&E("unsupported clock profile");let n=r[2],o=r[3];(!Array.isArray(n)||n.length!==6||!Array.isArray(n[5])||!Array.isArray(o))&&E("incomplete context"),(n[5].length>t.policies||o.length>t.placements)&&E("dependency/placement budget");let i=0,a=0;for(let u of o)(!Array.isArray(u)||u.length!==6||!Array.isArray(u[4])||!Array.isArray(u[5]))&&E("incomplete place context"),i+=u[4].length,a+=u[5].length;(i>t.records||a>t.proofs)&&E("record/proof budget"),(!o.length||!i)&&E("empty transaction"),(!n.slice(0,5).every(q)||!n[5].every(q))&&E("unknown authority context"),tt(n[2]),(new Set(n[5]).size!==n[5].length||n[5].some((u,d)=>d>0&&v(n[5][d-1],u)>=0))&&E("noncanonical policy dependencies");let c=o.map(u=>{(!u.slice(0,4).every(q)||!u[4].every(q)||!u[4].length)&&E("unknown place context"),Ss(u[0]),tt(u[2]),u[5].some(l=>!Array.isArray(l)||l.length!==2||!l.every(q))&&E("unknown origin proof");let d=u[5].map(l=>({by:l[0],signature:l[1]}));return(new Set(d.map(l=>l.by)).size!==d.length||d.some((l,p)=>p>0&&v(d[p-1].by,l.by)>=0))&&E("duplicate/noncanonical origin proofs"),{place:u[0],previous:u[1],epoch:u[2],originPrefix:u[3],records:u[4],proofs:d}});(new Set(c.map(u=>u.place)).size!==c.length||c.some((u,d)=>d>0&&v(c[d-1].place,u.place)>=0))&&E("duplicate/noncanonical places");let f={namespace:n[0],snapshot:n[1],epoch:n[2],prefix:n[3],head:n[4],policies:n[5]};return qe([le,"transaction",ar(f),o])!==e&&E("noncanonical framing"),{root:f,places:c}}s(De,"readPlaceActContext");function ks(e,t,r,n,o){let i=t.place==="."?e.scope:[o,t.place.slice(0,-13),e.scope].join("/"),a=Te(e,r,Number(tt(n.epoch)),i,"authority");a.kind!=="admitted"&&E("authority "+a.kind+" "+a.why)}s(ks,"eligibility");function Os(e,t,r){let n=tn(e),o=r.signers.find(i=>i.id===n.by);if(!o||r.verifiesOriginal(e,o,r.root)!==!0)return E("original signature");tt(n.epoch)!==t.epoch&&E("origin clock mismatch"),ks(n,t,o,r.root,r.regionFamily)}s(Os,"verifyAuthenticatedOriginal");function ze(e,t){(!t||typeof t!="object")&&E("missing instrument trust");let r=De(e,t.budget);for(let n of["verifiesRootContext","verifiesNamespaceAdmission","verifiesNewLocalPrefix","verifiesOriginal","verifiesProof","digest"])typeof t[n]!="function"&&E("missing instrument verifier "+n);(!t.root||!Array.isArray(t.signers)||!Array.isArray(t.places))&&E("missing authenticated context"),new Set(t.signers.map(n=>n.id)).size!==t.signers.length&&E("duplicate signer id"),(t.signers.length>t.budget.signers||!t.places.length||!q(t.regionFamily))&&E("trusted context budget/mapping"),(qe(ar(r.root))!==qe(ar(t.root))||t.verifiesRootContext(r.root)!==!0)&&E("unauthenticated authority context");for(let n of r.places){(!t.places.includes(n.place)||t.verifiesNamespaceAdmission(n.place,r.root)!==!0)&&E("namespace not admitted"),t.verifiesNewLocalPrefix(n.place,n.originPrefix,n.epoch,n.records)!==!0&&E("origin prefix or legacy reinterpretation");let o=[...new Set(n.records.map(a=>tn(a).by))].sort(v);(o.length!==n.proofs.length||o.some((a,c)=>n.proofs[c].by!==a))&&E("missing/borrowed origin proof");for(let a of n.proofs){let c=t.signers.find(f=>f.id===a.by);(!c||t.verifiesProof(rt(r.root,n,a.by,t.budget),a.signature,c,r.root)!==!0)&&E("origin proof signature")}let i=n.records.map(a=>t.digest(z(tn(a))));new Set(i).size!==i.length&&E("duplicate original");for(let a of n.records)Os(a,n,t)}return{identity:t.digest(e),context:r,dependencies:r.root}}s(ze,"verifyPlaceActContext");function nt(e,t,r,n,o,i){Re({root:r,places:[t]},i),(!q(e)||!q(n)||!q(o))&&E("unknown receipt identity/signer"),(e.length>i.bytes||n.length>i.bytes||o.length>i.bytes)&&E("byte budget");let a=qe([le,"receipt",n,o,e,t.place,t.previous,t.epoch,r.snapshot]);return We(a)>i.bytes&&E("byte budget"),a}s(nt,"placeReceiptBytes");function lr(e,t,r){(!r||typeof r!="object")&&E("missing instrument trust"),cr(r.budget),Array.isArray(t)||E("unknown receipt set"),t.length>r.budget.placements&&E("receipt budget");let n=0;for(let c of t){(!c||typeof c!="object")&&E("unknown receiver receipt");for(let f of[c.by,c.place,c.signature])(!q(f)||f.length>r.budget.bytes)&&E("receipt byte budget"),n+=f.length}(n>r.budget.bytes||We(JSON.stringify(t))>r.budget.bytes)&&E("receipt byte budget"),t.length>r.budget.placements&&E("receipt budget"),q(r.receiptScope)||E("unknown receiver scope");let o=ze(e,r);(t.length!==o.context.places.length||new Set(t.map(c=>c.place)).size!==t.length)&&E("incomplete/duplicate receiver receipts");let i=r.signers.find(c=>c.id===r.receiptSigner);if(!i)return E("unknown receiver signer");let a=Te({scope:r.receiptScope,by:i.id},i,Number(tt(r.root.epoch)),r.receiptScope,"authority");a.kind!=="admitted"&&E("receiver authority "+a.kind+" "+a.why);for(let c of o.context.places){let f=t.find(u=>u.place===c.place);(!f||f.by!==r.receiptSigner||r.verifiesProof(nt(o.identity,c,o.context.root,f.by,r.receiptScope,r.budget),f.signature,i,r.root)!==!0)&&E("receiver receipt signature")}return{identity:o.identity,places:o.context.places.map(c=>({place:c.place,epoch:c.epoch}))}}s(lr,"placeActReceiptsOf");function fr(e,t,r){(!r||typeof r!="object")&&E("missing instrument trust"),cr(r.budget),(typeof e!="string"||e.length>r.budget.bytes||We(e)>r.budget.bytes)&&E("byte budget");let n=Re({root:r.root,places:[t]},r.budget);t.records.includes(e)||E("original not in bound context"),ze(n,r)}s(fr,"verifyOriginalAtAuthorityContext");var ot=s(e=>({tokens:ce("alphabet",e,"tokens")}),"tokensOf"),Io={id:"alphabet",lattice:s(e=>oe.lattice(ot(e)),"lattice"),parse(e,t){let{tokens:r}=ot(e),n=_(t),o=n.members.find(i=>!r.includes(i));return o!==void 0&&te("alphabet",`\`${o}\` is not one of its tokens`),Q.fromTokens(r,new Set(n.polarity==="forbid"?r.filter(i=>!n.members.includes(i)):n.members))},emit:s((e,t)=>sr(t.members(ot(e).tokens)),"emit"),show:s((e,t)=>oe.lattice(ot(e)).show(t),"show"),points:s((e,t,r)=>oe.points(ot(e),t,r),"points")};var dr=s(e=>({lo:P("budget",e,"lo"),hi:P("budget",e,"hi")}),"span"),jo={id:"budget",lattice:s(e=>A.lattice(dr(e)),"lattice"),parse:s((e,t)=>X("budget",dr(e),t),"parse"),emit:s((e,t)=>ie(t),"emit"),show:s((e,t)=>A.lattice(dr(e)).show(t),"show"),points:s((e,t,r)=>A.points(dr(e),t,r),"points")};function nn(e){let t=ce("distribution",e,"buckets"),r=ce("distribution",e,"levels"),n=t.reduce(o=>o.flatMap(i=>r.map(a=>[...i,a])),[[]]);return{buckets:t,levels:r,tuples:n}}s(nn,"product");var rn=s(e=>{let{levels:t,tuples:r}=nn(e),n=s(o=>o.map(i=>t.findIndex(a=>a===i)),"at");return{levels:r.map(o=>JSON.stringify(o)),leq:r.map(o=>r.map(i=>n(o).every((a,c)=>a<=(n(i)[c]??-1))))}},"orderOver"),Mo={id:"distribution",lattice:s(e=>Y.lattice(rn(e)),"lattice"),parse(e,t){let{buckets:r,levels:n}=nn(e),o=s(u=>r.find(d=>!d.includes(":")&&u.startsWith(`${d}:`)),"bucketOf"),i=_(t).members,a=new Map(i.flatMap(u=>(d=>d===void 0?[]:[[d,u.slice(d.length+1)]])(o(u)))),c=i.find(u=>o(u)===void 0)??r.find(u=>!a.has(u));c!==void 0&&te("distribution",`\`${c}\` is not the bucket list it is given, every bucket named once`);let f=r.map(u=>Pe("distribution",n,a.get(u)??""));return{subject:"",floor:JSON.stringify(f.map(u=>u.floor)),ceiling:JSON.stringify(f.map(u=>u.ceiling))}},emit(e,t){let[r,n]=[JSON.parse(t.floor),JSON.parse(t.ceiling)];return sr(nn(e).buckets.map((o,i)=>r[i]===n[i]?`${o}:${r[i]}`:`${o}:${r[i]}..${n[i]}`))},show:s((e,t)=>Y.lattice(rn(e)).show(t),"show"),points:s((e,t,r)=>Y.points(rn(e),t,r),"points")};var ur=s(e=>({lo:P("interval",e,"lo"),hi:P("interval",e,"hi")}),"span"),Uo={id:"interval",lattice:s(e=>A.lattice(ur(e)),"lattice"),parse:s((e,t)=>X("interval",ur(e),t),"parse"),emit:s((e,t)=>ie(t),"emit"),show:s((e,t)=>A.lattice(ur(e)).show(t),"show"),points:s((e,t,r)=>A.points(ur(e),t,r),"points")};var pr=s(e=>({levels:ce("ladder",e,"levels")}),"over"),No={id:"ladder",lattice:s(e=>xe.lattice(pr(e)),"lattice"),parse:s((e,t)=>Pe("ladder",pr(e).levels,t),"parse"),emit:s((e,t)=>t.floor===t.ceiling?t.floor:`${t.floor}..${t.ceiling}`,"emit"),show:s((e,t)=>xe.lattice(pr(e)).show(t),"show"),points:s((e,t,r)=>xe.points(pr(e),t,r),"points")};function mr(e){let t=ce("lattice",e,"levels"),r=ir(e).leq;return(!Array.isArray(r)||r.length!==t.length||r.some(n=>!Array.isArray(n)||n.length!==t.length))&&te("lattice","takes leq as a square of truths over its levels"),{levels:t,leq:r}}s(mr,"orderOf");var Co={id:"lattice",lattice:s(e=>Y.lattice(mr(e)),"lattice"),parse:s((e,t)=>Pe("lattice",mr(e).levels,t),"parse"),emit:s((e,t)=>t.floor===t.ceiling?t.floor:`${t.floor}..${t.ceiling}`,"emit"),show:s((e,t)=>Y.lattice(mr(e)).show(t),"show"),points:s((e,t,r)=>Y.points(mr(e),t,r),"points")};var hr=s(e=>({lo:P("phase",e,"lo"),hi:P("phase",e,"hi")}),"span"),Bo={id:"phase",lattice:s(e=>A.lattice(hr(e)),"lattice"),parse:s((e,t)=>X("phase",hr(e),t),"parse"),emit:s((e,t)=>ie(t),"emit"),show:s((e,t)=>A.lattice(hr(e)).show(t),"show"),points:s((e,t,r)=>A.points(hr(e),t,r),"points")};var gr=s(e=>({lo:0,hi:P("rank",e,"n")}),"span"),To={id:"rank",lattice:s(e=>A.lattice(gr(e)),"lattice"),parse:s((e,t)=>X("rank",gr(e),t),"parse"),emit:s((e,t)=>ie(t),"emit"),show:s((e,t)=>A.lattice(gr(e)).show(t),"show"),points:s((e,t,r)=>A.points(gr(e),t,r),"points")};var yr=s(e=>({lo:P("stretch",e,"lo"),hi:P("stretch",e,"hi")}),"span"),Po={id:"stretch",lattice:s(e=>A.lattice(yr(e)),"lattice"),parse:s((e,t)=>X("stretch",yr(e),t),"parse"),emit:s((e,t)=>ie(t),"emit"),show:s((e,t)=>A.lattice(yr(e)).show(t),"show"),points:s((e,t,r)=>A.points(yr(e),t,r),"points")};var on=U(-1/0,1/0),qo=Kt(),Rs={K:1e3,M:1e6,G:1e9};function sn(e){let t=/^(-?\d+(?:\.\d+)?)([KMG])?\.\.((-?\d+(?:\.\d+)?)([KMG])?|\*)$/.exec(e);if(!t)return null;let r=s((n,o)=>Number(n)*(o?Rs[o]:1),"n");return{lo:r(t[1],t[2]),hi:t[3]==="*"?1/0:r(t[4],t[5])}}s(sn,"spanOf");function Wo(e){let t=e.startsWith("not:");return{polarity:t?"forbid":"permit",values:new Set((t?e.slice(4):e).split("|").filter(r=>r!==""&&r!=="none"))}}s(Wo,"idsOf");function Do(e){if(!e.length)return;if(e[0].form==="interval"){let o=e.map(i=>sn(i.value));return o.every(i=>i!==null)?{L:on,spans:o}:void 0}if(e[0].form!=="alphabet")return;let t="\0",r=e.map(o=>({forbid:o.value.startsWith("not:"),names:(o.value.startsWith("not:")?o.value.slice(4):o.value).split("|").filter(Boolean)})),n={tokens:[...new Set([t,...r.flatMap(o=>o.names)])].sort()};return{L:oe.lattice(n),spans:r.map(o=>oe.parse(n,{want:o.forbid?n.tokens.filter(i=>!o.names.includes(i)):o.names}))}}s(Do,"configurationValues");var it=".bound",zo=`TARGET${it}`,Lo=`capsule${it}`,Ko=`receipts${it}`;var _s=U(-1/0,1/0),$s={count:"sum",size:"sum",shown:"sum",longest:"max"};function Ho(e,t){let r=$s[e];if(r==="max")return t.reduce((n,o)=>_s.join(n,{lo:-1/0,hi:o}),{lo:-1/0,hi:0}).hi;if(r==="sum"||t.length<=1)return t.reduce((n,o)=>n+o,0);throw new Error(`REFUSE\xB7measure ${e}: ${t.length} readings and no combination the wire names for them`)}s(Ho,"combine");function Jo(e,t){let r=s(d=>R(`object context: ${d}`),"fail"),n=new Map;for(let d of e){if(!t.admit(d))return r(`signature or authority does not admit ${d.fields.id}`);let l=n.get(d.fields.id);if(l&&z(l.fields)!==z(d.fields))return r(`record ID collision ${d.fields.id}`);l||n.set(d.fields.id,d)}let o=[...n.values()],i=new Map(o.map((d,l)=>[d.fields.id,l])),a=new Map;for(let d of o.filter(l=>l.record==="cell")){if(a.has(d.fields.scope))return r(`cell definition is not unique at ${d.fields.scope}`);a.set(d.fields.scope,d)}let c=new Map;for(let[d,l]of a)try{let p=t.resolve(l);if(p.digest!==l.fields.topos||p.form.id!==l.fields.form)return r(`selected digest/form does not match ${d}`);p.form.lattice(p.params),c.set(d,p)}catch(p){return r(`codec/pin/decoder stop at ${d}: ${String(p)}`)}let f=new Map;for(let[d,l]of a){let p=Oe(l.fields.restsOn);if(p===void 0)return r(`invalid declared rest at ${d}`);for(let m of p){let g=a.get(m);if(!g)return r(`missing rest target ${m}`);if(Number(g.fields.epoch)>Number(l.fields.epoch))return r(`rest target ${m} did not exist at cell declaration`);if(["topos","form","params","measure"].some(h=>g.fields[h]!==l.fields[h]))return r(`incompatible rest component ${d}/${m}`)}f.set(d,p)}let u=new Map;for(let d of a.keys()){if(u.get(d)===2)continue;let l=[{name:d,exit:!1}];for(;l.length;){let p=l.pop();if(p.exit){u.set(p.name,2);continue}if(u.get(p.name)===1)return r(`declared rest cycle reachable from ${d}`);if(u.get(p.name)!==2){u.set(p.name,1),l.push({name:p.name,exit:!0});for(let m of[...f.get(p.name)].reverse())l.push({name:m,exit:!1})}}}for(let d of o.filter(l=>l.record!=="cell")){let l=d.fields,p=a.get(l.scope);if(!p||Number(p.fields.epoch)>Number(l.epoch)||Number(p.fields.epoch)===Number(l.epoch)&&i.get(p.fields.id)>i.get(l.id))return r(`cell not declared before ${l.id}`);if(l.sign==="-1"){let m=n.get(l.takes);if(!m||m.record!==d.record||m.fields.scope!==l.scope||m.fields.sign!=="+1"||m.fields.by!==l.by||Number(m.fields.epoch)>=Number(l.epoch))return r(`unauthorized or incompatible withdrawal target ${l.takes}`)}else{let m=c.get(l.scope);try{m.form.parse(m.params,l.value)}catch(g){return r(`span codec stop at ${l.id}: ${String(g)}`)}if(d.record==="claim"&&!t.origin(l.origin,l.by,l.scope))return r(`origin is not attested for ${l.id}`);if(l.widens!==void 0&&!t.witness(l.widens,l.by,l.scope))return r(`join witness is not admitted for ${l.id}`)}}for(let d of a.keys()){let l=new Set,p=[...f.get(d)];for(;p.length;){let h=p.pop();l.has(h)||(l.add(h),p.push(...f.get(h)))}let m=o.filter(h=>h.record==="mark"&&h.fields.sign==="+1"&&h.fields.pole==="ceiling"&&(h.fields.scope===d||l.has(h.fields.scope)&&h.fields.reach==="travels")),g=new Map;for(let h of m)g.set(h.fields.epoch,[...g.get(h.fields.epoch)??[],h]);for(let h of g.values())if(h.length>1&&h.some(y=>y.fields.widens!==void 0))return r(`ambiguous same-epoch ceiling acts at ${d}`)}return D(o)}s(Jo,"validateObjectContext");function br(e){let t=S(e,{preserveKeys:!0});if(t.kind!=="fact")return t;if(!t.value.keys.includes("type"))return D("config");let r=t.value.fields.type;return r==="cell"||r==="claim"||r==="mark"?D(r):R("an explicit type names cell, claim or mark","type")}s(br,"recordKind");function Vo(e){let t=[];for(let o of e){let i=S(o);if(i.kind!=="fact")return i;t.push(i.value.fields)}let r=[],n=[];for(let o=0;o<e.length;o++){let i=br(e[o]);if(i.kind!=="fact")return i;if(i.value==="config"){n.push(t[o]);continue}let a=ae(e[o],Be(t,Number(t[o].epoch)));if(a.kind!=="fact")return a;if(!("record"in a.value))throw Error("typed history returned configuration");r.push(a.value)}return D({objects:r,configuration:n})}s(Vo,"objectHistory");function Go(e){return e.map(t=>{let r=S(t);if(r.kind!=="fact")throw Error(`REFUSE\xB7publication ${r.why}`);let n=r.value.fields;if(n.value==="withdraw")throw Error("REFUSE\xB7publication a withdrawal is history, not standing");if(n.type!==void 0)throw Error("REFUSE\xB7publication object history needs its semantic projection");if(Qo(n))return x(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!Ce.has(i)));return x({...o,by:"target"})}).sort(v)}s(Go,"publicationOf");function Xo(e){let t=e.map(r=>{let n=S(r);if(n.kind!=="fact")throw Error(`REFUSE\xB7publication ${n.why}`);return n.value.fields});if(!t.some(r=>r.sig!==void 0&&!Qo(r))){for(let r of t){if(r.type!==void 0)throw Error("REFUSE\xB7publication object history needs its semantic projection");if(r.sig===void 0&&r.by!==void 0&&r.by!=="target")throw Error("REFUSE\xB7publication unsigned delivery signer");if(r.value==="withdraw")throw Error("REFUSE\xB7publication withdrawal in a public lock");if(r.sig===void 0&&[...Ce].some(n=>n!=="by"&&r[n]!==void 0))throw Error("REFUSE\xB7publication delivery envelope in a public lock")}return[...e]}}s(Xo,"publicLock");function Qo(e){return e.scope?.startsWith("keys/")===!0&&e.measure==="public-key"}s(Qo,"isPublicKey");function Yo(e){if(!e.bytes.length)throw new Error("REFUSE\xB7signer empty lot");for(let t of e.bytes){let r=S(t);if(r.kind!=="fact"||r.value.fields.sig!==void 0||r.value.fields.by!==e.keyId||z(r.value.fields)!==t)throw new Error("REFUSE\xB7signer noncanonical payload")}return e.bytes.join(`
22
+ `))throw Error(`REFUSE\xB7port ${e.coordinate} incomplete response frame`);let o;try{o=JSON.parse(r.stdout)}catch{throw Error(`REFUSE\xB7port ${e.coordinate} invalid response frame`)}if(!o||o.protocol!=="command-lot/1"||o.coordinate!==e.coordinate||o.implementation!==e.implementation||o.identity!==t.identity||!Array.isArray(o.responses)||o.responses.length!==t.requests.length)throw Error(`REFUSE\xB7port ${e.coordinate} response does not bind this lot`);if(o.responses.some((i,a)=>!n(i,a)))throw Error(`REFUSE\xB7port ${e.coordinate} invalid response member`);return o.responses}s(an,"commandResponse");function it(e,t){if(!e.coordinate)throw Error("REFUSE\xB7policy missing field coordinate");if(!["meet","exact","own"].includes(e.mode))throw Error(`REFUSE\xB7policy ${e.coordinate} undeclared composition`);let r=t.filter((a,c)=>t.findIndex(l=>l.source===a.source&&l.value===a.value&&l.own===a.own)===c);if(!r.length)return{kind:"unread",evidence:[]};if(r.some(a=>!a.source))throw Error(`REFUSE\xB7policy ${e.coordinate} missing attribution`);let n=r.filter(a=>a.own),o=e.mode==="own"&&n.length?n:r;if(e.mode!=="meet"){if(new Set(o.map(c=>c.value)).size!==1)return{kind:"incompatible",evidence:r};let a=e.decode(o[0].value);return{kind:e.inhabited(a)?"compatible":"incompatible",value:a,evidence:r}}let i=o.map(a=>e.decode(a.value)).reduce((a,c)=>e.lattice.meet(a,c));return{kind:e.inhabited(i)?"compatible":"incompatible",value:i,evidence:r}}s(it,"composePolicy");function Rt(e,t,r){if(e.mode!=="meet")return"non-meet";if(!e.inhabited(r))return"incompatible";let n=e.lattice.leq;return n(t,r)&&n(r,t)?"compatible":n(r,t)?"narrowing":"widening-needs-authority"}s(Rt,"policyTransition");function cn(e,t,r){if(!e)throw Error("REFUSE\xB7lineage missing current release");let n=new Map;for(let o of t){if(!o.digest||!o.predecessor||!r(o))throw Error("REFUSE\xB7lineage unauthenticated release");let i=n.get(o.digest);if(i&&i.predecessor!==o.predecessor)throw Error(`REFUSE\xB7lineage ${o.digest} conflicting predecessor`);n.set(o.digest,o)}for(let o of n.keys()){let i=new Set,a=o;for(;a&&n.has(a);){if(i.has(a))throw Error(`REFUSE\xB7lineage ${o} predecessor cycle`);i.add(a),a=n.get(a).predecessor}}return[...n.values()].filter(o=>o.predecessor===e&&o.digest!==e).sort((o,i)=>w(o.digest,i.digest))}s(cn,"releaseSuccessors");function ln(e,t){let r=new Map;for(let c of e){if(!c.digest||c.bytes!==null&&(!Number.isSafeInteger(c.bytes)||c.bytes<0))throw Error("REFUSE\xB7weight invalid verified byte reading");let l=r.get(c.digest);if(l&&l.bytes!==c.bytes)throw Error(`REFUSE\xB7weight ${c.digest} conflicting byte reading`);r.set(c.digest,{...c,named:c.named||(l?.named??!1)})}let n=[...r.values()],o=n.reduce((c,l)=>c+(l.bytes??0),0);if(!Number.isSafeInteger(o))throw Error("REFUSE\xB7weight byte sum exceeds exact range");let i=t&&n.every(c=>c.bytes!==null);return{unit:"bytes",known:i||n.some(c=>c.bytes!==null)?o:null,total:i?o:null,unreferenced:i?n.filter(c=>!c.named).reduce((c,l)=>c+l.bytes,0):null}}s(ln,"weightOf");function dn(e,t,r,n){if(!Number.isSafeInteger(e)||e<0||!Number.isSafeInteger(t)||t<=0||r.some(i=>!Number.isSafeInteger(i)||i<0||i>e))throw Error("REFUSE\xB7vacuous invalid declared epoch window");let o=Math.max(0,e-t+1);return{unit:"epochs",from:o,through:e,reading:r.some(i=>i>=o)?"observed":n?"unobserved":"unknown"}}s(dn,"vacuityOf");function un(e,t){let r=new Set(t);for(let n of e)if(!n||!r.has(n))throw Error(`REFUSE\xB7inspection unknown coordinate ${n||"(absent)"}`);return[...new Set(e)].sort(w)}s(un,"inspectionSelection");function fn(e){let t=s(u=>{throw Error("REFUSE\xB7program "+u)},"fail"),r=s((u,d)=>{(u.some(p=>!p)||new Set(u).size!==u.length)&&t("duplicate or empty "+d)},"unique");e.minimum.length||t("minimum is absent; vacuity cannot close a program"),r(e.minimum,"minimum coordinate");for(let[u,d]of e.evidence)(!u||!["met","unmet","unread","refused"].includes(d))&&t("unsupported evidence status "+u);let n=new Map;for(let u of e.programs)(!u.scope||n.has(u.scope))&&t("duplicate or empty coordinate "+u.scope),r(u.needs,"requirement at "+u.scope),r(u.restsOn,"dependency at "+u.scope),n.set(u.scope,u);for(let u of e.minimum)n.has(u)||t("unknown minimum "+u);let o=new Map,i=[];for(let u of[...n.keys()].sort(w)){let d=[{scope:u,exit:!1}];for(;d.length;){let p=d.pop();if(p.exit){o.set(p.scope,2),i.push(p.scope);continue}if(o.get(p.scope)===2)continue;o.get(p.scope)===1&&t("dependency cycle "+p.scope);let h=n.get(p.scope);h||t("unknown dependency "+p.scope),o.set(p.scope,1),d.push({...p,exit:!0});for(let g of[...h.restsOn].sort(w).reverse())d.push({scope:g,exit:!1})}}for(let[u,d]of[["elapsed",e.elapsed],["ceiling",e.ceiling]])d!==void 0&&(!Number.isFinite(d)||d<0)&&t("invalid "+u+" reading");let a=e.elapsed===void 0||e.ceiling===void 0?"unread":e.elapsed>e.ceiling?"over":"within",c=new Set(e.minimum),l=new Map,f=i.map(u=>{let d=n.get(u),p=d.restsOn.filter(y=>l.get(y)!=="met").sort(w),h=d.needs.filter(y=>["unmet","refused"].includes(e.evidence.get(y)??"")).sort(w),g=d.needs.filter(y=>!e.evidence.has(y)||e.evidence.get(y)==="unread").sort(w),m=p.length?"blocked":h.length?"unmet":g.length||!d.needs.length?"unread":"met";return l.set(u,m),{scope:u,status:m,blocked:p,missing:h,unread:g,carry:a==="over"&&!c.has(u)&&m!=="met"}});return{deadline:a,rows:f,next:f.filter(u=>u.status!=="met"&&!u.blocked.length&&!u.carry).map(u=>u.scope),closed:e.minimum.every(u=>l.get(u)==="met")}}s(fn,"programsOf");var Zo=["declared","statistics","sample","exact"];function pn(e){let t=Wt(Zo),r=[...e].map(n=>No("evidence",{floor:Zo[0],ceiling:n}));return r.length===0?"exact":is(t,r).ceiling}s(pn,"weakest");var ga=["transitivity","antisymmetry"],ha=["idempotence.meet","unit.top","top.greatest","commutativity.meet","consistency.meet","associativity.meet"],ya=["idempotence.join","unit.bottom","bottom.least","commutativity.join","consistency.join","associativity.join"],ba=["absorption.meet","absorption.join"],Ql=[...ga,...ha,...ya,...ba],mn=s((e,t,r)=>`${t}: ${r.map(n=>e.show(n)).join(" , ")}`,"sayAt");function wa(e,t){let r=[],n=s((o,i)=>tt(e,o,i),"same");for(let o of t)for(let i of t){e.leq(o,i)&&e.leq(i,o)&&!n(o,i)&&r.push(mn(e,"antisymmetry",[o,i]));for(let a of t)e.leq(o,i)&&e.leq(i,a)&&!e.leq(o,a)&&r.push(mn(e,"transitivity",[o,i,a]))}return r}s(wa,"posetViolationsIn");function va(e,t){let r=[...wa(e,t)],n=s((i,a)=>tt(e,i,a),"same"),o=s((i,...a)=>{r.push(mn(e,i,a))},"say");for(let i of t){n(e.meet(i,i),i)||o("idempotence.meet",i),n(e.meet(i,e.top),i)||o("unit.top",i),e.leq(i,e.top)||o("top.greatest",i);for(let a of t){n(e.meet(i,a),e.meet(a,i))||o("commutativity.meet",i,a),e.leq(i,a)!==n(e.meet(i,a),i)&&o("consistency.meet",i,a);for(let l of t)n(e.meet(e.meet(i,a),l),e.meet(i,e.meet(a,l)))||o("associativity.meet",i,a,l)}}return r}s(va,"meetViolationsIn");function ei(e,t){let r=[...va(e,t)],n=s((i,a)=>tt(e,i,a),"same"),o=s((i,...a)=>{r.push(mn(e,i,a))},"say");for(let i of t){n(e.join(i,i),i)||o("idempotence.join",i),n(e.join(i,e.bottom),i)||o("unit.bottom",i),e.leq(e.bottom,i)||o("bottom.least",i);for(let a of t){n(e.join(i,a),e.join(a,i))||o("commutativity.join",i,a),n(e.meet(i,e.join(i,a)),i)||o("absorption.meet",i,a),n(e.join(i,e.meet(i,a)),i)||o("absorption.join",i,a),e.leq(i,a)!==n(e.join(i,a),a)&&o("consistency.join",i,a);for(let l of t)n(e.join(e.join(i,a),l),e.join(i,e.join(a,l)))||o("associativity.join",i,a,l)}}return r}s(ei,"violationsIn");function Ea(e){return e!==""&&!/[\s\\|]/.test(e)&&e.split("/").every(t=>t!==""&&t!=="."&&t!==".."&&t!=="*"&&t!=="**")}s(Ea,"coordinateText");function st(e){try{let t=M(e);if(t.polarity!=="permit"||t.members.some(n=>!Ea(n)))return;let r=[...new Set(t.members)].sort(w);return M({polarity:"permit",members:r})!==e?void 0:r}catch{return}}s(st,"restCoordinates");var Zl=["type","scope","id","epoch","by","sig"];function xa(e,t,r,n,o){let i=s((u,d)=>$(u,d),"bad");if(t.includes("at"))return i("object records carry no at: order is epoch and a local join witness is widens","at");let a=e.type;if(!r.types.has(a??"")||!["cell","claim","mark"].includes(a??""))return i("an object record names a declared type: cell, claim or mark","type");if(!/^(0|[1-9][0-9]*)$/.test(e.epoch??"")||!Number.isSafeInteger(Number(e.epoch)))return i("an object record carries an exactly supported logical epoch","epoch");if(Number(e.epoch)<r.activation)return i(`an object epoch precedes typed-wire activation ${r.activation}`,"epoch");let c;if(a==="cell")c="cell";else if(e.sign==="-1")c=`${a}/negative`;else{if(e.sign!=="+1")return i("a claim or mark names sign=+1 or sign=-1","sign");if(a==="claim")c="claim/positive";else if(e.pole==="floor"&&e.reach==="travels"&&e.widens===void 0)c="mark/floor-travelling";else if(e.pole==="ceiling"&&e.reach==="travels"&&e.widens===void 0)c="mark/travelling";else if(e.pole==="ceiling"&&e.reach==="local")c="mark/local";else return i("a positive mark is ceiling/travels, ceiling/local with widens, or floor/travels without widens","pole")}let l=r.required.get(c),f=r.allowed.get(c);if(!l||!f||r.common.size===0||r.configuration.size===0||[...r.common].some(u=>!l.has(u)||!f.has(u))||[...l].some(u=>!f.has(u)))return i(`typed wire has no complete required/allowed contract for ${c}`,"type");for(let u of Zl)if(e[u]===void 0||e[u]==="")return i(`an object record has no ${u}`,u);for(let u of t)if(!n.has(u)||!f.has(u))return i(`\`${u}=\` is not allowed on ${c}`,u);for(let u of l)if(!f.has(u)||e[u]===void 0||e[u]==="")return i(`a ${c} record has no declared required \`${u}\``,u);if(!Ea(e.scope))return i("scope is a canonical cell coordinate","scope");if(a==="cell"){if(!o.has(e.form))return i("the cell names no admitted form","form");if(st(e.restsOn)===void 0)return i("cell restsOn is none or a canonical alphabet of coordinates","restsOn")}return fe({record:a,fields:{...e}})}s(xa,"objectFromFields");function gn(e,t){return`${e}:${t}`}s(gn,"formatSignature");function Re(e){let t=e.lastIndexOf(":");return t<=0||t===e.length-1?null:{algorithm:e.slice(0,t),raw:e.slice(t+1)}}s(Re,"parseSignature");function hn(e,t){let r={...e,by:t};return delete r.sig,r}s(hn,"signedFieldsOf");function yn(e,t){return e!==""&&le(he(t,"./"),he(e,"./"))}s(yn,"under");var Ot=new Set(["sig","expires","repo","by","epoch"]),Qt="withdraw",St="wire/",vn="audit/wire/";function Oa(e){let t=e.scope??"";return t.startsWith(St)||t.startsWith(vn)}s(Oa,"isWireClaim");function bn(e){if(e.startsWith(vn))return e.slice(vn.length);if(e.startsWith(St))return e.slice(St.length)}s(bn,"listOf");function U(e){let t=e.epoch??"";return/^\d+$/.test(t)?Number(t):0}s(U,"epochOf");function Ra(e,t){return Object.keys(e).filter(r=>r!=="value"&&!Ot.has(r)).every(r=>t[r]===e[r])}s(Ra,"names");function _t(e,t){let r=e.filter(d=>bn(d.scope??"")!==void 0&&U(d)<=t),n=r.filter(d=>d.value===Qt),o=new Map;for(let d of r){if(d.value===Qt||n.some(m=>Ra(m,d)))continue;let p=(bn(d.scope??"")??"")+"\0"+(d.by??""),h=o.get(p)??[],g=h.length?U(h[0]):-1;U(d)>g?o.set(p,[d]):U(d)===g&&o.set(p,[...h,d])}let i=[...o.values()].flatMap(d=>d.some(p=>(p.scope??"").startsWith(St))?d.filter(p=>(p.scope??"").startsWith(St)):d),a=new Map;for(let d of i){let p=bn(d.scope??"")??"",h=a.get(p);if(h!==void 0&&h!==d.value)throw Error(`REFUSE\xB7wire wire/${p} has conflicting live declarations`);a.set(p,d.value??"")}let c=new Map;for(let d of r){let p=bn(d.scope??"")??"";if(d.value===Qt||n.some(m=>Ra(m,d)))continue;let h=c.get(p);(h===void 0||U(d)>U(h)||U(d)===U(h)&&(d.scope??"").startsWith(St)&&(h.scope??"").startsWith(vn))&&c.set(p,d)}if(!c.size)return null;let l=s(d=>new Set((c.get(d)?.value??"").split("|").filter(Boolean)),"ids"),f=new Map([...c].filter(([d])=>d.startsWith("form/")).map(([d,p])=>[d.slice(5),p.value??""])),u=new Map([...c.keys()].filter(d=>!d.includes("/")).map(d=>[d,l(d)]));return{epoch:t,...c.has("object/types")?{object:{activation:U(c.get("object/types")),types:l("object/types"),common:l("object/common"),reserved:l("object/reserved"),configuration:l("object/allowed/config"),required:new Map([...c.keys()].filter(d=>d.startsWith("object/required/")).map(d=>[d.slice(16),l(d)])),allowed:new Map([...c.keys()].filter(d=>d.startsWith("object/allowed/")).map(d=>[d.slice(15),l(d)]))}}:{},fields:l("fields"),required:l("required"),roles:l("roles"),forms:l("forms"),classes:l("at-classes"),digests:new Set([...l("digest-algorithms")].map(d=>d.split(":")[0])),signatures:l("signature-algorithms"),formOf:f,lists:u}}s(_t,"wireAt");function En(e,t){let r=e.indexOf(":");return r>0&&t.digests.has(e.slice(0,r))&&/^[0-9a-f]+$/i.test(e.slice(r+1))}s(En,"admittedDigest");function ed(e){if(e.startsWith("/")||/[\s\\]/.test(e))return!1;let t=e.split("/").filter(r=>r!=="");return t.length>0&&t.every((r,n)=>r!=="."&&r!==".."&&(!r.includes("*")||n===t.length-1))}s(ed,"isRegion");var Sa={region:s(e=>e.split("|").filter(Boolean).every(ed),"region"),class:s((e,t)=>{let r=e.indexOf(":");if(r<=0||!t.classes.has(e.slice(0,r)))return!1;let n=e.slice(r+1);return!/^[a-z0-9-]+:[0-9a-f]{16,}$/i.test(n)||En(n,t)},"class"),signature:s((e,t)=>{let r=Re(e);if(r===null||!t.signatures.has(r.algorithm))return!1;let n=r.algorithm.slice(r.algorithm.lastIndexOf(":")+1);return En(r.algorithm,t)||r.algorithm.includes(":")&&(t.lists.get("era")?.has(n)??!1)},"signature"),count:s(e=>/^\d+$/.test(e),"count")};function wn(e,t){return $(t,e)}s(wn,"debit");function Se(e,t,r){let n=x(e,{preserveKeys:!0});if(n.kind!=="fact")return n.kind==="abstain"?We(n.why):$(n.why,n.named);let o=n.value.fields,i=n.value.keys;if(i.includes("type")){if(!t?.object)return $("typed object grammar is not admitted at this epoch","type");if(!t.object.configuration.size||!t.object.reserved.size||[...t.object.reserved].some(g=>t.object.configuration.has(g)))return $("typed wire has no closed configuration/object field contract","type");let h=xa(o,i,t.object,t.fields,t.forms);return h.kind!=="fact"?h:Sa.signature(o.sig,t)?h.value.record==="cell"&&!En(o.topos,t)?$("cell topos is not an admitted digest","topos"):h.value.record==="cell"&&(o.restsOn??"").split("|").some(g=>En(g,t))?$("cell restsOn names coordinates, not byte digests","restsOn"):h:$("object signature grammar is not admitted","sig")}if(t){if(t.object){if(!t.object.configuration.size||!t.object.reserved.size||[...t.object.reserved].some(g=>t.object.configuration.has(g)))return $("typed wire has no closed configuration/object field contract","type");let h=i.find(g=>t.object.reserved.has(g)||!t.object.configuration.has(g));if(h)return $(`\`${h}=\` is an object-only field: untyped configuration cannot carry it`,h)}for(let h of Object.keys(o))if(!t.fields.has(h))return wn(h,`\`${h}=\` is not a field of the wire at epoch ${t.epoch}`);for(let h of t.required)if(o[h]===void 0)return wn(h,`a claim with no \`${h}\``);for(let[h,g]of t.formOf){let m=o[h];if(m===void 0)continue;let y=t.lists.get(g),b=Sa[g]??(y?F=>y.has(F):void 0);if(!b)return We(`\`${h}\` takes the form ${g}, which this reader does not know`);if(!b(m,t))return wn(h,`\`${h}=${m}\` is not a ${g} of the wire at epoch ${t.epoch}`)}if(o.role!==void 0&&!t.roles.has(o.role))return We(`\`role=${o.role}\` is a role this wire does not name`);if(!t.forms.has(o.form??""))return We(`\`form=${o.form}\` is a form this wire does not name`)}let a=Array.isArray(r)?r:void 0,c=o.value===Qt?{kind:"enumerated",values:[Qt]}:Ce(o.form??"",o.value??"",a);if(c===null)return Qs.includes(o.form??"")||(a?.some(g=>g.form===o.form)??!1)?wn("value",`\`${o.value}\` is not a ${o.form}`):We(`\`form=${o.form}\` is a form this reader does not know`);let l=o.role==="writes"?"writes":o.role==="demands"?"demands":"reads",f={};for(let[h,g]of Object.entries(o))["scope","measure","form","value","by","at","role","unit","multiplicity","epoch","ref","to","ref_by"].includes(h)||(f[h]=g);let u=o.ref,d=o.to===void 0?null:bt(o.to),p=u&&d&&Zs.includes(u)?{rel:u,to:d,by:o.ref_by==="declared"?"declared":"inferred"}:null;return fe({scope:o.scope??"",measure:o.measure??"",bound:c,role:l,by:o.by??"",at:o.at??"",...o.unit!==void 0?{unit:o.unit}:{},...o.multiplicity==="one"||o.multiplicity==="many"||o.multiplicity==="unknown"?{multiplicity:o.multiplicity}:{},...o.epoch!==void 0?{epoch:o.epoch}:{},...p?{reference:p}:{},extra:f})}s(Se,"fromLine");var He="keys";function _a(e){let t=e.scope??"";return t===He||t.startsWith(`${He}/`)}s(_a,"isKeyClaim");function ri(e){let t=/^(\d+)\.\.(\d+)$/.exec(e);return t?{lo:Number(t[1]),hi:Number(t[2])}:null}s(ri,"depthWindow");var kt=ne(-1/0,1/0),ti=ne(1,1/0);function Ia(e){return e.epoch??{start:0,close:null}}s(Ia,"windowOf");function xn(e,t){let r=Ia(e),n=(e.windows??[]).filter(o=>t>=o.from&&(o.to===null||t<o.to));return n.length?{start:r.start,close:n.reduce((o,i)=>kt.meet(o,i),kt.top).hi}:r}s(xn,"windowAt");function td(e,t){let r=xn(e,t);return t>=r.start&&(r.close===null||t<=r.close)}s(td,"inside");function Aa(e){let t=s(n=>[n.role,n.form,n.at].join(" "),"claim"),r=new Map;for(let n of e)n.value==="withdraw"&&r.set(t(n),kt.meet(r.get(t(n))??kt.top,{lo:-1/0,hi:U(n)}));return n=>r.get(t(n))?.hi??null}s(Aa,"standsUntil");function rd(e){let t=Aa(e),r=e.filter(n=>n.value!=="withdraw").map(n=>({globs:(n.value??"").split("|").filter(Boolean),from:U(n),to:t(n)})).filter(n=>n.to===null||n.from<n.to);return{coverage:[...new Set(r.filter(n=>n.to===null).flatMap(n=>n.globs))],spans:r}}s(rd,"coverageOver");function ka(e){let t=Aa(e);return e.filter(r=>r.value!=="withdraw").flatMap(r=>(n=>n===null?[]:[{...n,from:U(r),to:t(r)}])(ri(r.value??""))).filter(r=>r.to===null||r.from<r.to)}s(ka,"windowsOver");function Fa(e,t,r){let n=e.filter(d=>d.scope===He&&d.measure==="quorum"&&d.by===t.id&&r(d,t.publicKey)).sort((d,p)=>U(d)-U(p)),o=s(d=>{let p=n.filter(h=>U(h)<=d).pop();return ti.meet(ti.top,ri(p?.value??"")??ti.top).lo},"quorumAt"),i=[...new Set(e.filter(d=>["class","public-key","coverage","epoch"].includes(d.measure??"")).map(d=>d.scope??"").filter(d=>d.startsWith(`${He}/`)).map(d=>d.slice(He.length+1)))],a=s((d,p)=>{let h=p.get(d.id);return h===void 0?d:{...d,epoch:{start:Ia(d).start,close:h}}},"closedAt"),c=s((d,p,h)=>e.filter(g=>{let m=d.get(g.by??"");return g.scope===`${He}/${p}`&&g.measure===h&&m!==void 0&&m.keyClass==="authorize"&&td(m,U(g))&&r(g,m.publicKey)}),"claimsOn"),l=s(d=>{let p=new Map([[t.id,a(t,d)]]);for(let h=!0;h;){h=!1;for(let g of i){if(p.has(g))continue;let m=c(p,g,"class"),y=new Set(m.filter(k=>k.value==="withdraw").map(k=>`${k.by??""} ${k.at??""}`)),b=m.filter(k=>k.value!=="withdraw"&&!y.has(`${k.by??""} ${k.at??""}`)).sort((k,z)=>U(k)-U(z)),F=m.filter(k=>k.value!=="withdraw").sort((k,z)=>U(k)-U(z)),P=[],G=null;for(let k of F){let z=k.by??"";if(P.includes(z)||P.push(z),P.length>=o(U(k))){G=U(k);break}}let ge=c(p,g,"public-key")[0]?.value??"";if(G===null||!b.length||!ge)continue;let N=e.some(k=>(k.by??"")===g&&U(k)===1&&!(k.scope??"").startsWith(`${He}/`)),C=rd(c(p,g,"coverage"));p.set(g,a({id:g,keyClass:b.every(k=>k.value==="authorize")?"authorize":"attest",publicKey:ge,coverage:C.coverage,spans:N?C.spans.map(k=>({...k,from:Math.min(k.from,1)})):C.spans,windows:ka(c(p,g,"epoch")),depth:ri(c(p,g,"resolution")[0]?.value??"")??{lo:1,hi:1},admittedBy:P,epoch:{start:N?Math.min(G,1):G,close:null}},d)),h=!0}}return p},"admitUnder"),f=new Map;for(let d=0;d<=i.length+1;d++){let p=l(f),h=new Map;for(let m of p.keys()){let y=ka(c(p,m,"epoch")).filter(b=>b.to===null);y.length&&h.set(m,y.reduce((b,F)=>kt.meet(b,F),kt.top).hi)}if(!(h.size!==f.size||[...h].some(([m,y])=>f.get(m)!==y)))return{admitted:[...p.values()],potential:i.filter(m=>!p.has(m))};f=h}let u=l(f);return{admitted:[...u.values()],potential:i.filter(d=>!u.has(d))}}s(Fa,"signersOf");function Rn(e,t,r,n){let o=e.by??"";if(n!==void 0&&!e.sig&&o==="target")return n.pins.includes(n.digest)?{kind:"admitted",signer:o}:{kind:"grey",why:`unpinned: no sources/ or uses/ line names ${n.digest}`};if(n!==void 0&&e.sig&&!t.some(a=>a.id===o))return{kind:"refuse",why:`REFUSE\xB7authority ${o||"\u2205"} is no key this release carries`,named:o};if(!e.sig)return{kind:"grey",why:"unsigned"};let i=t.find(a=>a.id===o);return i?r(e,i.publicKey)?It(e,i,U(e)):{kind:"grey",why:`the signature does not hold for ${o}`}:{kind:"grey",why:`signer ${o||"\u2205"} is not admitted`}}s(Rn,"authorityOf");function It(e,t,r,n=e.scope??"",o="record"){let i=e.by??"";if(o==="authority"&&(!Number.isSafeInteger(r)||r<0))return{kind:"refuse",why:`REFUSE\xB7authority ${i||"\u2205"} has unknown or invalid authority epoch`,named:i};let a=o==="authority"?"authority evaluated at epoch":"signed at epoch",c=xn(t,r);if(c.close!==null&&r>c.close)return{kind:"refuse",why:`REFUSE\xB7authority ${i} ${a} ${r}, after its epoch closed at ${c.close}`,named:i};if(r<c.start)return{kind:"grey",why:`${a} ${r}, before ${i} was admitted at ${c.start}`};let l=n;if(!(t.spans===void 0?t.coverage:t.spans.filter(d=>r>=d.from&&(d.to===null||r<d.to)).flatMap(d=>d.globs)).some(d=>d==="*"||yn(d,l)))return{kind:"refuse",why:`REFUSE\xB7authority ${i} does not cover ${l}`,named:i};let u=qe(he(e.scope??""));return u<t.depth.lo||u>t.depth.hi?{kind:"refuse",why:`REFUSE\xB7authority ${i} may not sign at depth ${u}`,named:i}:le(he(e.scope??""),he(He))&&t.keyClass!=="authorize"?{kind:"refuse",why:`REFUSE\xB7authority ${i} is attest and cannot admit signers`,named:i}:{kind:"admitted",signer:i}}s(It,"authorityAtEpoch");var nd=["source","derived","observed","foreign"],od=["coordinate-role/","leaf-role/"],id=["foreign","derived","observed"],sd=new Map([["source","source"],["render","derived"],["receipt","derived"]]);function Ca(e){return e.flatMap(t=>{let r=t.scope??"",n=t.value??"",o=sd.get(t.role??"");if(r.startsWith("region/")&&t.measure==="paths"&&o!==void 0&&n!=="withdraw")return n.split("|").filter(Boolean).map(a=>({name:a,role:o}));let i=od.find(a=>r.startsWith(a));return i===void 0||t.measure!=="role"||!nd.includes(n)?[]:[{name:r.slice(i.length),role:n}]})}s(Ca,"roleClaimsOf");function Na(e,t){return gt(he(e),t)}s(Na,"namesAt");function ja(e,t){let r={at:he(e).at,epoch:0,seen:[]};return Co([r],t.map(n=>[n.name,n.role]),id)??"source"}s(ja,"roleAt");var $a=s((e,t)=>ei(e,t),"violationsIn"),Sn=s(e=>e!==null&&typeof e=="object"?e:{},"paramsOf");function ke(e,t){throw new Error(`REFUSE\xB7form ${e}: ${t}`)}s(ke,"refuseForm");function se(e,t,r){let n=Sn(t)[r];return(typeof n!="number"||!isFinite(n))&&ke(e,`takes ${r} as a number, and a value it is not given is not invented`),n}s(se,"numberAt");function Be(e,t,r){let n=Sn(t)[r];return(!Array.isArray(n)||!n.length||n.some(o=>typeof o!="string"))&&ke(e,`takes ${r} as a list of words`),n}s(Be,"wordsAt");var kn=s(e=>M({polarity:"permit",members:[...new Set(e)].sort(w)}),"written");function we(e,t,r){if(r==="empty")return{lo:t.hi,hi:t.lo};let n=s(o=>(i=>i.kind==="fact"&&i.value.bound.kind==="interval"?{lo:i.value.bound.lo??t.lo,hi:i.value.bound.hi??t.hi}:void 0)(Se(v({form:"interval",value:o}),null)),"read");return n(r)??n(`${r}..${r}`)??ke(e,`\`${r}\` is not a band: lo..hi or one end, each a number or *`)}s(we,"bandOf");var Ne=s(e=>(t=>e.lo>e.hi?"empty":`${t(e.lo)}..${t(e.hi)}`)(t=>isFinite(t)?$r(t):"*"),"bandText");function At(e,t,r){return t.some(o=>o.includes(".."))&&ke(e,"a level holds no band mark `..`"),t.flatMap(o=>t.map(i=>({subject:"",floor:o,ceiling:i}))).find(({floor:o,ceiling:i})=>r===`${o}..${i}`)??(r.includes("..")?void 0:t.filter(o=>o===r).map(o=>({subject:"",floor:o,ceiling:o}))[0])??ke(e,`\`${r}\` is not one of its levels, nor two of them as lo..hi`)}s(At,"levelsOf");function ni(e){let t=e.provider?.lines??[],r=s(y=>{let b=t.filter(F=>F.scope==="wire/programs/"+y&&F.measure==="id");if(b.length!==1||!b[0].value)throw Error("REFUSE\xB7program missing or conflicting selector "+y);return b[0].value},"select");if(r("profile")!=="admitted-demands@1")throw Error("REFUSE\xB7program unsupported projection profile");let n=s(y=>{let b=e.lines.filter(F=>F.scope===y);if(b.length>1)throw Error("REFUSE\xB7program conflicting input "+y);return b[0]},"one"),o=s(y=>M(y).members,"list"),i=n(r("selection"));if(!i)throw Error("REFUSE\xB7program no declared selection");let a=o(i.value??"").map(y=>{let b=n(y);if(!b||b.role!=="demands")throw Error("REFUSE\xB7program selected coordinate is not a demand "+y);return{scope:y,needs:o(b.needs??"none"),restsOn:o(b.restsOn??"none")}}),c=n(r("minimum")),l=r("evidence"),f=e.regions[l]?.receipts;if(f===void 0)throw Error("REFUSE\xB7program evidence region was not handed "+l);let u=new Map;for(let y of f.filter(b=>b.measure==="status")){let b=y.scope??"",F=y.value??"";if(!["met","unmet","unread","refused"].includes(F))throw Error("REFUSE\xB7program unsupported evidence status "+b);if(u.has(b)&&u.get(b)!==F)throw Error("REFUSE\xB7program conflicting evidence "+b);u.set(b,F)}let d=r("elapsed"),p=f.filter(y=>y.scope===d);if(p.length>1)throw Error("REFUSE\xB7program conflicting elapsed reading "+d);let h=n(r("ceiling")),g=p[0];if(g&&h&&g.measure!==h.measure)throw Error("REFUSE\xB7program elapsed and ceiling units differ");let m=s((y,b)=>{if(!y)return;if(y.form!=="interval")throw Error("REFUSE\xB7program time input is not an interval "+y.scope);let F=we("interval",{lo:0,hi:1/0},y.value??"");if(!Number.isFinite(F.hi)||b&&F.lo!==F.hi)throw Error("REFUSE\xB7program time input is not an exact finite reading "+y.scope);return F.hi},"measure");return{programs:a,evidence:u,minimum:o(c?.value??"none"),elapsed:m(g,!0),ceiling:m(h,!1)}}s(ni,"programInputs");function Pa(e){let t=fn(ni(e));return[`PROGRAM deadline=${t.deadline} closed=${t.closed}`,...t.rows.map(r=>`DEMAND ${r.scope} ${r.status} blocked=${r.blocked.join("|")||"none"} missing=${r.missing.join("|")||"none"} unread=${r.unread.join("|")||"none"} carry=${r.carry}`),...t.next.sort(w).map(r=>"NEXT "+r)]}s(Pa,"renderPrograms");var oi=["contract","yes","vector","no"];function Ma(e,t,r,n){let o=s(c=>{throw Error("REFUSE\xB7publication "+c)},"fail");e.length||o("empty public surface is not conformance");let i=new Set,a=[...e].sort((c,l)=>w(c.scope,l.scope)).map(c=>{(!c.scope||i.has(c.scope))&&o("duplicate or empty coordinate "+c.scope),i.add(c.scope);let l=new Map;for(let p of c.members)(!oi.includes(p.role)||l.has(p.role)||!p.digest)&&o("ambiguous member at "+c.scope),l.set(p.role,p.digest);let f=oi.filter(p=>!l.has(p)||!t.has(l.get(p)));for(let[p,h]of l){let g=t.get(h);g&&n(g)!==h&&o("member digest differs at "+c.scope+"/"+p)}let u=r.get(c.scope);if(u){["met","unmet","unread","refused"].includes(u.status)||o("unsupported proof status "+c.scope);let p=new Map;for(let h of u.members)(!oi.includes(h.role)||p.has(h.role))&&o("ambiguous proof inputs "+c.scope),p.set(h.role,h.digest);(p.size!==l.size||[...l].some(([h,g])=>p.get(h)!==g))&&o("proof input identity differs at "+c.scope)}let d=f.length?"missing":!u||u.status==="unread"?"unread":u.status==="met"?"met":"unmet";return{scope:c.scope,status:d,missing:f}});return{rows:a,missing:a.filter(c=>c.status!=="met").length,closed:a.every(c=>c.status==="met")}}s(Ma,"publicationCoverage");var Zt="#topos-reference:1?",ii=["class","algorithm","digest","blob"],Ua=["location","location-class"],J=s(e=>{throw Error("REFUSE\xB7reference-location "+e)},"fail"),On=s((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"owns"),ad=/^[0-9a-f]{64}$/;function Ft(e){if(e===null||typeof e!="object"||Array.isArray(e))return J("record");let t=e,r=Object.keys(t);if(ii.some(i=>!On(t,i))||r.some(i=>![...ii,...Ua].includes(i)))return J("fields");if(t.class!=="standing")return J("class");if(t.algorithm!=="sha256")return J("algorithm");if(typeof t.digest!="string"||!ad.test(t.digest)||typeof t.blob!="string"||!/^sha256:[0-9a-f]{64}$/.test(t.blob))return J("digest");let n=On(t,"location"),o=On(t,"location-class");if(n!==o)return J("location pair");if(n){if(t["location-class"]!=="viewer"&&t["location-class"]!=="holder")return J("location class");if(typeof t.location!="string"||!t.location)return J("location URL");let i;try{i=new URL(t.location)}catch{return J("location URL")}if(!["https:","http:"].includes(i.protocol)||i.username||i.password||i.hash&&t["location-class"]==="holder")return J("location URL");if(i.href!==t.location)return J("noncanonical location")}return Object.freeze({...t})}s(Ft,"checkLocatedReference");function Ge(e){let t=Ft(e);return Zt+[...ii,...Ua].filter(r=>On(t,r)).map(r=>r+"="+encodeURIComponent(t[r])).join("&")}s(Ge,"encodeLocatedReference");function Ke(e){if(!e.startsWith(Zt))return J("profile");let t=new URLSearchParams(e.slice(Zt.length));if(new Set(t.keys()).size!==[...t].length)return J("duplicate field");let r=Ft(Object.fromEntries(t));return Ge(r)!==e?J("noncanonical encoding"):r}s(Ke,"decodeLocatedReference");function at(e){let t=Ft(e);return Ge({class:t.class,algorithm:t.algorithm,digest:t.digest,blob:t.blob})}s(at,"locatedReferenceIdentity");function _n(e,t,r){let n=Ft(e),o=at(n);if(!Number.isSafeInteger(r.maxBytes)||r.maxBytes<=0)return J("bytes budget");if(t===void 0)return{kind:"needs",needs:"bytes",identity:o};if(t.byteLength>r.maxBytes)return J("bytes budget");if(r.digestBytes(t)!==n.blob.slice(7))return J("blob integrity");let i,a;try{a=new TextDecoder("utf8",{fatal:!0}).decode(t),i=JSON.parse(a)}catch{return J("document")}if(i===null||typeof i!="object"||Array.isArray(i))return J("document");let c=i;if(Object.keys(c).length!==2||c.profile!=="semantic-standing@1"||typeof c.standing!="string")return J("document profile");if(a!==JSON.stringify({profile:c.profile,standing:c.standing}))return J("document encoding");let l;try{l=Et(c.standing)}catch{return J("standing bytes")}let f=be(l);return r.digestBytes(new TextEncoder().encode(f))!==n.digest?J("standing integrity"):{kind:"present",identity:o,standing:f,lines:l,authentication:"not demonstrated"}}s(_n,"inspectLocatedReference");var er="topos-inventory/1",B=s(e=>{throw Error("REFUSE\xB7module-inventory "+e)},"fail"),In=/^sha256:[0-9a-f]{64}$/,si=s((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"owns"),ct=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000\r\n]/.test(e),"text");function cd(e){return ct(e)&&!/[\\\s?#]/.test(e)&&!e.startsWith("/")&&e.split("/").every(t=>t!==""&&t!=="."&&t!=="..")&&/\.(?:[cm]?js|[cm]?ts|tsx)$/.test(e)&&!e.endsWith(".d.ts")}s(cd,"unit");function Ba(e){(!ct(e.source)||!ct(e.version)||!ct(e.holder))&&B("source/version/holder"),(e["unit-kind"]!=="module"||!cd(e.unit))&&B("module unit")}s(Ba,"identity");function tr(e){Ba(e);let t=["source","version","holder","unit-kind","unit","reached-from","status","digest","needs"];if(Object.keys(e).some(n=>!t.includes(n)))return B("fields");if(!ct(e["reached-from"]))return B("reached-from");let r=e["reached-from"].indexOf("#");if(r<0||!In.test(e["reached-from"].slice(0,r)))return B("reached-from");try{let n=JSON.parse(decodeURIComponent(e["reached-from"].slice(r+1)));if(!Array.isArray(n)||n.length<1||n[0]!=="exports"||!n.every(ct)||encodeURIComponent(JSON.stringify(n))!==e["reached-from"].slice(r+1))return B("reached-from")}catch{return B("reached-from")}if(e.status==="point"){if(!e.digest||!In.test(e.digest)||si(e,"needs"))return B("point digest")}else if(e.status==="open"){if(e.needs!=="digest"||si(e,"digest"))return B("open digest")}else return B("status");return er+v(e).slice(12)}s(tr,"encodeInventoryRow");function ai(e){if(!e.startsWith(er+" "))return B("profile");let t=x("bound-lock/1"+e.slice(er.length));if(t.kind!=="fact")return B("record");let r=t.value.fields;return tr(r)!==e?B("canonical bytes"):Object.freeze({...r})}s(ai,"decodeInventoryRow");function Ta(e,t){let r=[];for(let n of e){if(Ba({source:n.source,version:n.version,holder:n.holder,"unit-kind":n.unitKind,unit:n.unit,"reached-from":"",status:"open",needs:"digest"}),typeof n.reached!="boolean")return B("reach declaration");if(!n.reached)continue;let o=n.reachedFrom;if(!o||!In.test(o.digest)||!Array.isArray(o.selector)||o.selector.length<1||o.selector[0]!=="exports"||!o.selector.every(ct))return B("reach evidence");let i=t.documents.get(o.digest);if(!i||t.digestBytes(i)!==o.digest)return B("evidence digest");let a;try{a=JSON.parse(new TextDecoder("utf8",{fatal:!0}).decode(i))}catch{return B("evidence document")}if(a===null||typeof a!="object"||Array.isArray(a))return B("package identity");let c=a;if(c.name!==n.source||c.version!==n.version)return B("package identity");let l=a;for(let u of o.selector){if(l===null||typeof l!="object"||Array.isArray(l)||!si(l,u))return B("unproved reachability");l=l[u]}if(l!=="./"+n.unit)return B("unproved reachability");let f={source:n.source,version:n.version,holder:n.holder,"unit-kind":"module",unit:n.unit,"reached-from":o.digest+"#"+encodeURIComponent(JSON.stringify(o.selector))};if(n.moduleBytes===void 0)r.push(tr({...f,status:"open",needs:"digest"}));else{if(!(n.moduleBytes instanceof Uint8Array))return B("module bytes");let u=t.digestBytes(n.moduleBytes);if(!In.test(u))return B("digest algorithm");r.push(tr({...f,status:"point",digest:u}))}}return[...new Set(r)].sort(w)}s(Ta,"moduleInventory");function An(e){for(let r of e)ai(r);let t=[...new Set(e)].sort(w);return t.length?t.join(`
24
23
  `)+`
25
- `}s(Yo,"requestBytes");function Zo(e){return e.map(t=>x({by:t.keyId,sig:t.signature})).join(`
24
+ `:""}s(An,"inventoryBytes");function La(e,t,r){if(!Number.isSafeInteger(r)||r<0)return B("diff budget");let n=new Set(An(e).split(`
25
+ `).filter(Boolean)),o=new Set(An(t).split(`
26
+ `).filter(Boolean)),i=[...[...n].filter(a=>!o.has(a)).map(a=>({operation:"remove",line:a})),...[...o].filter(a=>!n.has(a)).map(a=>({operation:"add",line:a}))].sort((a,c)=>w(a.line,c.line)||w(a.operation,c.operation));return{changes:i.slice(0,r),omitted:Math.max(0,i.length-r),unchanged:[...n].filter(a=>o.has(a)).length}}s(La,"inventoryDiff");var Fn=s(e=>({lo:se("budget",e,"lo"),hi:se("budget",e,"hi")}),"span"),Ct={id:"budget",lattice:s(e=>j.lattice(Fn(e)),"lattice"),parse:s((e,t)=>we("budget",Fn(e),t),"parse"),emit:s((e,t)=>Ne(t),"emit"),show:s((e,t)=>j.lattice(Fn(e)).show(t),"show"),points:s((e,t,r)=>j.points(Fn(e),t,r),"points")};var nr="topos-source-card/1",K=s(e=>{throw Error("REFUSE\xB7source-card "+e)},"fail"),qa=s((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"own"),rr=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000-\u0020\u007f]/.test(e),"word");function ci(e){return e===null||typeof e=="boolean"||typeof e=="string"||typeof e=="number"&&Number.isFinite(e)?JSON.stringify(e):Array.isArray(e)?"["+e.map(ci).join(",")+"]":e&&typeof e=="object"?"{"+Object.keys(e).sort(w).map(t=>JSON.stringify(t)+":"+ci(e[t])).join(",")+"}":K("parameters")}s(ci,"json");function ld(e){let t={};for(let[n,o]of Object.entries(e)){if(!/^[a-z][a-z0-9-]*$/.test(n)||typeof o!="string"||/[\u0000\r\n]/.test(o))return K("fields");t[n]=o}for(let n of["source","publisher","authority"])if(!rr(e[n]))return K(n);if(["by","sig","epoch","type"].some(n=>qa(e,n)))return K("protocol envelope");if(!/^sha256:[0-9a-f]{64}$/.test(e.catalog)||!rr(e.form))return K("catalog/form");let r;try{r=JSON.parse(e.params)}catch{return K("parameters")}if(!r||typeof r!="object"||Array.isArray(r))return K("parameters");if(t.params=ci(r),!rr(e["cost-unit"])||!/^\d+(?:\.\d+)?$/.test(e["cost-limit"])||!Number.isFinite(Number(e["cost-limit"]))||Number(e["cost-limit"])<=0||String(Number(e["cost-limit"]))!==e["cost-limit"])return K("cost declaration");for(let n of["needs","shares"]){if(n==="shares"&&!qa(e,n))continue;let o=e[n];if(!rr(o)||o.split("|").some(i=>!rr(i)))return K(n);t[n]=[...new Set(o.split("|"))].sort(w).join("|")}return typeof e.resolution!="string"||!e.resolution||typeof e.cost!="string"||!e.cost?K("resolution/cost"):t}s(ld,"normalized");function lt(e){return nr+v(ld(e)).slice(12)}s(lt,"encodeSourceCard");function dt(e){if(!e.startsWith(nr+" "))return K("profile");let t=x("bound-lock/1"+e.slice(nr.length));if(t.kind!=="fact")return K("record");let r=t.value.fields;return lt(r)!==e?K("canonical bytes"):Object.freeze({...r})}s(dt,"decodeSourceCard");function Nt(e,t){let r=dt(lt(e));if(r.catalog!==t.digest)return K("catalog identity");let n=t.forms.get(r.form);if(!n||n.id!==r.form)return K("uncatalogued form");let o=JSON.parse(r.params),i=n.lattice(o),a=n.parse(o,r.resolution);if(n.emit(o,a)!==r.resolution)return K("resolution canonical");if(i.leq(a,i.bottom))return K("empty resolution");if(!i.leq(a,i.top))return K("resolution domain");let c={lo:0,hi:Number(r["cost-limit"])},l;try{l=Ct.parse(c,r.cost)}catch{return K("cost syntax")}return l.lo<0||l.hi>c.hi||l.lo>l.hi||!Number.isFinite(l.lo)||!Number.isFinite(l.hi)?K("cost domain"):Ct.emit(c,l)!==r.cost?K("cost canonical"):{card:r,resolution:a,cost:l,sharedCause:r.shares===void 0?{kind:"unknown",independence:"not established"}:{kind:"declared",shares:r.shares,independence:"not established"},authority:"declared; not authenticated",needs:r.needs==="none"?[]:r.needs.split("|")}}s(Nt,"inspectSourceCard");function Da(e,t,r){let n=Nt(e,r),o=Nt(t,r),i=s(l=>Object.fromEntries(Object.entries(l).filter(([f])=>f!=="resolution"&&f!=="cost")),"omit");if(v(i(n.card))!==v(i(o.card)))return!1;let a=r.forms.get(e.form),c=JSON.parse(e.params);return a.lattice(c).leq(n.resolution,o.resolution)&&Ct.lattice({lo:0,hi:Number(e["cost-limit"])}).leq(n.cost,o.cost)}s(Da,"sourceCardRefines");var or="topos-measure-m0/1",_=s(e=>{throw Error("REFUSE\xB7measure-m0 "+e)},"fail"),ae=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"obj"),je=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000\r\n]/.test(e),"text"),te=s(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1,"prob"),Cn=s(e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=1,"int");function X(e,t,r){Object.keys(e).some(n=>!t.includes(n))&&_(r)}s(X,"keys");function $e(e){return e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)?JSON.stringify(e):Array.isArray(e)?"["+e.map($e).join(",")+"]":ae(e)?"{"+Object.keys(e).sort(w).map(t=>JSON.stringify(t)+":"+$e(e[t])).join(",")+"}":_("JSON value")}s($e,"json");function dd(e){if(!ae(e)||e.kind!=="joint-independence"||e.scope!=="latent-lineages-and-fresh-draws"||!je(e.provenance))return _("joint independence declaration");X(e,["kind","scope","provenance"],"independence fields")}s(dd,"independence");function ud(e,t){if(!ae(e))return _("weights");if(e.family==="uniform")return X(e,["family","K"],"weights fields"),e.K==="unknown"?void 0:Cn(e.K)?e.K:_("K");if(e.family==="declared"){if(X(e,["family","values"],"weights fields"),!Array.isArray(e.values)||!e.values.length||e.values.some(n=>!te(n)))return _("weights");let r=e.values;return Math.abs(r.reduce((n,o)=>n+o,0)-1)>t?_("normalized weights"):r.filter(n=>n>0).length}return _("weights family")}s(ud,"weights");function za(e,t){if(!ae(e)||(X(e,["box","failureUpper","provenance","coveragePremise","source"],"calibration fields"),!Array.isArray(e.box)||e.box.length!==2||!e.box.every(te)||e.box[0]<=0||e.box[0]>e.box[1]||t==="p"&&e.box[1]>=1||!te(e.failureUpper)||!je(e.provenance)||!je(e.coveragePremise)||e.source!=="external"))return _("calibration "+t)}s(za,"calibration");function ir(e){if(!ae(e))return _("record");if(X(e,["status","reason","kind","model","observation","units","numerical","result"],"fields"),e.status==="unmeasured")return!je(e.reason)||Object.keys(e).some(c=>c!=="status"&&c!=="reason")?_("unmeasured reason only"):{status:"unmeasured",reason:e.reason,certification:"not established"};if(e.status!=="declared"||!ae(e.model)||!ae(e.observation)||!ae(e.numerical)||!ae(e.result)||e.reason!==void 0)return _("complete numerical declaration");let t=e.model,r=e.observation,n=e.numerical,o=e.result;if(X(t,["id","p","c","weights","jointIndependence","parameterProvenance"],"model fields"),X(n,["arithmetic","tolerance"],"numerical policy"),n.arithmetic!=="binary64-declared"||typeof n.tolerance!="number"||!Number.isFinite(n.tolerance)||n.tolerance<=0||n.tolerance>1e-9)return _("numerical policy");if(!["binary-M0-population-agreement@1","binary-M0-uniform-population@1","binary-M0-whole-cell-iid@1"].includes(String(t.id)))return _("published M0 model");if(dd(t.jointIndependence),!je(t.parameterProvenance))return _("parameter provenance");let i=ud(t.weights,n.tolerance),a;if(e.kind==="population-moments"){if(t.id!=="binary-M0-population-agreement@1"||!te(t.p)||!te(t.c)||i===void 0||e.units!=="probability")return _("population domain");if(X(r,["design","moments","provenance"],"observation fields"),r.design!=="conditional-population-iid-with-replacement"||$e(r.moments)!=='["R2","R4"]'||!je(r.provenance))return _("population moments");if(X(o,["R2","R4"],"result fields"),!te(o.R2)||!te(o.R4))return _("moment range");a="Declared population pair/fourth agreement only; not a complete observable law, error rate or inverse"}else if(e.kind==="identification"){if(!te(t.p)||t.p<=0||t.p>=1||t.c!=="unknown-in-(0,1]"||e.units!=="dimensionless")return _("identification domain");if(X(r,["design","moments","provenance"],"observation fields"),r.design!=="population-expectation"||!ae(r.moments)||!te(r.moments.R2)||!te(r.moments.R4)||!je(r.provenance))return _("population inverse");if(X(r.moments,["R2","R4"],"selected moments"),t.id==="binary-M0-uniform-population@1"&&ae(t.weights)&&t.weights.family==="uniform"&&t.weights.K==="unknown"){if(X(o,["kind","c","K"],"result fields"),o.kind!=="unique-within-uniform-family"||!te(o.c)||o.c<=0||!Cn(o.K))return _("uniform inverse result");a="Uniqueness theorem applies only to exact population moments, known p and declared uniform family; supplied inverse is not recomputed"}else if(t.id==="binary-M0-population-agreement@1"){if(o.kind!=="compatible-set"||$e(o.constraints)!=='["R2","R4"]')return _("nonuniform compatible set");X(o,["kind","constraints"],"result fields"),a="Set defined by declared R2/R4 equations; not a singleton or an enumerated/exhaustive solver output"}else return _("identification family")}else if(e.kind==="keff-outer-enclosure"){if(t.id!=="binary-M0-whole-cell-iid@1"||t.p!=="external-box"||t.c!=="external-box"||i===void 0||e.units!=="dimensionless")return _("finite domain");if(X(r,["design","cellUnit","T","N","Dhat","independence","provenance","epsilon","calibration","uncertaintyUnit"],"observation fields"),r.design!=="conditional-population-iid-with-replacement"||r.cellUnit!=="whole-complete-cell"||r.uncertaintyUnit!=="whole-cells"||r.independence!=="joint-iid-complete-cells"||!Cn(r.T)||!Cn(r.N)||r.N<2||!te(r.Dhat)||!je(r.provenance)||!te(r.epsilon)||r.epsilon<=0)return _("whole-cell sampling");if(!ae(r.calibration))return _("external calibration required");if(X(r.calibration,["p","c"],"calibration fields"),za(r.calibration.p,"p"),za(r.calibration.c,"c"),X(o,["kind","lower","upper","denominator","cap","errorBudgets"],"result fields"),o.kind!=="conditional-outer-enclosure"||typeof o.lower!="number"||!Number.isFinite(o.lower)||o.lower<1||!(o.upper===null||typeof o.upper=="number"&&Number.isFinite(o.upper)&&o.upper>=o.lower))return _("enclosure");if(o.denominator!=="strictly-positive-premise"&&o.denominator!=="may-approach-zero")return _("denominator premise");if(o.cap!==null){if(!ae(o.cap)||o.cap.kind!=="known-deterministic"||typeof o.cap.value!="number"||!Number.isFinite(o.cap.value)||o.cap.value<1||!je(o.cap.provenance))return _("external cap");if(X(o.cap,["kind","value","provenance"],"cap fields"),o.upper!==null&&o.upper>o.cap.value)return _("cap bound")}if(o.denominator==="may-approach-zero"&&o.upper!==null&&o.cap===null)return _("no finite upper bound");if(!ae(o.errorBudgets)||!te(o.errorBudgets.data)||!te(o.errorBudgets.p)||!te(o.errorBudgets.c)||o.errorBudgets.method!=="union-bound")return _("joint error budgets");if(X(o.errorBudgets,["data","p","c","method"],"budget fields"),o.errorBudgets.p!==r.calibration.p.failureUpper||o.errorBudgets.c!==r.calibration.c.failureUpper)return _("calibration budgets");a="Conditional declared outer enclosure; pairs share members; coverage/calibration and numerical enclosure require external verification; no finite upper bound if denominator approaches zero without cap"}else if(e.kind==="weight-participation"){if(t.id!=="binary-M0-population-agreement@1"||!te(t.p)||!te(t.c)||i===void 0||e.units!=="dimensionless")return _("participation domain");if(X(r,["design","provenance"],"observation fields"),r.design!=="declared-normalized-weights"||!je(r.provenance))return _("participation observation");if(X(o,["kind","lower","upper"],"result fields"),o.kind!=="declared-weight-participation"||typeof o.lower!="number"||typeof o.upper!="number"||!Number.isFinite(o.lower)||!Number.isFinite(o.upper)||o.lower<1||o.lower>o.upper||o.upper>i)return _("participation bound");a="Published concentration definition 1/sum(w_i^2); supported range only, not recomputed and not a count of causally independent sources"}else return _("measure kind");return{status:"declared",condition:a,certification:"not established",resultStatus:"declared-not-recomputed",needsVerification:["model premises","numerical result","observation/calibration provenance"],record:e}}s(ir,"inspectM0Measure");function li(e){return ir(e),or+v({record:$e(e)}).slice(12)}s(li,"encodeM0Measure");function Wa(e){if(!e.startsWith(or+" "))return _("profile");let t=x("bound-lock/1"+e.slice(or.length));if(t.kind!=="fact"||Object.keys(t.value.fields).join("|")!=="record")return _("record");let r;try{r=JSON.parse(t.value.fields.record)}catch{return _("JSON record")}return li(r)!==e?_("canonical bytes"):r}s(Wa,"decodeM0Measure");function Ja(e,t){if(ir(e),ir(t),e.status==="unmeasured"||t.status==="unmeasured")return $e(e)===$e(t);let r=s(i=>$e({...i,result:null}),"context");if(r(e)!==r(t))return!1;let n=e.result,o=t.result;return e.kind==="weight-participation"?j.lattice({lo:1,hi:1/0}).leq({lo:n.lower,hi:n.upper},{lo:o.lower,hi:o.upper}):$e(n)===$e(o)}s(Ja,"m0MeasureRefines");function sr(e,t,r,n=[]){if(!t.length||new Set(t).size!==t.length||!t.includes("scope"))throw Error("REFUSE\xB7receipt missing or conflicting canonical field contract");let o=new Map;for(let a of e){let c=x(a);if(c.kind!=="fact")throw Error("REFUSE\xB7receipt the observed set holds an invalid record");let l=c.value.fields;if(n.includes(l.by??""))throw Error("REFUSE\xB7receipt excluded evidence is inside its own set");let f=v(Object.fromEntries(t.filter(d=>l[d]!==void 0).map(d=>[d,l[d]]))),u=(l.scope??"").split("/")[0]??"";(o.get(u)??o.set(u,new Set).get(u)).add(f)}let i=[...o].map(([a,c])=>({scope:`receipts/${a}`,count:c.size,digest:r([...c].sort(w).map(l=>l+`
27
+ `).join(""))})).sort((a,c)=>w(a.scope,c.scope));return{root:r(i.map(a=>a.digest+`
28
+ `).join("")),regions:i}}s(sr,"receiptProjection");var R=s(e=>{throw Error("REFUSE\xB7walk "+e)},"refuse"),me=s(e=>{let t=x(e);return t.kind!=="fact"?R("invalid canonical record"):t.value},"record");function fd(e){let t=e.filter(r=>r.scope==="walk/origin"&&r.role==="writes"&&r.form==="alphabet"&&r.measure==="id"&&r.value!=="withdraw");return t.length!==1||!t[0].value?R("missing or conflicting declared ledger origin"):t[0].value}s(fd,"walkOrigin");function pd(e,t){let r=_t(e,Number.MAX_SAFE_INTEGER);if(!r||!r.signatures.size)return R("origin context has no signature contract");let n=[...r.signatures],i=[...new Set(e.filter(c=>c.scope?.startsWith("keys/")&&c.measure==="public-key").map(c=>c.scope.slice(5)))].map(c=>{let l=s(h=>{let g=e.filter(m=>m.scope==="keys/"+c&&m.measure===h&&m.value!=="withdraw");return g.length!==1?R("origin key "+c+" has missing or conflicting "+h):g[0].value},"said"),f=l("class"),u=l("coverage").split("|"),d=l("public-key");(!f||!d||u.some(h=>!h))&&R("incomplete origin key "+c);let p=Se(v({scope:"keys/"+c,role:"writes",form:"interval",measure:"resolution",value:l("resolution"),by:"target",at:"policy:walk"}),null);return p.kind!=="fact"||p.value.bound.kind!=="interval"||p.value.bound.lo===null||p.value.bound.hi===null?R("origin key "+c+" has no bounded resolution"):{id:c,keyClass:f==="authorize"?"authorize":"attest",publicKey:d,coverage:u,depth:{lo:p.value.bound.lo,hi:p.value.bound.hi},admittedBy:[]}});i.length||R("origin context has no keys");let a=s(c=>{let l=me(c);return Rn(l.fields,i,(f,u)=>t(f,u,n))},"of");return{of:a,authenticate:s(c=>c.every(l=>a(l).kind==="admitted"),"authenticate"),wire:r}}s(pd,"walkAuthority");function di(e,t,r,n,o){let i=[...new Set(e.map(l=>{let f=me(l);v(f.fields,f.version)!==l&&R("noncanonical record"),f.fields.sig||R("unsigned evidence");for(let u of Object.keys(f.fields))u!=="sig"&&!t.includes(u)&&R("identity omits "+u);return l}))].sort(w);if(o){if(!n)return R("coordinate partition requires a declared origin");let l=new Map;for(let u of i){let d=me(u).fields;if(!d.scope)return R("coordinate record has no scope");let p="receipts/"+encodeURIComponent(n)+"/"+d.scope.split("/").map(encodeURIComponent).join("/"),h=l.get(p)??{claims:new Set,records:[]};h.claims.add(v(Object.fromEntries(t.filter(g=>d[g]!==void 0).map(g=>[g,d[g]])))),h.records.push(u),l.set(p,h)}let f=[...l].map(([u,d])=>({scope:u,count:d.claims.size,digest:r([...d.claims].sort(w).map(p=>p+`
29
+ `).join("")),records:d.records})).sort((u,d)=>w(u.scope,d.scope));return{...Nn([f],r,o),regions:f}}let a=sr(i,t,r),c=a.regions.map(l=>({...l,records:i.filter(f=>me(f).fields.scope.split("/")[0]===l.scope.slice(9)),scope:n?"receipts/"+encodeURIComponent(n)+"/"+l.scope.slice(9):l.scope}));return{root:n?Nn([c],r).root:a.root,regions:c}}s(di,"walkSnapshot");function Nn(e,t,r){let n=new Map;for(let l of e)for(let f of l){if(!Number.isSafeInteger(f.count)||f.count<0)return R("invalid inventory count "+f.scope);let u=n.get(f.scope);u&&(u.digest!==f.digest||u.count!==f.count)&&R("ambiguous inventory region "+f.scope),u||n.set(f.scope,f)}let o=[...n.values()].sort((l,f)=>w(l.scope,f.scope)),i=o.flatMap(l=>[v({scope:l.scope,role:"writes",form:"alphabet",measure:"digest",value:l.digest,by:"target",at:"receipt:walk"}),v({scope:l.scope,role:"writes",form:"interval",measure:"count",value:`${l.count}..${l.count}`,by:"target",at:"receipt:walk"})]),a=sr(i,["scope","role","form","measure","value"],t).root;if(!r)return{root:a,regions:o.map(l=>({...l,records:[]}))};if(r.kind!=="scope-coordinates@1"||new Set(r.depths).size!==r.depths.length||r.depths.some(l=>!Number.isSafeInteger(l)||l<1))return R("invalid declared coordinate partition");let c=r.depths.map(l=>{let f=new Map;for(let u of o){let d=u.scope.split("/");if(d.length<3||d[0]!=="receipts")return R("coordinate region has no origin namespace");let p=d.slice(0,2+l).join("/"),h=f.get(p)??[];h.push(u),f.set(p,h)}return{depth:l,regions:[...f].map(([u,d])=>{if(d.length===1&&d[0].scope===u)return d[0];let p=d.reduce((h,g)=>h+g.count,0);return Number.isSafeInteger(p)?{scope:u,count:p,digest:Nn([d],t).root}:R("coordinate group count is outside the exact range")}).sort((u,d)=>w(u.scope,d.scope))}});return{root:a,regions:o.map(l=>({...l,records:[]})),refinements:c}}s(Nn,"walkInventory");function Pn(e,t){if(t!==void 0&&(!Number.isSafeInteger(t)||t<0))return R("invalid resolution");let r=e.filter(n=>t===void 0?n.projection==="inventory":n.resolution===t);return r.length!==1?R("undeclared or ambiguous resolution"):["inventory","summary","history"].includes(r[0].projection)?r[0].projection:R("unsupported declared projection")}s(Pn,"walkProjection");function md(e,t,r,n,o){let i=Pn(n,r),a=new Map;for(let h of t.regions)a.has(h.scope)&&R("ambiguous peer region "+h.scope),a.set(h.scope,h.digest);let c=n.filter(h=>r===void 0?h.projection==="inventory":h.resolution===r)[0],l=e.regions;if(c.depth!==void 0&&!e.refinements)return R("declared refinement requires a matching snapshot partition");if(e.refinements){if(c.depth===void 0)return R("refined snapshot has no declared resolution partition");if(i==="history"&&c.depth!=="all")return R("history requires complete coordinate regions");if(c.depth!=="all"){let h=e.refinements.find(g=>g.depth===c.depth);if(!h)return R("undeclared coordinate refinement");l=h.regions}}let f=s(h=>{if(a.get(h.scope)===h.digest||e.refinements?.some(y=>y.regions.some(b=>(h.scope===b.scope||h.scope.startsWith(b.scope+"/"))&&a.get(b.scope)===b.digest)))return!0;if(!e.refinements||e.regions.some(y=>y.scope===h.scope))return!1;let g=e.regions.filter(y=>y.scope.startsWith(h.scope+"/")),m=[...a.keys()].filter(y=>y.startsWith(h.scope+"/"));return g.length>0&&m.length===g.length&&g.every(y=>a.get(y.scope)===y.digest)},"covered"),u=l.filter(h=>!f(h)),d=o??u.map(h=>h.scope);new Set(d).size!==d.length&&R("duplicate requested region");for(let h of d)u.some(g=>g.scope===h)||R("region is not an open requested difference "+h);let p=u.filter(h=>d.includes(h.scope));return{root:e.root,regions:(i==="inventory"?l:p).map(h=>({scope:h.scope,digest:h.digest,count:h.count})),records:i==="history"?[...new Set(p.flatMap(h=>e.regions.find(g=>g.scope===h.scope)?.records??[]))].sort(w):[],touched:i==="history"?p.length:0,open:u.length}}s(md,"walkAt");function ui(e,t,r,n,o,i,a){let c=di(e,r,n,i,a);new Set(t.map(l=>l.scope)).size!==t.length&&R("ambiguous expected region"),c.regions.length!==t.length&&R("partial or extra payload");for(let l of t){let f=c.regions.find(u=>u.scope===l.scope);(!f||f.digest!==l.digest||f.count!==l.count)&&R("region digest or count mismatch "+l.scope)}return o(e)!==!0&&R("receiver does not admit evidence"),[...new Set(e)].sort(w)}s(ui,"walkPayload");var jn="walk/root",$n="walk/regions/";function Ve(e){let t=me(e).fields;return!t.type&&(t.scope===jn||!!t.scope?.startsWith($n))}s(Ve,"isWalkHeader");function gd(e,t,r,n){let o=s((i,a,c,l,f)=>v({scope:i,form:a,measure:c,value:l,condition:f,role:"writes",at:"receipt:"+t,by:"target"}),"row");return[o(jn,"alphabet","digest",e.root,r),...e.regions.flatMap(i=>[o($n+i.scope,"alphabet","digest",i.digest,e.root),...n?[o($n+i.scope,"interval","count",`${i.count}..${i.count}`,e.root)]:[]])].sort(w)}s(gd,"walkHeaders");function fi(e,t,r,n){(!e.length||n(e)!==!0)&&R("metadata is not authenticated");let o=["scope","role","form","measure","value","condition","by","at","epoch","sig"],i=e.map(f=>{let u=me(f),d=u.fields;return(u.version!==re.split("/").at(-1)||!Ve(f))&&R("unknown metadata record"),(Object.keys(d).some(p=>!o.includes(p))||o.some(p=>d[p]===void 0))&&R("missing or extra metadata field"),(v(d)!==f||d.role!=="writes"||d.at!=="receipt:"+t)&&R("metadata context or canonical bytes differ"),d}),a=i.filter(f=>f.scope===jn);a.length!==1&&R("missing or ambiguous root");let c=a[0];(c.form!=="alphabet"||c.measure!=="digest"||c.condition!==r)&&R("stale base or wrong root grammar"),i.some(f=>f.by!==c.by||f.epoch!==c.epoch)&&R("metadata mixes signers or epochs");let l=new Map;for(let f of i.filter(u=>u.scope!==jn)){let u=f.scope.slice($n.length);(!u||f.condition!==c.value)&&R("region does not rest on the authenticated root");let d=l.get(u)??{scope:u};if(f.form==="alphabet"&&f.measure==="digest")d.digest!==void 0&&R("ambiguous region digest"),d.digest=f.value;else if(f.form==="interval"&&f.measure==="count"){let p=Se(v(f),null);if(p.kind!=="fact"||p.value.bound.kind!=="interval")return R("count has no declared interval encoding");let{lo:h,hi:g}=p.value.bound;if(h===null||d.count!==void 0||h!==g||!Number.isSafeInteger(h)||h<0)return R("count is ambiguous or not discrete");d.count=h}else R("unknown region grammar");l.set(u,d)}return[...l.values()].some(f=>f.digest===void 0)&&R("region digest absent"),{root:c.value,context:t,base:r,signer:c.by,regions:[...l.values()].map(f=>({...f,digest:f.digest})).sort((f,u)=>w(f.scope,u.scope))}}s(fi,"readWalkHeaders");function hd(e,t){let r=e.filter(Ve),n=e.filter(c=>!Ve(c)),o=fi(r,t.context,t.base,t.authenticateMetadata);o.regions.some(c=>c.count===void 0)&&R("payload was offered without its summary");let i=o.regions.map(c=>({...c,count:c.count})),a=ui(n,i,t.fields,t.digest,c=>t.admitBatch([...r,...c])===!0);return{metadata:o,records:a,headers:r}}s(hd,"readWalkPayload");function yd(e,t){t.origin||R("foreign origin identity absent"),t.regionOrigin!==void 0&&t.regionOrigin!==t.origin&&R("region origin differs from authenticated origin");let r=e.filter(Ve),n=e.filter(p=>!Ve(p)),o=fi(r,t.context,t.base,t.authenticatePrefix),i=me(r[0]).fields.epoch;/^(0|[1-9][0-9]*)$/.test(i)||R("invalid sender prefix epoch");let a=Number(i);Number.isSafeInteger(a)||R("invalid sender prefix epoch");for(let p of n){let h=me(p).fields.epoch;(h===void 0||!/^(0|[1-9][0-9]*)$/.test(h)||!Number.isSafeInteger(Number(h))||Number(h)>a)&&R("foreign epoch is outside the authenticated prefix")}o.regions.some(p=>p.count===void 0)&&R("prefix was offered without its summary");let c=o.regions.map(p=>({...p,count:p.count})),l=ui(n,c,t.fields,t.digest,p=>t.authenticateEvidence(p)===!0&&t.validateOriginHistory(p)===!0,t.regionOrigin,t.partition),f=di(l,t.fields,t.digest,t.regionOrigin,t.partition);for(let p of f.regions){let h=t.previousPrefixes.filter(b=>b.scope===p.scope);h.length>1&&R("ambiguous previous origin prefix");let g=h[0];if(!g)continue;a<g.senderEpoch&&R("sender cut precedes the verified origin prefix");let m=new Set(g.records.map(b=>v(Object.fromEntries(Object.entries(me(b).fields).filter(([F])=>F!=="sig"))))),y=new Set(p.records.map(b=>v(Object.fromEntries(Object.entries(me(b).fields).filter(([F])=>F!=="sig")))));[...m].some(b=>!y.has(b))&&R("foreign history is not an extension of its verified prefix");for(let b of p.records){let F=me(b),P=v(Object.fromEntries(Object.entries(F.fields).filter(([G])=>G!=="sig")));Number(F.fields.epoch)<=g.senderEpoch&&!m.has(P)&&R("foreign epoch does not match the verified prefix")}}let u=[v({scope:"receipts/import",role:"writes",form:"alphabet",measure:"digest",value:o.root,condition:t.origin,at:"receipt:"+t.context,by:"target"}),...c.flatMap(p=>[v({scope:p.scope,role:"writes",form:"alphabet",measure:"digest",value:p.digest,at:"receipt:"+t.context,by:"target"}),v({scope:p.scope,role:"writes",form:"interval",measure:"count",value:`${p.count}..${p.count}`,at:"receipt:"+t.context,by:"target"})])],d=sr(u,["scope","role","form","measure","value","condition","at"],t.digest).root;return{origin:t.origin,senderEpoch:a,records:l,headers:r,identity:d,importReceiptProposal:v({scope:"receipts",role:"writes",form:"alphabet",measure:"digest",value:d,at:"receipt:"+t.context,by:"target"})}}s(yd,"readForeignWalk");function bd(e){let t=s(g=>{let m=e.map(me).map(y=>y.fields).filter(y=>y.scope===g&&y.value!=="withdraw");return m.length!==1||m[0].form!=="alphabet"||m[0].measure!=="id"||m[0].role!=="writes"?R("missing or conflicting declaration "+g):m[0].value},"at");t("wire/walk/contract")!=="whole-region@1"&&R("unsupported declared exchange contract");let r=t("wire/walk/fields").split("|"),n=t("wire/walk/metadata-fields").split("|"),o=t("wire/walk/resolutions").split("|");o.some(g=>!/^(0|[1-9][0-9]*)$/.test(g)||!Number.isSafeInteger(Number(g)))&&R("invalid declared resolutions");let i=o.map(Number);(new Set(r).size!==r.length||["scope","by","epoch"].some(g=>!r.includes(g))||r.some(g=>!g||g==="sig"))&&R("incomplete history identity field contract");let a=["scope","role","form","measure","value","condition","by","at","epoch","sig"];(n.length!==a.length||new Set(n).size!==n.length||a.some(g=>!n.includes(g)))&&R("unsupported metadata field contract"),(!i.length||new Set(i).size!==i.length)&&R("missing or conflicting declared resolutions");let c=t("wire/walk/projections").split("|").map(g=>{let m=g.split(":");if(m.length!==2||!/^(0|[1-9][0-9]*)$/.test(m[0]))return R("invalid declared projection");let y=Number(m[0]),b=m[1];return!Number.isSafeInteger(y)||!["inventory","summary","history"].includes(b)?R("unsupported declared projection"):{resolution:y,projection:b}});(c.length!==i.length||new Set(c.map(g=>g.resolution)).size!==c.length||c.some(g=>!i.includes(g.resolution)))&&R("projection does not match declared resolutions");let l=s(g=>e.map(me).map(y=>y.fields).filter(y=>y.scope===g&&y.value!=="withdraw").length?t(g):void 0,"optional"),f=l("wire/walk/partition"),u=l("wire/walk/refinements");if(f===void 0&&u===void 0)return{contract:"whole-region@1",fields:r,metadataFields:n,resolutions:i,projections:c};if(f!=="scope-coordinates@1"||u===void 0)return R("missing or unsupported coordinate partition contract");let d=u.split("|").map(g=>{let m=g.split(":");if(m.length!==2||!/^(0|[1-9][0-9]*)$/.test(m[0])||m[1]!=="all"&&!/^[1-9][0-9]*$/.test(m[1]))return R("invalid declared coordinate refinement");let y=Number(m[0]),b=m[1]==="all"?"all":Number(m[1]);return!Number.isSafeInteger(y)||b!=="all"&&!Number.isSafeInteger(b)?R("invalid declared coordinate refinement"):{resolution:y,depth:b}});if(d.length!==c.length||new Set(d.map(g=>g.resolution)).size!==d.length||d.some(g=>!i.includes(g.resolution)))return R("refinement does not match declared resolutions");let p=c.map(g=>({...g,depth:d.find(m=>m.resolution===g.resolution).depth}));if(p.some(g=>g.projection==="history"&&g.depth!=="all"))return R("history requires complete coordinate regions");let h={kind:f,depths:[...new Set(d.flatMap(g=>g.depth==="all"?[]:[g.depth]))]};return{contract:"whole-region@1",fields:r,metadataFields:n,resolutions:i,projections:p,partition:h}}s(bd,"walkSelection");var Un="topos-region-reading/1",T=s(e=>{throw Error("REFUSE\xB7region-reading "+e)},"fail"),ar=s(e=>typeof e=="string"&&/^sha256:[0-9a-f]{64}$/.test(e),"hash"),Mn=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000\r\n]/.test(e),"text");function Ha(e,t){if(!Array.isArray(e)||!e.length||e.some(r=>!Mn(r)||/[\s?#\\]/.test(r)||r.split("/").some(n=>n===""||n==="."||n===".."))||new Set(e).size!==e.length)return T(t)}s(Ha,"selectors");function Ga(e,t,r){if(t.frame!=="canonical-walk-headers@1")return T("frame");if(!ar(t.inputDigest)||r(e)!==t.inputDigest)return T("input digest");if(Ha(t.selectors,"selectors"),!["all","count","digest"].includes(t.measure))return T("measure selector");if(!Number.isSafeInteger(t.resolution)||t.resolution<0)return T("resolution");if(!Array.isArray(t.resolutionProfile)||t.resolutionProfile.some(m=>m.depth!==void 0)||Pn(t.resolutionProfile,t.resolution)!=="inventory")return T("inventory resolution");if(!["canonical-lines","declared-walk-count"].includes(t.unit)||t.unit==="declared-walk-count"&&!Mn(t.countUnit)||t.unit==="canonical-lines"&&t.countUnit!==void 0)return T("unit");let n=t.evidence;if(!n||n.keyClass!=="attest"||!Mn(n.producer)||!Mn(n.provenance))return T("attest declaration");Ha(n.coverage,"coverage");let o;try{o=new TextDecoder("utf8",{fatal:!0}).decode(e)}catch{return T("UTF-8")}if(!o.endsWith(`
30
+ `))return T("document bytes");let i=o.slice(0,-1).split(`
31
+ `);if(i.some(m=>!m)||new Set(i).size!==i.length||[...i].sort(w).join(`
26
32
  `)+`
27
- `}s(Zo,"responseBytes");function ei(e,t){if(!e.endsWith(`
28
- `))throw new Error("REFUSE\xB7signer truncated response");let r=e.slice(0,-1).split(`
29
- `);if(r.length!==t.bytes.length)throw new Error("REFUSE\xB7signer response count");return r.map(n=>{let o=S(n);if(o.kind!=="fact")throw new Error("REFUSE\xB7signer response grammar");let i=o.value.fields,a=ee(i.sig??"");if(Object.keys(i).length!==2||i.by!==t.keyId||!a||a.algorithm!==t.algorithm||x(i)!==n)throw new Error("REFUSE\xB7signer response identity or signature form");return{keyId:i.by,signature:i.sig}})}s(ei,"responseOf");function ti(e,t){let r=s((o,i)=>{let a=e.filter(f=>f.scope===o&&f.measure===i&&f.role==="writes"&&f.value!=="withdraw"),c=[...new Set(a.map(f=>f.value))];if(c.length!==1||!c[0])throw new Error(`REFUSE\xB7signer ${t} missing or conflicting ${o}`);return c[0]},"value"),n=s((o,i)=>{if(e.some(c=>c.scope===o&&c.measure===i&&c.role==="writes"&&c.value!=="withdraw"&&c.form!=="interval"))throw new Error(`REFUSE\xB7signer ${t} invalid ${o}`);let a=re("interval",r(o,i));if(!a||a.kind!=="interval"||a.lo===null||a.lo!==a.hi||!Number.isSafeInteger(a.lo)||a.lo<=0)throw new Error(`REFUSE\xB7signer ${t} invalid ${o}`);return a.lo},"exact");return{name:r(`keys/${t}`,"signer"),timeoutMs:n("signer/timeout","milliseconds"),responseBytes:n("signer/response-bytes","bytes")}}s(ti,"signerSelection");function ri(e,t){let r=e.filter(c=>(c.scope==="wire/reader-lifetime"||c.scope==="audit/wire/reader-lifetime")&&c.value!=="withdraw");if(!r.length)return;if(new Set(r.map(c=>c.value)).size!==1)throw Error("REFUSE\xB7wire conflicting reader lifetime profiles");let o=r[0].value;if(!["bounded-process@1","bounded-process@2"].includes(o??""))throw Error("REFUSE\xB7wire unsupported reader lifetime");let i=typeof t=="string"?t:o==="bounded-process@1"?t.module:t.id,a=s((c,f)=>{let u=[`reader/${c}`,`reader/${i}/${c}`],d=e.filter(g=>u.includes(g.scope??"")&&g.measure===f&&g.value!=="withdraw"&&g.role==="writes");if(!d.length)throw Error(`REFUSE\xB7reader ${i} no declared ${c}`);let l=d.map(g=>{let h=g.form==="interval"?re("interval",g.value??""):void 0;if(!h||h.kind!=="interval"||h.hi===null||!Number.isSafeInteger(h.hi)||h.hi<=0||h.lo===null||h.lo<0||h.lo>h.hi)throw Error(`REFUSE\xB7reader ${i} invalid ${g.scope}`);return{lo:h.lo,hi:h.hi}});if(o==="bounded-process@1")return Math.min(...l.map(g=>g.hi));let p=U(0,1/0),m=l.reduce((g,h)=>p.meet(g,h),p.top);if(!p.inhabited(m))throw Error(`REFUSE\xB7reader ${i} conflicting ${c}`);return m.hi},"limit");return{timeoutMs:a("timeout","milliseconds"),responseBytes:a("response-bytes","bytes")}}s(ri,"readerLifetime");function ni(e,t){let r=e.filter(o=>(o.scope==="wire/reader-empty"||o.scope==="audit/wire/reader-empty")&&o.value!=="withdraw");if(!r.length)return!1;if(r.some(o=>o.value!=="declared-empty@1"))throw Error("REFUSE\xB7wire unsupported empty-reading contract");let n=e.filter(o=>["reader/empty",`reader/${t}/empty`].includes(o.scope??"")&&o.measure==="id"&&o.role==="writes"&&o.value!=="withdraw");if(!n.length)return!1;if(n.some(o=>o.form!=="alphabet"||!["allow","required"].includes(o.value??"")))throw Error(`REFUSE\xB7reader ${t} invalid empty policy`);return n.every(o=>o.value==="allow")}s(ni,"readerAllowsEmpty");function oi(e,t,r){let n=e.filter(i=>(i.scope==="wire/reader-inputs"||i.scope==="audit/wire/reader-inputs")&&i.value!=="withdraw");if(!n.length)return;if(n.some(i=>i.value!=="declared-presence@1"))throw Error("REFUSE\xB7wire unsupported reader input presence");let o=e.filter(i=>["reader/inputs",`reader/${t}/inputs`].includes(i.scope??"")&&i.measure==="id"&&i.role==="writes"&&i.value!=="withdraw");if(!o.length||o.some(i=>i.form!=="alphabet"||!["required","optional"].includes(i.value??"")))throw Error(`REFUSE\xB7reader ${t} no valid input presence policy`);if(r===0&&o.some(i=>i.value==="required"))throw Error(`REFUSE\xB7reader ${t} required input selection is empty`)}s(oi,"assertReaderInputs");function ii(e,t){let r=e.filter(a=>(a.scope==="wire/transport"||a.scope==="audit/wire/transport")&&a.value!=="withdraw");if(!r.length)return;if(r.some(a=>a.value!=="content-request/1"))throw Error("REFUSE\xB7wire unsupported content transport");let o=s((a,c)=>{let f=e.filter(u=>u.scope===a&&u.measure===c&&u.role==="writes"&&u.value!=="withdraw");if(!f.length||new Set(f.map(u=>u.value)).size!==1)throw Error(`REFUSE\xB7transport ${t} missing or conflicting ${a}`);return f[0]},"one")(`transport/${t}`,"id").value;if(!o)throw Error(`REFUSE\xB7transport ${t} has no mechanism`);let i=s((a,c)=>{let f=e.filter(l=>l.scope===a&&l.measure===c&&l.role==="writes"&&l.value!=="withdraw");if(!f.length)throw Error(`REFUSE\xB7transport ${t} missing ${a}`);let u=U(0,1/0),d=f.reduce((l,p)=>{let m=p.form==="interval"?re("interval",p.value??""):void 0;if(!m||m.kind!=="interval"||m.lo===null||m.lo<0||m.hi===null||!Number.isSafeInteger(m.hi)||m.hi<=0||m.lo>m.hi)throw Error(`REFUSE\xB7transport ${t} invalid ${a}`);return u.meet(l,{lo:m.lo,hi:m.hi})},u.top);if(!u.inhabited(d))throw Error(`REFUSE\xB7transport ${t} conflicting ${a}`);return d.hi},"limit");return{name:o,timeoutMs:i("transport/timeout","milliseconds"),responseBytes:i("transport/response-bytes","bytes")}}s(ii,"transportSelection");function si(e,t,r){let n={protocol:"content-request/1",location:e,digest:t,timeoutMs:r.timeoutMs,responseBytes:r.responseBytes};return JSON.stringify(n)+`
30
- `}s(si,"contentRequest");var N=s(e=>{throw new Error(`REFUSE\xB7act ${e}`)},"refuse"),an=s((e,t=!0)=>{let r=S(e);if(r.kind!=="fact"||x(r.value.fields)!==e)return N("noncanonical record");let n=r.value.fields;return!n.by||t&&!ee(n.sig??"")||n.sig!==void 0&&!ee(n.sig)?N("unsigned or invalid record"):n},"fieldsOf"),ai=s(e=>{let t=e.epoch??"",r=Number(t);return!/^(0|[1-9][0-9]*)$/.test(t)||!Number.isSafeInteger(r)?N("invalid local epoch"):r},"epochOf");function wr(e){if(!e.length)return N("empty lot");let t=e.map(r=>z(an(r)));if(new Set(t).size!==t.length)return N("duplicate record");for(let r of e)ai(an(r));return t.join(`
33
+ `!==o)return T("document bytes");let a=i.map(m=>{let y=x(m);return y.kind!=="fact"||v(y.value.fields,y.value.version)!==m||!Ve(m)?T("walk header"):{line:m,fields:y.value.fields}});for(let m of a)if(m.fields.role!=="writes"||!["digest","count"].includes(m.fields.measure??"")||(m.fields.measure==="digest"?m.fields.form!=="alphabet"||!ar(m.fields.value):m.fields.form!=="interval"))return T("walk header fields");let c=a.map(m=>(m.fields.scope??"")+" "+m.fields.measure);if(new Set(c).size!==c.length)return T("ambiguous walk coordinate");let l=a.filter(m=>m.fields.scope==="walk/root");if(l.length!==1||l[0].fields.measure!=="digest"||!ar(l[0].fields.value))return T("walk root");let f=l[0].fields.value;for(let m of a.filter(y=>y.fields.scope!=="walk/root"))if(!m.fields.scope?.startsWith("walk/regions/")||m.fields.condition!==f)return T("walk frame condition");let u=new Set;for(let m of t.selectors){let y=a.filter(b=>ee(m,b.fields.scope??"")&&(t.measure==="all"||b.fields.measure===t.measure));if(!y.length)return T("selector has no lines "+m);for(let b of y)u.add(b.line)}let d=a.filter(m=>u.has(m.line));for(let m of d)if(!n.coverage.some(y=>ee(y,m.fields.scope??"")))return T("outside declared coverage "+m.fields.scope);let p=d.length;if(t.unit==="declared-walk-count"){p=0;for(let m of d){if(m.fields.measure!=="count"||m.fields.form!=="interval")return T("count-only selector");let y=Se(m.line,null);if(y.kind!=="fact"||y.value.bound.kind!=="interval")return T("count value");let b=y.value.bound;if(b.lo===null||b.hi===null||b.lo!==b.hi||!Number.isSafeInteger(b.lo)||b.lo<0)return T("exact count");if(p+=b.lo,!Number.isSafeInteger(p))return T("count range")}}let h=r(new TextEncoder().encode(d.map(m=>m.line).join(`
34
+ `)+`
35
+ `));if(!ar(h))return T("digest algorithm");let g=d.map(m=>({line:m.line,sha256:r(new TextEncoder().encode(m.line+`
36
+ `))}));return g.some(m=>!ar(m.sha256))?T("digest algorithm"):{profile:Un,inputDigest:t.inputDigest,frame:t.frame,resolution:t.resolution,projection:"inventory",walkRoot:f,selectors:[...t.selectors].sort(w),measure:t.measure,unit:t.unit,...t.countUnit?{countUnit:t.countUnit}:{},count:p,matched:g,selectionDigest:h,evidence:n,authentication:"not established",execution:"not established",statisticalConfidence:"not applicable"}}s(Ga,"readRegions");function Ka(e){let t={profile:e.profile,input:e.inputDigest,frame:e.frame,resolution:String(e.resolution),projection:e.projection,root:e.walkRoot,selectors:JSON.stringify(e.selectors),measure:e.measure,unit:e.unit,count:String(e.count),matched:JSON.stringify(e.matched),selection:e.selectionDigest,evidence:JSON.stringify({keyClass:e.evidence.keyClass,producer:e.evidence.producer,provenance:e.evidence.provenance,coverage:[...e.evidence.coverage].sort(w)}),authentication:e.authentication,execution:e.execution,confidence:e.statisticalConfidence,...e.countUnit?{"count-unit":e.countUnit}:{}};return Un+v(t).slice(12)}s(Ka,"encodeRegionReading");var cr="topos-registry-place/1",L=s(e=>{throw Error("REFUSE\xB7registry-place "+e)},"fail"),Bn=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000\r\n]/.test(e),"text"),pi=s(e=>typeof e=="string"&&/^sha256:[0-9a-f]{64}$/.test(e),"hash"),mi=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"obj");function Ln(e,t,r){if(Object.keys(e).some(n=>!t.includes(n)))return L(r)}s(Ln,"keys");function Xa(e,t){return!Array.isArray(e)||e.some(r=>!Bn(r))?L(t):[...new Set(e)].sort(w)}s(Xa,"list");function Ye(e){let t=e;return!mi(t)||(Ln(t,["clock","unit","from","through"],"horizon fields"),!Bn(t.clock)||!Bn(t.unit)||!Number.isSafeInteger(t.from)||!Number.isSafeInteger(t.through)||t.from<0||t.from>t.through)?L("horizon"):{clock:t.clock,unit:t.unit,from:t.from,through:t.through}}s(Ye,"normalizeRegistryHorizon");function gi(e){let t=e;if(!mi(t))return L("quorum");if(Ln(t,["kind","eligible","required"],"quorum fields"),t.kind!=="named-threshold@1")return L("quorum kind");let r=Xa(t.eligible,"quorum eligible");return!r.length||r.length!==t.eligible.length||!Number.isSafeInteger(t.required)||t.required<1||t.required>r.length?L("quorum threshold"):{kind:t.kind,eligible:r,required:t.required}}s(gi,"normalizeRegistryQuorum");function wd(e){if(!mi(e))return L("entry");Ln(e,["kind","place","holder","lineage","shares","card","horizon","quorum","target"],"fields");for(let r of["place","holder","lineage"])if(!Bn(e[r]))return L("identity "+r);if(e.kind!=="admit-lineage"&&e.kind!=="withdraw-exact")return L("kind");let t={kind:e.kind,place:e.place,holder:e.holder,lineage:e.lineage};if(e.kind==="admit-lineage"){if(e.target!==void 0)return L("admission target");if(e.shares!==void 0&&(t.shares=JSON.stringify(Xa(e.shares,"shares"))),e.card!==void 0){if(!pi(e.card))return L("card digest");t.card=e.card}}else{if(!pi(e.target))return L("exact target digest");if(e.shares!==void 0||e.card!==void 0)return L("withdrawal payload");t.target=e.target}return e.horizon!==void 0&&(t.horizon=JSON.stringify(Ye(e.horizon))),e.quorum!==void 0&&(t.quorum=JSON.stringify(gi(e.quorum))),t}s(wd,"normalized");function jt(e){return cr+v(wd(e)).slice(12)}s(jt,"encodeRegistryEntry");function Tn(e){if(!e.startsWith(cr+" "))return L("profile");let t=x("bound-lock/1"+e.slice(cr.length));if(t.kind!=="fact")return L("record");let r=t.value.fields;Ln(r,["kind","place","holder","lineage","shares","card","horizon","quorum","target"],"fields");let n={...r};for(let o of["shares","horizon","quorum"])if(r[o]!==void 0)try{n[o]=JSON.parse(r[o])}catch{return L("JSON "+o)}return jt(n)!==e?L("canonical bytes"):n}s(Tn,"decodeRegistryEntry");function hi(e){return new TextEncoder().encode(jt(e)+`
37
+ `)}s(hi,"registryEntryBytes");function Va(e){let t;try{t=new TextDecoder("utf8",{fatal:!0}).decode(e)}catch{return L("UTF-8")}return!t.endsWith(`
38
+ `)||t.slice(0,-1).includes(`
39
+ `)?L("single line bytes"):t.slice(0,-1)}s(Va,"one");function Ya(e,t){let r=t.artifacts.get(e);return r!==void 0&&t.digestBytes(r)!==e?L("artifact digest"):r}s(Ya,"artifact");function Qa(e,t){let r=Tn(jt(e)),n=[];if(r.horizon===void 0&&n.push("horizon"),r.quorum===void 0&&n.push("quorum"),r.kind==="admit-lineage")if(r.shares===void 0&&n.push("shares"),r.card===void 0)n.push("card");else{let i=Ya(r.card,t);i===void 0?n.push("bytes/card:"+r.card):Nt(dt(Va(i)),t.catalog)}else{let i=Ya(r.target,t);if(i===void 0)n.push("bytes/target:"+r.target);else{let a=Tn(Va(i));if(a.kind!=="admit-lineage")return L("target is not admission");if(a.place!==r.place||a.holder!==r.holder||a.lineage!==r.lineage)return L("target attribution")}}let o=t.digestBytes(hi(r));return pi(o)?{status:n.length?"open":"declared",entry:r,identity:o,needs:n.sort(w),authority:"not established",quorumDecision:"not evaluated",horizonDecision:"not evaluated",independence:"not established"}:L("digest algorithm")}s(Qa,"inspectRegistryEntry");function Za(e){return[...new Set(e.map(jt))].sort(w).map(t=>t+`
40
+ `).join("")}s(Za,"registryLines");var lr=s(e=>({tokens:Be("alphabet",e,"tokens")}),"tokensOf"),qn={id:"alphabet",lattice:s(e=>Fe.lattice(lr(e)),"lattice"),parse(e,t){let{tokens:r}=lr(e),n=M(t),o=n.members.find(i=>!r.includes(i));return o!==void 0&&ke("alphabet",`\`${o}\` is not one of its tokens`),ve.fromTokens(r,new Set(n.polarity==="forbid"?r.filter(i=>!n.members.includes(i)):n.members))},emit:s((e,t)=>kn(t.members(lr(e).tokens)),"emit"),show:s((e,t)=>Fe.lattice(lr(e)).show(t),"show"),points:s((e,t,r)=>Fe.points(lr(e),t,r),"points")};var dr="topos-ci/1",q=s(e=>{throw Error("REFUSE\xB7ci-form "+e)},"fail"),Dn=s(e=>typeof e=="string"&&/^sha256:[0-9a-f]{64}$/.test(e),"hash"),ut=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000\r\n]/.test(e),"text"),yi=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"object");function zn(e,t){if(Object.keys(e).some(r=>!t.includes(r)))return q("fields")}s(zn,"keys");function tc(e){return!Array.isArray(e)||!e.length||new Set(e).size!==e.length||e.some(t=>!ut(t)||/[\s*?#\\]/.test(t)||t.split("/").some(r=>r===""||r==="."||r===".."))?q("limited coverage"):[...e].sort(w)}s(tc,"scopes");function vd(e){if(!yi(e))return q("declaration");if(zn(e,["workflow","projection","job","runsOn","node","artifact","keyClass","coverage","witness","provenance","evidence"]),!Dn(e.workflow)||!Dn(e.projection)||!Dn(e.artifact))return q("content identity");if(!ut(e.job)||!ut(e.runsOn)||!Number.isSafeInteger(e.node)||e.node<1||!ut(e.provenance))return q("pipeline declaration");if(e.keyClass!=="attest")return q("attest class");if(!ut(e.witness)||!e.witness.startsWith("witness:")||e.witness.length===8)return q("witness");if(e.witness.includes("/"))return q("witness slash has step semantics; opaque namespace requires another profile");if(!/^witness:[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(e.witness))return q("witness");if(!yi(e.evidence))return q("execution evidence");if(e.evidence.kind==="unobserved")zn(e.evidence,["kind"]);else if(e.evidence.kind==="reported"){if(zn(e.evidence,["kind","run","receipt"]),!ut(e.evidence.run)||!Dn(e.evidence.receipt))return q("execution evidence")}else return q("execution evidence");return{workflow:e.workflow,projection:e.projection,job:e.job,"runs-on":e.runsOn,node:String(e.node),artifact:e.artifact,"key-class":e.keyClass,coverage:JSON.stringify(tc(e.coverage)),witness:e.witness,provenance:e.provenance,evidence:JSON.stringify(e.evidence.kind==="unobserved"?{kind:"unobserved"}:{kind:"reported",run:e.evidence.run,receipt:e.evidence.receipt})}}s(vd,"fields");function Wn(e){return dr+v(vd(e)).slice(12)}s(Wn,"encodeCiDeclaration");function bi(e){if(!e.startsWith(dr+" "))return q("profile");let t=x("bound-lock/1"+e.slice(dr.length));if(t.kind!=="fact")return q("record");let r=t.value.fields;zn(r,["workflow","projection","job","runs-on","node","artifact","key-class","coverage","witness","provenance","evidence"]);let n,o;try{n=JSON.parse(r.coverage),o=JSON.parse(r.evidence)}catch{return q("JSON field")}let i={workflow:r.workflow,projection:r.projection,job:r.job,runsOn:r["runs-on"],node:Number(r.node),artifact:r.artifact,keyClass:r["key-class"],coverage:n,witness:r.witness,provenance:r.provenance,evidence:o};return Wn(i)!==e?q("canonical bytes"):i}s(bi,"decodeCiDeclaration");function ec(e,t,r){try{let n=qn.parse({tokens:e},t),o=n.members(e);if(o.length!==1||o[0]!==t)return q(r)}catch{return q(r)}}s(ec,"one");function rc(e,t){let r=bi(Wn(e));if(t.digestBytes(t.workflowBytes)!==r.workflow||t.digestBytes(t.projectionBytes)!==r.projection)return q("handed input digest");let n;try{n=JSON.parse(new TextDecoder("utf8",{fatal:!0}).decode(t.projectionBytes))}catch{return q("projection document")}if(!yi(n)||n.workflowDigest!==r.workflow||n.job!==r.job||n.runsOnExpression!=="${{ matrix.os }}"||n.artifactDigest!==r.artifact)return q("selected pipeline binding");if(!Array.isArray(n.runners)||!n.runners.length||n.runners.some(a=>!ut(a))||!Array.isArray(n.nodes)||!n.nodes.length||n.nodes.some(a=>!Number.isSafeInteger(a)||Number(a)<1)||!Array.isArray(n.allowedCoverage))return q("selected pipeline domain");ec(n.runners,r.runsOn,"runner outside declared matrix"),ec(n.nodes.map(String),String(r.node),"node outside declared matrix");let o=tc(n.allowedCoverage);for(let a of r.coverage)if(!o.some(c=>yn(c,a)))return q("outside selected coverage "+a);let i=[];for(let a of[r.artifact,...r.evidence.kind==="reported"?[r.evidence.receipt]:[]]){let c=t.artifacts.get(a);if(c===void 0)i.push("bytes:"+a);else if(t.digestBytes(c)!==a)return q("artifact digest")}return{status:i.length?"open":"declared",declaration:r,needs:i.sort(w),coverageStatus:"declared only",authority:"not established",execution:"not established",evidence:r.evidence.kind==="reported"?"reported-unverified":"unobserved",needsVerification:["selected producer extraction","CI execution and artifact binding","attestation authenticity and actual coverage"],statisticalConfidence:"not applicable"}}s(rc,"inspectCiDeclaration");var Xe=[0n,1n],nc=[1n,1n],Jn=s(e=>{throw new Error("REFUSE\xB7model/M3 "+e)},"refuse"),Ed=s((e,t)=>{for(e=e<0n?-e:e;t;){let r=e%t;e=t,t=r}return e},"gcd");function $t(e,t=1n){t===0n&&Jn("zero rational denominator"),t<0n&&(e=-e,t=-t);let r=Ed(e,t);return[e/r,t/r]}s($t,"q");function Pt(e){if(typeof e=="string"){if(/^-?\d+\/\d+$/.test(e)){let[i,a]=e.split("/");return $t(BigInt(i),BigInt(a))}/^-?\d+(\.\d+)?$/.test(e)||Jn("invalid exact probability");let t=e.startsWith("-")?-1n:1n,r=e.replace(/^-/,""),[n,o=""]=r.split(".");return $t(t*BigInt(n+o),10n**BigInt(o.length))}return(!e||typeof e.numerator!="string"||typeof e.denominator!="string"||!/^[-]?\d+$/.test(e.numerator)||!/^\d+$/.test(e.denominator))&&Jn("invalid rational"),$t(BigInt(e.numerator),BigInt(e.denominator))}s(Pt,"rational");var ft=s((e,t)=>$t(e[0]*t[1]+t[0]*e[1],e[1]*t[1]),"add"),oc=s((e,t)=>$t(e[0]*t[1]-t[0]*e[1],e[1]*t[1]),"sub");var wi=s((e,t)=>$t(e[0]*t[1],e[1]*t[0]),"div");var ic=s((e,t)=>e[0]===t[0]&&e[1]===t[1],"equal"),Oe=s(e=>({numerator:String(e[0]),denominator:String(e[1])}),"pack");function sc(e){let t=Pt(e);return(t[0]<0n||t[0]>t[1])&&Jn("probability outside 0..1"),t}s(sc,"probability");var _e=s(e=>{throw Error("REFUSE\xB7mix-loss "+e)},"refuse"),ac=s((e,t=!1)=>{try{return t?sc(e):Pt(e)}catch{return _e("invalid "+(t?"prior probability":"factor weight"))}},"exact"),cc=s(e=>{let t=Math.max(0,e.toString(2).length-53);return Math.log2(Number(e>>BigInt(t)))+t},"logInteger"),lc=s(e=>cc(e[0])-cc(e[1]),"logQ"),dc=s(e=>e[0]===0n?0:2**lc(e),"numeric"),vi=s(e=>e.reduce((t,r)=>r[0]===0n?t:t-dc(r)*lc(r),0),"entropy"),Ei=s((e,t)=>{(!Array.isArray(e)||!e.length||e.some(r=>typeof r!="string"||!r.trim())||new Set(e).size!==e.length)&&_e("distinct nonempty "+t+" required")},"uniqueNames");function xi(e,t){(!t||t.logarithm!=="binary64-log2"||typeof t.budget!="string"||!/^\d+$/.test(t.budget))&&_e("logarithm and work budget required"),(!e||!Array.isArray(e.factors)||!Array.isArray(e.alphabet)||!Array.isArray(e.configurations))&&_e("declared factors, alphabet and configuration support required"),Ei(e.factors.map(g=>g?.id),"factor IDs"),Ei(e.alphabet,"alphabet values"),Ei(e.configurations.map(g=>g?.id),"configuration IDs");let r=new Set(e.alphabet),n=new Set;for(let g of e.configurations){(!Array.isArray(g.values)||g.values.length!==e.factors.length||g.values.some(y=>!r.has(y)))&&_e("configuration outside declared factor/alphabet domain");let m=JSON.stringify(g.values);n.has(m)&&_e("duplicate named-factor configuration"),n.add(m)}let o=e.factors.map(g=>ac(g.weight));(o.some(g=>g[0]<0n)||o.every(g=>g[0]===0n))&&_e("nonnegative weights with positive total required");let i={m:e.factors.length,factors:e.factors.map((g,m)=>({id:g.id,weight:Oe(o[m])})),alphabet:[...e.alphabet],configurations:e.configurations.map(g=>({id:g.id,values:[...g.values]}))};if(!e.prior)return{status:"unmeasured",cause:"mix-loss/prior-required",parameters:i,policy:t};let a=BigInt(e.configurations.length);if(a>BigInt(t.budget))return{status:"unmeasured",cause:"mix-loss/work-budget",parameters:i,policy:t,required:String(a),workUnit:"declared-configurations"};let c;if(e.prior.kind==="uniform")c=e.configurations.map(()=>wi(nc,[BigInt(e.configurations.length),1n]));else if(e.prior.kind==="explicit"){let g=e.prior.probabilities;(!Array.isArray(g)||g.length!==e.configurations.length||g.some(b=>!b||typeof b.configuration!="string")||new Set(g.map(b=>b.configuration)).size!==g.length)&&_e("one prior probability per configuration required");let m=new Map(g.map(b=>[b.configuration,ac(b.p,!0)]));e.configurations.some(b=>!m.has(b.id))&&_e("prior support differs from declared configurations"),c=e.configurations.map(b=>m.get(b.id));let y=c.reduce(ft,Xe);y[0]!==y[1]&&_e("prior probabilities must sum exactly to one")}else return _e("declared prior kind required");let l=new Map,f=e.configurations.map((g,m)=>{let y=new Map(e.alphabet.map(N=>[N,Xe]));g.values.forEach((N,C)=>y.set(N,ft(y.get(N),o[C])));let b=Xe;for(let N of y.values())N[0]*b[1]>b[0]*N[1]&&(b=N);let F=e.alphabet.filter(N=>{let C=y.get(N);return C[0]*b[1]===b[0]*C[1]}),P=F.length===1?{kind:"value",value:F[0]}:{kind:"tie",values:F},G=P.kind==="tie"?"tie":JSON.stringify(["value",P.value]),ge=l.get(G)??{output:P.kind==="tie"?{kind:"tie",values:[]}:P,indices:[]};return ge.indices.push(m),l.set(G,ge),{id:g.id,probability:Oe(c[m]),mix:P.kind==="tie"?{kind:"tie"}:P,fork:e.factors.map((N,C)=>({factor:N.id,value:g.values[C]}))}}),u=[...l.values()].map(g=>{let m=g.indices.map(b=>c[b]).reduce(ft,Xe),y=m[0]===0n?[]:g.indices.map(b=>({configuration:e.configurations[b].id,p:wi(c[b],m)}));return{output:g.output.kind==="tie"?{kind:"tie"}:g.output,probability:Oe(m),configurations:g.indices.map(b=>e.configurations[b].id),posterior:y.map(b=>({configuration:b.configuration,p:Oe(b.p)})),conditionalBits:m[0]===0n?null:vi(y.map(b=>b.p)),mass:m}}),d=vi(c),p=vi(u.map(g=>g.mass)),h=u.reduce((g,m)=>g+(m.conditionalBits===null?0:dc(m.mass)*m.conditionalBits),0);return{status:"measured",model:"declared-weighted-mix-projection@1",parameters:i,prior:{kind:e.prior.kind,probabilities:e.configurations.map((g,m)=>({configuration:g.id,p:Oe(c[m])}))},policy:t,unit:"bits",approximation:"binary64-log2",configurationBits:d,mixBits:p,lossBits:h,entropyDifferenceBits:d-p,forkLossBits:0,mixInjectiveOnConfigurations:[...l.values()].every(g=>g.indices.length===1),mixInjectiveOnPositiveSupport:[...l.values()].every(g=>g.indices.filter(m=>c[m][0]>0n).length<=1),configurations:f,outputs:u.map(({mass:g,...m})=>m),meaning:"conditional entropy of the declared configuration given its deterministic mix output; named fork is injective"}}s(xi,"mixProjectionLoss");var Ie=s(e=>{throw Error("REFUSE\xB7region-measure/"+e)},"refuse"),ur=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000-\u001f\u007f]/.test(e),"name");function Ri(e,t){if(!e||e.model!=="finite-nonnegative-atomic-valuation@1"||!ur(e.unit))return Ie("model-and-unit");if(Object.keys(e).some(d=>!["model","unit","atoms","regions"].includes(d))||!Array.isArray(e.atoms)||!Array.isArray(e.regions))return Ie("domain");if(!t||typeof t.budget!="string"||!/^(0|[1-9][0-9]*)$/.test(t.budget))return Ie("budget");let r=BigInt(e.atoms.length)+BigInt(e.regions.length);for(let d of e.regions){if(!d||!ur(d.id)||!Array.isArray(d.members)||!d.members.every(ur)||Object.keys(d).some(p=>!["id","members"].includes(p)))return Ie("region");r+=BigInt(d.members.length)}if(r>BigInt(t.budget))return{status:"unmeasured",cause:"region-measure/budget",required:String(r),workUnit:"declared-input-rows"};let n=new Map;for(let d of e.atoms){if(!d||!ur(d.id)||Object.keys(d).some(g=>!["id","value"].includes(g)))return Ie("atom");let p;try{p=Pt(d.value)}catch{return Ie("weight")}if(p[0]<0n)return Ie("negative-weight");let h=n.get(d.id);if(h!==void 0&&!ic(h,p))return Ie("conflicting-atom");n.set(d.id,p)}let o=new Set,i=new Map,a=s(d=>d.reduce((p,h)=>ft(p,n.get(h)),Xe),"sum"),c=e.regions.map(d=>{if(o.has(d.id))return Ie("duplicate-region");o.add(d.id);let p=[...new Set(d.members)].sort();for(let h of p){if(!ur(h)||!n.has(h))return Ie("unknown-atom");let g=i.get(h)??[];g.push(d.id),i.set(h,g)}return{region:d.id,members:p,value:Oe(a(p))}}).sort((d,p)=>d.region<p.region?-1:d.region>p.region?1:0),l=[...i.keys()].sort(),f=a(l),u=c.reduce((d,p)=>ft(d,Pt(p.value)),Xe);return{status:"measured",model:e.model,unit:e.unit,arithmetic:"exact-rational",readings:c,union:{members:l,value:Oe(f)},sumOfRegions:Oe(u),overlapExcess:Oe(oc(u,f)),disjointBySupport:[...i.values()].every(d=>d.length===1),overlaps:[...i].filter(([,d])=>d.length>1).map(([d,p])=>({atom:d,regions:[...p].sort()})).sort((d,p)=>d.atom<p.atom?-1:d.atom>p.atom?1:0),unassigned:[...n.keys()].filter(d=>!i.has(d)).sort(),work:{unit:"declared-input-rows",required:String(r)}}}s(Ri,"finiteRegionMeasure");var Oi={name:"finite-deterministic-chain-same-prior@1",contract:"sha256:34add91f4dfd04d38490f85577fcbb95059a58803c8b82c4a82af2d265a421d9",implementation:"sha256:af9c6a3dbeda91981b394b61e187f916dc0e0304801b7b654ff3e025ebce94cb"},Hn="topos-projection-chain/1",Pe=s(e=>{throw Error(`REFUSE\xB7${e}`)},"refuse"),ki=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000\r\n]/.test(e),"name");function Si(e,t){if(!Array.isArray(e)||e.length!==t.length)return Pe("projection/non-chain");let r=new Map;for(let n of e){if(!Array.isArray(n)||n.length!==2||!ki(n[0])||!ki(n[1]))return Pe("projection/randomized-map");if(!t.includes(n[0])||r.has(n[0]))return Pe("projection/non-chain");r.set(n[0],n[1])}return r}s(Si,"mapping");function uc(e){if(!e||typeof e!="object"||e.profile!==Hn)return Pe("projection/profile");if(Object.keys(e).some(h=>!["profile","atoms","f","g","direct","prior","policy"].includes(h)))return Pe("projection/changed-prior");if(!Array.isArray(e.atoms)||!e.atoms.length||!e.atoms.every(ki)||new Set(e.atoms).size!==e.atoms.length)return Pe("projection/domain");let t=e.policy;if(!t||t.logarithm!=="binary64-log2"||typeof t.budget!="string"||!/^(0|[1-9][0-9]*)$/.test(t.budget)||Object.keys(t).some(h=>h!=="logarithm"&&h!=="budget"))return Pe("projection/policy");if(2n*BigInt(e.atoms.length)+1n>BigInt(t.budget))return{status:"unmeasured",cause:"mix-loss/work-budget",workUnit:"declared-configurations"};let n=[...e.atoms].sort(w),o=Si(e.f,n),i=[...new Set(o.values())].sort(w),a=Si(e.g,i);if(e.direct!==void 0){let h=Si(e.direct,n);if(n.some(g=>h.get(g)!==a.get(o.get(g))))return Pe("projection/non-chain")}let c=2n*BigInt(n.length)+BigInt(i.length);if(c>BigInt(t.budget))return{status:"unmeasured",cause:"mix-loss/work-budget",required:String(c),workUnit:"declared-configurations"};let l=s((h,g,m)=>xi({factors:[{id:"source",weight:"0"},{id:"projection",weight:"1"}],alphabet:[...new Set([...h,...g.values()])].sort(w),configurations:h.map(y=>({id:y,values:[y,g.get(y)]})),...m===void 0?{}:{prior:m}},t),"project"),f=l(n,o,e.prior);if(f.status==="unmeasured")return f;let u={kind:"explicit",probabilities:f.outputs.map(h=>h.output.kind!=="value"?Pe("projection/non-chain"):{configuration:h.output.value,p:h.probability})},d=l(i,a,u),p=l(n,new Map(n.map(h=>[h,a.get(o.get(h))])),{kind:"explicit",probabilities:f.prior.probabilities});return d.status!=="measured"||p.status!=="measured"?Pe("projection/evaluation"):{status:"measured",profile:Hn,model:Oi,unit:"bits",approximation:"binary64-log2",work:{unit:"declared-configurations",required:String(c)},parameters:{atoms:n,f:n.map(h=>[h,o.get(h)]),g:i.map(h=>[h,a.get(h)]),prior:f.prior,policy:t},loss:{xy:f.lossBits,yz:d.lossBits,xz:p.lossBits},residualBits:p.lossBits-f.lossBits-d.lossBits,certification:"finite model evaluation; not a general Lean certificate"}}s(uc,"measureProjectionChain");var fr="topos-reading-witness/1",xd=["class","reading","contract","model","params","inputs","selection","unit","scale","resolution","reader","implementation","context","run","result","authentication","evidence"],Rd=["reading","contract","model","params","inputs","selection","scale","resolution","reader","implementation","context","result","evidence"],Ae=s(e=>{throw Error("REFUSE\xB7reading-witness/"+e)},"fail"),Sd=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000-\u0020\u007f]/.test(e),"word"),_i=s(e=>typeof e=="string"&&/^sha256:[0-9a-f]{64}$/.test(e),"digest");function fc(e){if(e===null||typeof e!="object"||Array.isArray(e))return Ae("record");let t=e,r;if(t.authentication==="key-covered")r=["key","coverage"];else if(t.authentication==="ci-run-unkeyed")r=["repository","commit","workflow","attempt"];else return Ae("authentication-profile");let n=[...xd,...r];if(n.some(o=>!Object.prototype.hasOwnProperty.call(t,o))||Object.keys(t).some(o=>!n.includes(o)))return Ae("fields");if(Object.values(t).some(o=>!Sd(o)))return Ae("field-value");if(t.class!=="attest")return Ae("reading-class");if(Rd.some(o=>!_i(t[o])))return Ae("digest");if(t.authentication==="key-covered"){if(!_i(t.coverage))return Ae("coverage")}else if(!_i(t.workflow)||typeof t.attempt!="string"||!/^[1-9][0-9]*$/.test(t.attempt))return Ae("ci-context");return{...t}}s(fc,"fields");function Ii(e){let{evidence:t,...r}=fc(e);return"topos-reading-statement/1"+v(r).slice(12)}s(Ii,"readingWitnessStatementBytes");function Mt(e){return fr+v(fc(e)).slice(12)}s(Mt,"encodeReadingWitness");function pr(e){if(typeof e!="string"||!e.startsWith(fr+" "))return Ae("profile");let t=x("bound-lock/1"+e.slice(fr.length));if(t.kind!=="fact")return Ae("record");let r=t.value.fields;return Mt(r)!==e?Ae("canonical-bytes"):Object.freeze({...r})}s(pr,"decodeReadingWitness");function pc(e){let t=Mt(e),r=pr(t);return{status:"declared",witness:r,bytes:t,statementBytes:Ii(r),authentication:"not verified",authorization:"not established",needsVerification:["reading/model/input/selection/implementation/context/result digest bindings","declared unit, scale composition law and resolution",r.authentication==="key-covered"?"key signature and admitted coverage over this reading":"CI evidence binds repository, commit, workflow, run, attempt and output","consuming policy accepts this evidence for the requested obligation"]}}s(pc,"inspectReadingWitness");var Kn="topos-physical-lines/1",Ai={name:"finite-nonnegative-atomic-valuation@1",contract:"sha256:636ace16eeaa46eafb7b07c28d1d57916bc9108b188e96b5a8bf7bed6dc15707",implementation:"sha256:ef7e39d0ac44b0dd3d4b68220d3c381f737eb2729d0017ed3271ce119d408b13"},Me=s(e=>{throw Error("REFUSE\xB7physical-lines/"+e)},"refuse"),mc=s(e=>typeof e=="string"&&/^sha256:[0-9a-f]{64}$/.test(e),"digest"),yc=s(e=>typeof e=="string"&&e.length>0&&!/[\u0000-\u001f\u007f]/.test(e),"name"),gc=s(e=>yc(e)&&!e.includes("\\")&&e.split("/").every(t=>t!==""&&t!=="."&&t!==".."),"path"),hc=s(e=>typeof e=="string"&&/^(0|[1-9][0-9]*)$/.test(e),"integer"),Gn=s((e,t)=>Object.keys(e).every(r=>t.includes(r)),"fields");function bc(e,t){if(typeof t!="function")return Me("digest-port");if(!e||e.profile!==Kn||!Gn(e,["profile","snapshot","files","regions","policy"])||!mc(e.snapshot))return Me("profile");if(!Array.isArray(e.files)||!Array.isArray(e.regions)||!e.policy||!Gn(e.policy,["byteBudget","rowBudget"])||!hc(e.policy.byteBudget)||!hc(e.policy.rowBudget))return Me("policy");let r=0n,n=new Set,o=new Set;for(let u of e.files){if(!u||!Gn(u,["name","digest","bytes"])||!gc(u.name)||u.name.includes("*")||!mc(u.digest)||!(u.bytes instanceof Uint8Array))return Me("file");if(n.has(u.name))return Me("duplicate-file");n.add(u.name),r+=BigInt(u.bytes.length)}for(let u of e.regions){if(!u||!Gn(u,["scope","selectors"])||!yc(u.scope)||!Array.isArray(u.selectors)||!u.selectors.length||!u.selectors.every(d=>gc(d)&&d.split("/").every(p=>!p.includes("**")||p==="**")))return Me("selector");if(o.has(u.scope))return Me("duplicate-region");o.add(u.scope)}if(r>BigInt(e.policy.byteBudget))return{status:"unmeasured",cause:"physical-lines/byte-budget",required:String(r),workUnit:"input-bytes"};let i=e.regions.reduce((u,d)=>u+d.selectors.reduce((p,h)=>p+BigInt(h.length),0n)*BigInt(e.files.length+1),0n);if(i>BigInt(e.policy.rowBudget))return{status:"unmeasured",cause:"physical-lines/selection-budget",required:String(i),workUnit:"selector-code-units-times-candidates"};let a=[...e.files].sort((u,d)=>w(u.name,d.name)),c=a.map(u=>{if(t(u.bytes)!==u.digest)return Me("integrity");try{new TextDecoder("utf-8",{fatal:!0}).decode(u.bytes)}catch{return Me("utf8")}let d=0n;for(let p=0;p<u.bytes.length;p++){if(u.bytes[p]===13&&u.bytes[p+1]!==10)return Me("isolated-cr");u.bytes[p]===10&&d++}return u.bytes.length&&u.bytes[u.bytes.length-1]!==10&&d++,{id:u.name,value:String(d)}}),l=[...e.regions].sort((u,d)=>w(u.scope,d.scope)).map(u=>{let d=[...new Set(u.selectors)].sort(w),p=d.map(h=>{let g=a.filter(m=>ee(h,m.name)).map(m=>m.name);return g.length?{selector:h,members:g,status:"selected"}:{selector:h,members:g,status:"unmeasured",cause:"selector-no-match"}});return{scope:u.scope,selectors:d,selections:p,members:[...new Set(p.flatMap(h=>h.members))].sort(w)}}),f=Ri({model:"finite-nonnegative-atomic-valuation@1",unit:"physical-lines/utf8-lf@1",atoms:c,regions:l.filter(u=>u.members.length).map(u=>({id:u.scope,members:u.members}))},{budget:e.policy.rowBudget});return f.status==="unmeasured"?f:{status:"read",profile:Kn,snapshot:e.snapshot,model:Ai,policy:{...e.policy},textDomain:"utf8-lf-crlf-reject-isolated-cr@1",inputFiles:a.map(u=>({name:u.name,digest:u.digest})),regions:l.map(u=>u.members.length?{...u,status:"measured",value:f.readings.find(d=>d.region===u.scope).value}:{...u,status:"unmeasured",cause:"selector-no-match"}),valuation:f,work:{inputBytes:String(r),selectionUnits:String(i)},verification:"supplied inventory and snapshot; authority and completeness are consumer obligations"}}s(bc,"readPhysicalLines");var E=s(e=>{throw Error("REFUSE\xB7"+e)},"recordFail");function I(e,t,r=[]){if(e===null||typeof e!="object"||Array.isArray(e))return E("record/object");let n=e;return t.some(o=>!Object.prototype.hasOwnProperty.call(n,o))||Object.keys(n).some(o=>![...t,...r].includes(o))?E("record/fields"):n}s(I,"recordObject");function A(e){return typeof e!="string"||!e||/[\u0000-\u0020\u007f]/.test(e)?E("record/name"):e}s(A,"recordText");function V(e){let t=A(e);return t!=="."&&(t.startsWith("/")||t.includes("\\")||t.split("/").some(r=>!r||r==="."||r===".."))?E("record/coordinate"):t}s(V,"recordCoordinate");function O(e){let t=A(e);return/^sha256:[a-f0-9]{64}$/.test(t)?t:E("record/digest")}s(O,"recordDigest");function Fi(e){if(!e||!Number.isSafeInteger(e.bytes)||e.bytes<1||!Number.isSafeInteger(e.items)||e.items<0)return E("record/budget")}s(Fi,"recordBudget");function D(e,t,r){return Fi(t),!Array.isArray(e)||e.length>t.items?E("record/items"):e.map(r)}s(D,"recordList");function Ut(e,t,r=A){let n=D(e,t,r);return new Set(n).size!==n.length?E("record/duplicate"):n.sort(w)}s(Ut,"recordNames");function H(e,t,r){if(Fi(r),Object.values(t).some(o=>o.length>r.bytes))return E("record/bytes");let n=e+v(t).slice(12);return n.length>r.bytes||new TextEncoder().encode(n).length>r.bytes?E("record/bytes"):n}s(H,"recordLine");function Y(e,t,r){if(Fi(r),typeof t!="string"||t.length>r.bytes||new TextEncoder().encode(t).length>r.bytes)return E("record/bytes");if(!t.startsWith(e+" "))return E("record/profile");let n=x("bound-lock/1"+t.slice(e.length));return n.kind!=="fact"?E("record/line"):{...n.value.fields}}s(Y,"recordFields");function Q(e){try{return JSON.parse(e)}catch{return E("record/json")}}s(Q,"recordJSON");function Z(e,t){if(e!==t)return E("record/canonical")}s(Z,"recordCanonical");var Vn="topos-authority-card/1",Ci=["place","snapshot","key","authority","coverage","policy","budget","catalog","standingContract","issuedAt","grants","retirements","demands","horizon","actions","evidence"],kd=["snapshot","authority","coverage","policy","budget","catalog","standingContract","evidence"];function Ni(e,t){let r=I(e,Ci),n={...r};V(r.place),A(r.key);for(let a of kd)O(r[a]);let o=Ye(n.horizon);if(!Number.isSafeInteger(r.issuedAt)||n.issuedAt<o.from||n.issuedAt>o.through)return E("authority-card/clock");let i=D(r.actions,t,a=>{let c=I(a,["request","decision"]);return O(c.request),["allow","ask","deny"].includes(String(c.decision))?{request:c.request,decision:c.decision}:E("authority-card/decision")}).sort((a,c)=>w(a.request,c.request));return new Set(i.map(a=>a.request)).size!==i.length?E("authority-card/duplicate-action"):{...n,horizon:o,actions:i,grants:Ut(r.grants,t,O),retirements:Ut(r.retirements,t,O),demands:Ut(r.demands,t,O)}}s(Ni,"checked");function wc(e){return Object.fromEntries(Ci.map(t=>[t,typeof e[t]=="string"?e[t]:JSON.stringify(e[t])]))}s(wc,"fields");function mr(e,t){return H(Vn,wc(Ni(e,t)),t)}s(mr,"encodeAuthorityCard");function Yn(e,t){let r=Y(Vn,e,t);I(r,Ci);let n=Ni({...r,...Object.fromEntries(["grants","retirements","demands","horizon","actions","issuedAt"].map(o=>[o,Q(r[o])]))},t);return Z(mr(n,t),e),n}s(Yn,"decodeAuthorityCard");function ji(e,t){let{evidence:r,...n}=wc(Ni(e,t));return H("topos-authority-statement/1",n,t)}s(ji,"authorityCardStatement");function vc(e,t){return{status:"declared",card:Yn(mr(e,t),t),authentication:"not verified",authorization:"not established"}}s(vc,"inspectAuthorityCard");function Ec(e,t,r,n){let o=Yn(mr(e,n),n);O(t);let i=s(()=>({status:"refused",code:"card-stale",next:"refresh-card"}),"stale");if(!r||!r.clock||typeof r.verifiesJudgment!="function")return E("authority-card/consumer-context");for(let c of["place","snapshot","key","authority","coverage","policy","budget","catalog","standingContract"])if(o[c]!==r[c])return i();if(r.clock.name!==o.horizon.clock||r.clock.unit!==o.horizon.unit||!Number.isSafeInteger(r.clock.now)||r.clock.now<o.issuedAt||r.clock.now>o.horizon.through)return i();let a=o.actions.find(c=>c.request===t);return a?r.verifiesJudgment(ji(o,n),o.evidence)!==!0?{status:"open",needs:["authority-card/verified-judgment"]}:{status:"observed",decision:a.decision,source:"consumer-verified-judgment"}:{status:"refused",code:"not-in-card",next:"request-card-entry"}}s(Ec,"authorityCardAnswer");var Xn="topos-attributed-origin/1",Qn="topos-written-refusal/1";function $i(e){let t=I(e,["origin","key","scope","context"],["evidence"]);return O(t.origin),O(t.context),A(t.key),V(t.scope),t.evidence!==void 0&&O(t.evidence),{...t}}s($i,"origin");function xc(e){let t=I(e,["producer","code","request","scope","context","next"],["evidence"]);for(let r of["producer","code","next"])A(t[r]);return V(t.scope),O(t.request),O(t.context),t.evidence!==void 0&&O(t.evidence),{...t}}s(xc,"refusal");function gr(e,t){return H(Xn,$i(e),t)}s(gr,"encodeAttributedOrigin");function Zn(e,t){let r=$i(Y(Xn,e,t));return Z(gr(r,t),e),r}s(Zn,"decodeAttributedOrigin");function Pi(e,t){let{evidence:r,...n}=$i(e);return H("topos-origin-statement/1",n,t)}s(Pi,"originStatement");function Rc(e,t){let r=Zn(gr(e,t),t);return{status:"attributed",origin:r,authentication:"not verified",authorization:"not established",needs:r.evidence===void 0?["origin/covering-evidence"]:["origin/coverage-verification"]}}s(Rc,"inspectAttributedOrigin");function Sc(e,t,r){let n=Zn(gr(e,r),r);return!t||typeof t.verifiesCoverage!="function"?E("origin/consumer-context"):n.key!==t.key||n.context!==t.context?E("origin/context"):n.evidence===void 0||t.verifiesCoverage(Pi(n,r),n.evidence,n.key,n.scope)!==!0?{status:"open",needs:["origin/verified-coverage"]}:{status:"authenticated-attribution",origin:n,authorization:"not established"}}s(Sc,"authenticateOrigin");function Mi(e,t){return H(Qn,xc(e),t)}s(Mi,"encodeWrittenRefusal");function kc(e,t){let r=xc(Y(Qn,e,t));return Z(Mi(r,t),e),r}s(kc,"decodeWrittenRefusal");var oe=s(e=>{throw new Error(`REFUSE\xB7act ${e}`)},"refuse"),Ui=s((e,t=!0)=>{let r=x(e);if(r.kind!=="fact"||v(r.value.fields)!==e)return oe("noncanonical record");let n=r.value.fields;return!n.by||t&&!Re(n.sig??"")||n.sig!==void 0&&!Re(n.sig)?oe("unsigned or invalid record"):n},"fieldsOf"),Oc=s(e=>{let t=e.epoch??"",r=Number(t);return!/^(0|[1-9][0-9]*)$/.test(t)||!Number.isSafeInteger(r)?oe("invalid local epoch"):r},"epochOf");function eo(e){if(!e.length)return oe("empty lot");let t=e.map(r=>pe(Ui(r)));if(new Set(t).size!==t.length)return oe("duplicate record");for(let r of e)Oc(Ui(r));return t.join(`
31
41
  `)+`
32
- `}s(wr,"actBytes");function cn(e,t){if(!t.scope||!t.context)return N("missing receipt contract");let r=wr(e),n=t.placements,o="";if(n!==void 0){let i=new Set,a=new Set,c=new Set(e);for(let f of n){if(!f.place||a.has(f.place)||f.place!=="."&&(f.place.startsWith("/")||f.place.split("/").some(u=>!u||u==="."||u==="..")))return N("invalid receiving coordinate");a.add(f.place);for(let u of f.records){if(!c.has(u))return N("placement contains an uncommitted record");i.add(u)}}if(i.size!==c.size)return N("unassigned committed record");o=[...n].sort((f,u)=>v(f.place,u.place)).map(f=>x({scope:f.place,role:"writes",form:"alphabet",measure:"digest",value:t.digest(wr(f.records)),at:t.context,by:"target"})).join(`
42
+ `}s(eo,"actBytes");function Bi(e,t){if(!t.scope||!t.context)return oe("missing receipt contract");let r=eo(e),n=t.placements,o="";if(n!==void 0){let i=new Set,a=new Set,c=new Set(e);for(let l of n){if(!l.place||a.has(l.place)||l.place!=="."&&(l.place.startsWith("/")||l.place.split("/").some(f=>!f||f==="."||f==="..")))return oe("invalid receiving coordinate");a.add(l.place);for(let f of l.records){if(!c.has(f))return oe("placement contains an uncommitted record");i.add(f)}}if(i.size!==c.size)return oe("unassigned committed record");o=[...n].sort((l,f)=>w(l.place,f.place)).map(l=>v({scope:l.place,role:"writes",form:"alphabet",measure:"digest",value:t.digest(eo(l.records)),at:t.context,by:"target"})).join(`
33
43
  `)+`
34
- `}return t.localEpoch!==void 0&&(!Number.isSafeInteger(t.localEpoch)||t.localEpoch<0)?N("invalid commit epoch"):t.digest(x({scope:t.scope,at:t.context,...t.localEpoch===void 0?{}:{epoch:String(t.localEpoch)}})+`
35
- `+r+o)}s(cn,"actIdentity");function ci(e,t,r){let n=cn(e,r),o=an(t,!1),i=ai(o);if(o.scope!==r.scope||o.at!==r.context||o.role!=="writes"||o.form!=="alphabet"||o.measure!=="digest"||o.value!==n)return N("receipt does not bind this act");for(let a of e)if(r.admitsRecord(a,i)!==!0)return N("record not admitted");return r.verifiesReceipt(t)!==!0?N("receipt does not verify"):{identity:n,epoch:i,records:[...e],receipt:t}}s(ci,"actResultOf");function li(e){let t=s(i=>{let a=[...new Set(e.flatMap(c=>{let f=S(c);return f.kind==="fact"&&f.value.fields.scope===i&&f.value.fields.role==="writes"&&f.value.fields.value!=="withdraw"?[f.value.fields.value]:[]}))];return a.length>1?N("conflicting "+i):a[0]},"value"),r=t("wire/act-result");if(r===void 0)return;if(r!=="local-act@1")return N("unsupported result profile");let n=t("wire/act-result-scope"),o=t("wire/act-result-context");return!n||!o?N("incomplete result profile"):{scope:n,context:o}}s(li,"actResultProfile");var Fs="object";var fe=s((e,t,r=null)=>({kind:e,bits:null,premium:null,degenerate:null,why:t,distributive:r}),"unknown");function As(e,t){let r=s(a=>{let[c="",f=""]=a.split(".");return{numerator:BigInt(`${c}${f}`),scale:10n**BigInt(f.length)}},"rational"),n=r(e),o=r(t),i=n.numerator*o.scale-o.numerator*n.scale;return i<0n?-1:i>0n?1:0}s(As,"compareDecimal");function fi(e){let t=S(e);if(t.kind!=="fact")return fe("invalid",t.why);let{form:r,value:n,type:o}=t.value.fields;if(o!==void 0)return fe("unsupported","object freedom needs its selected valuation; a configuration estimate cannot measure it");if(r===void 0||n===void 0)return fe("invalid","a declaration must name its form and value");if(n==="withdraw")return fe("inactive","a withdrawal declares no current freedom");if(r==="alphabet"){let i;try{i=_(n)}catch(a){return fe("invalid",a instanceof Error?a.message:String(a))}return i.polarity==="forbid"?fe("complement","the complement names exclusions but declares no universe to count"):{kind:"finite",form:r,bits:new Set(i.members).size,premium:0,degenerate:!0,distributive:!0}}if(r==="interval"){let[i="",a=""]=n.split("..");return i==="*"||a==="*"?fe("unbounded","the interval has an open endpoint and declares no discrete state count",!1):As(i,a)>=0?{kind:"finite",form:r,bits:0,premium:0,degenerate:!0,distributive:!0}:fe("continuous","the interval declares no discrete step or state count",!1)}return fe("unsupported",`freedom is not defined here for form ${r}`)}s(fi,"declaredConfig");function st(e,t,r,n=[]){if(!t.length||new Set(t).size!==t.length||!t.includes("scope"))throw Error("REFUSE\xB7receipt missing or conflicting canonical field contract");let o=new Map;for(let a of e){let c=S(a);if(c.kind!=="fact")throw Error("REFUSE\xB7receipt the observed set holds an invalid record");let f=c.value.fields;if(n.includes(f.by??""))throw Error("REFUSE\xB7receipt excluded evidence is inside its own set");let u=x(Object.fromEntries(t.filter(l=>f[l]!==void 0).map(l=>[l,f[l]]))),d=(f.scope??"").split("/")[0]??"";(o.get(d)??o.set(d,new Set).get(d)).add(u)}let i=[...o].map(([a,c])=>({scope:`receipts/${a}`,count:c.size,digest:r([...c].sort(v).map(f=>f+`
36
- `).join(""))})).sort((a,c)=>v(a.scope,c.scope));return{root:r(i.map(a=>a.digest+`
37
- `).join("")),regions:i}}s(st,"receiptProjection");function di(e,t,r,n,o){if(n==="")throw new F("join-unwitnessed","obligations: REFUSE\xB7join a widening lands only with a witness or the signatures of whoever rests on the old bound");return{...t,marks:[...t.marks??[],he({pole:"ceiling",reach:"local",span:e.meet(e.top,r),widens:n,...o===void 0?{}:{at:o}})]}}s(di,"join");function Er(e,t,r=t.takes===void 0?1:-1){let n=r===1?void 0:t.takes??t.id;if(r===1&&t.takes!==void 0)throw new F("sign-mismatch","obligations: REFUSE\xB7observe a claim that takes another back is observed at \u22121, never at +1");if(r===-1&&n===void 0)throw new F("withdrawal-unnamed","obligations: REFUSE\xB7observe a withdrawal names the claim it takes back, never a value that looks like it");let o=n===void 0?t:{origin:t.origin,span:t.span,sign:-1,takes:n,...t.at===void 0?{}:{at:t.at}};return{...e,epoch:Math.max(e.epoch,t.at??e.epoch),seen:[...e.seen,o]}}s(Er,"observe");function ui(e,t){return{...e,at:t>=e.at.length?e.at:e.at.slice(0,Math.max(1,t))}}s(ui,"refine");function pi(e,t,r,n,o={}){let i=t.get(r)??G(r);return new Map([...t,[r,{...i,marks:[...i.marks??[],he({pole:"floor",reach:"travels",span:e.meet(e.top,n),...o})]}]])}s(pi,"require");function vr(e,t,r,n,o={}){let i=t.get(r)??G(r);return new Map([...t,[r,{...i,marks:[...i.marks??[],he({pole:"ceiling",reach:"travels",span:e.meet(e.top,n),...o})]}]])}s(vr,"sign");function mi(e){let t=new Map;for(let[r,n]of e)for(let o of n.restsOn)t.set(o,[...t.get(o)??[],r]);return t}s(mi,"restingOn");function hi(e,t,r,n,o){let i=s(d=>H(t.get(d)?.marks??[]).filter(l=>l.pole==="ceiling"&&l.reach==="travels"&&l.widens===void 0).reduce((l,p)=>e.meet(l,p.span),e.top),"own"),a=s(d=>ke(t.get(d)??G(d),t).reduce((l,p)=>e.meet(l,i(p)),i(d)),"above"),c=[],f=[[n,a(n)]],u=new Set([n]);for(let d=0;d<f.length;d+=1){let[l,p]=f[d];if(!e.leq(p,o)){c.push(l);for(let m of r.get(l)??[]){if(u.has(m))continue;u.add(m);let g=t.get(m);f.push([m,g!==void 0&&g.restsOn.length===1?e.meet(p,i(m)):a(m)])}}}return{cells:c,visits:f.length}}s(hi,"bites");function xr(e){let t=e.span.hi-e.span.lo,r=Number.isFinite(t)?1/(1+Math.max(t,0)):0;return e.withdraws?-r:r}s(xr,"amplitude");function Sr(e,t){return t<=0?0:(e.epoch%t+t)%t}s(Sr,"phase");function Le(e,t){if(!e.length)return 0;let r=0,n=0;for(let o of e){let i=2*Math.PI*Sr(o,t)/t;r+=Math.cos(i),n+=Math.sin(i)}return Math.sqrt(r*r+n*n)/e.length}s(Le,"coherence");function ln(e,t){let r=0,n=0;for(let o of e){let i=2*Math.PI*Sr(o,t)/t;r+=xr(o)*Math.cos(i),n+=xr(o)*Math.sin(i)}return Math.sqrt(r*r+n*n)**2}s(ln,"interfere");function gi(e,t,r){return r.map(n=>ln(e.map((o,i)=>i%2===0?o:{...o,epoch:o.epoch+n}),t))}s(gi,"fringes");var yi=s((e,t)=>e.seen.map(r=>({origin:r.origin,epoch:e.epoch,span:r.span})),"seenAs");function bi(e,t){return t===0?[[]]:e.flatMap((r,n)=>bi(e.slice(n+1),t-1).map(o=>[r,...o]))}s(bi,"takes");function wi(e,t,r=new Map){let n=Z(e,t,r),o=[...new Set(H(t.seen).map(i=>i.origin))];for(let i=1;i<=o.length;i+=1)for(let a of bi(o,i)){let c=Z(e,{...t,seen:t.seen.filter(f=>!a.includes(f.origin))},r);if(!ve(e,c.floor,n.floor)||!ve(e,c.ceiling,n.ceiling))return i}return 0}s(wi,"fragility");function Ei(e,t,r){return e(t)-e(r)}s(Ei,"price");function vi(e,t,r){return Z(e,t.get(r)??G(r),t).ceiling.hi}s(vi,"looksLeft");function xi(e,t,r){let n=Z(e,t.get(r)??G(r),t);if(n.ceiling.hi-1<n.floor.lo)throw new F("attention-spent",`obligations: REFUSE\xB7attention ${r} has no look left: an act nobody pays for is not taken`);return vr(e,t,r,{lo:e.top.lo,hi:n.ceiling.hi-1})}s(xi,"pay");function Si(e,t,r){let n=C(e,t),o=C(e,{...t,seen:[...t.seen,r]}),i=s(a=>Math.max(0,a.hi-a.lo),"width");return i(n)-i(o)}s(Si,"disturbance");function ki(e,t){if(t<=0)throw new Error("obligations: REFUSE\xB7budget a region read at no resolution has no budget to take");return Math.ceil(2*e/t)}s(ki,"budget");function Oi(e,t,r,n){let o=s(i=>{let a=C(e,i);return n<=0?a.lo:Math.round(a.lo/n)},"bin");return o(t)===o(r)}s(Oi,"sameObject");function Ri(e,t,r){let n=new Set;for(let o of t){let i=C(e,o);n.add(r<=0?i.lo:Math.round(i.lo/r))}return n.size}s(Ri,"distinct");function _i(e,t,r,n){let o=n,i=s(()=>(o=(o*1103515245+12345)%2147483648,o/2147483648),"next"),a=[],c=e;for(let f=1;f<=t;f+=1){for(let u=0;u<r;u+=1){let d=c.map(y=>1+20*y.seen.length),l=d.reduce((y,b)=>y+b,0),p=s(()=>{let y=i()*l,b=0;for(;y>d[b]&&b<c.length-1;)y-=d[b],b+=1;return b},"where"),m=p(),g=p();g===m&&(g=(g+1)%c.length);let h=`e${f}-${u}`;c=c.map((y,b)=>b===m||b===g?{...y,epoch:f,seen:[...y.seen,{id:`${h}-${b}`,origin:h,at:f,span:{lo:0,hi:100}}]}:y)}a.push(c)}return a}s(_i,"evolve");function $i(e,t,r){let n=e.map((i,a)=>({...i,epoch:i.at??0,origin:i.origin||`o${a}`})),o=Array.from({length:t},(i,a)=>({origin:`n${a}`,span:{lo:0,hi:1},epoch:a%Math.max(1,r),at:a%Math.max(1,r)}));return Le([...n,...o].map(i=>({origin:i.origin,epoch:i.epoch,span:i.span})),r)}s($i,"decohere");var Fi=s(e=>e.at.join("/"),"at"),Is=s((e,t)=>[...new Set(e.seen.map(r=>r.origin))].filter(r=>!t.includes(r)),"spoke");function fn(e,t=[]){let r=new Map;for(let o of e)for(let i of Is(o,t))r.set(i,[...r.get(i)??[],Fi(o)]);let n=new Map;for(let o of r.values())for(let i of o){let a=n.get(i)??new Set;for(let c of o)c!==i&&a.add(c);n.set(i,a)}return new Map([...n].map(([o,i])=>[o,[...i]]))}s(fn,"neighbours");function js(e,t,r=[]){let n=fn(e,r),o=new Set([t]),i=[t];for(;i.length;){let a=i.pop();for(let c of n.get(a)??[])o.has(c)||(o.add(c),i.push(c))}return e.map(Fi).filter(a=>!o.has(a))}s(js,"horizon");function Ai(e,t,r=[]){return e.length-js(e,t,r).length-1}s(Ai,"reach");var ji=s(e=>e.at.join("/"),"at"),Ii=s((e,t)=>{let r=C(e,t);return Ze(e,t).origins<2?"one":r.lo>r.hi?"apart":"together"},"said"),Ms=s((e,t)=>{let r=C(e,t);return Math.max(0,r.hi-r.lo)},"widthOf");function dn(e,t,r,n){let o="",i;for(let a of t){let c=ji(a);if(n.has(c))continue;let f=a.seen.map((d,l)=>({origin:d.origin,epoch:d.at??l,span:d.span})),u=r.reach*Ai(t,c)+r.coherence*Le(f,8)+r.rank*(fn(t).get(c)??[]).length+r.bits*Math.log2(1+Ms(e,a));(i===void 0||u>i)&&(i=u,o=c)}return o}s(dn,"choose");function Mi(e,t,r,n,o,i){let a=o,c=s(()=>(a=(a*1103515245+12345)%2147483648,a/2147483648),"next"),f=[...t],u=new Set,d=new Set,l=0;for(let m=1;m<=n;m+=1){let g=dn(e,f,r,new Set);if(!g)break;f=f.map(h=>{if(ji(h)!==g)return h;let y=Ii(e,h),b=C(e,h),O=(b.lo+b.hi)/2+(c()*2-1)*i,W={id:`p${m}`,origin:`p${m}`,at:m,span:{lo:O-5,hi:O+5}},B={...h,epoch:m,seen:[...h.seen,W]},ye=Ii(e,B);return ye==="together"&&y!=="together"&&u.add(g),ye==="apart"&&(d.add(g),u.has(g)&&(l+=1,u.delete(g))),B})}let p=f.filter(m=>Ze(e,m).origins>1).length;return{closed:u.size,forks:d.size,reopened:l,coverage:Math.round(100*p/f.length)}}s(Mi,"play");function Ui(e,t,r,n,o,i){let a=i,c=s(()=>(a=(a*1103515245+12345)%2147483648,a/2147483648),"next"),f=[],u=t;for(let d=1;d<=r;d+=1){let l=C(e,u),p=(l.lo+l.hi)/2+(c()*2-1)*o;u=Er(u,{origin:`self${d}`,at:d,span:{lo:p-n/2,hi:p+n/2}}),f.push(u)}return f}s(Ui,"selfFold");function Us(e,t="semantic-live@1"){if(!["semantic-live@1","semantic-live@2"].includes(t))throw Error("REFUSE\xB7receipt undeclared semantic input profile");let r=e.filter(a=>a.record==="cell"),n=new Map(r.map(a=>[a.fields.scope,G(a.fields.scope,Number(a.fields.epoch),[],Oe(a.fields.restsOn))])),o=s(a=>{let c={...a.fields};for(let f of["sig","by","epoch","expires","repo","shape"])delete c[f];return x(c)},"encode"),i=s((a,c)=>{let f=e.filter(l=>l.record===c&&l.fields.scope===a),u=new Map(f.map(l=>[l.fields.id,l])),d=H(f.map(l=>({id:l.fields.id,at:Number(l.fields.epoch),...l.fields.takes?{takes:l.fields.takes}:{}}))).map(l=>u.get(l.id));return t==="semantic-live@2"?d.sort((l,p)=>Number(l.fields.epoch)-Number(p.fields.epoch)):d},"acts");return new Map(r.map(a=>{let c=a.fields.scope,f=ke(n.get(c),n),u=f.map(g=>r.find(h=>h.fields.scope===g)),d=f.flatMap(g=>i(g,"mark").filter(h=>h.fields.reach==="travels"&&!h.fields.widens)),l=[...i(c,"mark"),...i(c,"claim")],p=[a,...u,...d,...l].map(o),m=[...new Set(p)];return[c,t==="semantic-live@1"?m.sort(v):m]}))}s(Us,"cellInputs");function Ns(e){if(Ni(e),e.filter(r=>r.scope==="valuation/cells").some(r=>r.value!=="unquantified"))throw Error("REFUSE\xB7valuation cells have an unsupported valuation; no discrete quantum is invented");return{valuation:"unknown"}}s(Ns,"cellReceiptContract");function Ni(e){let t=e.filter(r=>r.scope==="wire/receipt-inputs");if(t.length!==1||!["semantic-live@1","semantic-live@2"].includes(t[0].value))throw Error("REFUSE\xB7receipt wire/receipt-inputs has no admitted semantic input contract");return t[0].value}s(Ni,"cellInputProfile");var Cs=s(e=>e.map(t=>"CELL "+JSON.stringify(t)),"renderCells");var w=s(e=>{throw Error("REFUSE\xB7walk "+e)},"refuse"),J=s(e=>{let t=S(e);return t.kind!=="fact"?w("invalid canonical record"):t.value},"record");function Bs(e){let t=e.filter(r=>r.scope==="walk/origin"&&r.role==="writes"&&r.form==="alphabet"&&r.measure==="id"&&r.value!=="withdraw");return t.length!==1||!t[0].value?w("missing or conflicting declared ledger origin"):t[0].value}s(Bs,"walkOrigin");function Ts(e,t){let r=Be(e,Number.MAX_SAFE_INTEGER);if(!r||!r.signatures.size)return w("origin context has no signature contract");let n=[...r.signatures],i=[...new Set(e.filter(c=>c.scope?.startsWith("keys/")&&c.measure==="public-key").map(c=>c.scope.slice(5)))].map(c=>{let f=s(m=>{let g=e.filter(h=>h.scope==="keys/"+c&&h.measure===m&&h.value!=="withdraw");return g.length!==1?w("origin key "+c+" has missing or conflicting "+m):g[0].value},"said"),u=f("class"),d=f("coverage").split("|"),l=f("public-key");(!u||!l||d.some(m=>!m))&&w("incomplete origin key "+c);let p=ae(x({scope:"keys/"+c,role:"writes",form:"interval",measure:"resolution",value:f("resolution"),by:"target",at:"policy:walk"}),null);return p.kind!=="fact"||p.value.bound.kind!=="interval"||p.value.bound.lo===null||p.value.bound.hi===null?w("origin key "+c+" has no bounded resolution"):{id:c,keyClass:u==="authorize"?"authorize":"attest",publicKey:l,coverage:d,depth:{lo:p.value.bound.lo,hi:p.value.bound.hi},admittedBy:[]}});i.length||w("origin context has no keys");let a=s(c=>{let f=J(c);return or(f.fields,i,(u,d)=>t(u,d,n))},"of");return{of:a,authenticate:s(c=>c.every(f=>a(f).kind==="admitted"),"authenticate"),wire:r}}s(Ts,"walkAuthority");function un(e,t,r,n,o){let i=[...new Set(e.map(f=>{let u=J(f);x(u.fields,u.version)!==f&&w("noncanonical record"),u.fields.sig||w("unsigned evidence");for(let d of Object.keys(u.fields))d!=="sig"&&!t.includes(d)&&w("identity omits "+d);return f}))].sort(v);if(o){if(!n)return w("coordinate partition requires a declared origin");let f=new Map;for(let d of i){let l=J(d).fields;if(!l.scope)return w("coordinate record has no scope");let p="receipts/"+encodeURIComponent(n)+"/"+l.scope.split("/").map(encodeURIComponent).join("/"),m=f.get(p)??{claims:new Set,records:[]};m.claims.add(x(Object.fromEntries(t.filter(g=>l[g]!==void 0).map(g=>[g,l[g]])))),m.records.push(d),f.set(p,m)}let u=[...f].map(([d,l])=>({scope:d,count:l.claims.size,digest:r([...l.claims].sort(v).map(p=>p+`
38
- `).join("")),records:l.records})).sort((d,l)=>v(d.scope,l.scope));return{...kr([u],r,o),regions:u}}let a=st(i,t,r),c=a.regions.map(f=>({...f,records:i.filter(u=>J(u).fields.scope.split("/")[0]===f.scope.slice(9)),scope:n?"receipts/"+encodeURIComponent(n)+"/"+f.scope.slice(9):f.scope}));return{root:n?kr([c],r).root:a.root,regions:c}}s(un,"walkSnapshot");function kr(e,t,r){let n=new Map;for(let f of e)for(let u of f){if(!Number.isSafeInteger(u.count)||u.count<0)return w("invalid inventory count "+u.scope);let d=n.get(u.scope);d&&(d.digest!==u.digest||d.count!==u.count)&&w("ambiguous inventory region "+u.scope),d||n.set(u.scope,u)}let o=[...n.values()].sort((f,u)=>v(f.scope,u.scope)),i=o.flatMap(f=>[x({scope:f.scope,role:"writes",form:"alphabet",measure:"digest",value:f.digest,by:"target",at:"receipt:walk"}),x({scope:f.scope,role:"writes",form:"interval",measure:"count",value:`${f.count}..${f.count}`,by:"target",at:"receipt:walk"})]),a=st(i,["scope","role","form","measure","value"],t).root;if(!r)return{root:a,regions:o.map(f=>({...f,records:[]}))};if(r.kind!=="scope-coordinates@1"||new Set(r.depths).size!==r.depths.length||r.depths.some(f=>!Number.isSafeInteger(f)||f<1))return w("invalid declared coordinate partition");let c=r.depths.map(f=>{let u=new Map;for(let d of o){let l=d.scope.split("/");if(l.length<3||l[0]!=="receipts")return w("coordinate region has no origin namespace");let p=l.slice(0,2+f).join("/"),m=u.get(p)??[];m.push(d),u.set(p,m)}return{depth:f,regions:[...u].map(([d,l])=>{if(l.length===1&&l[0].scope===d)return l[0];let p=l.reduce((m,g)=>m+g.count,0);return Number.isSafeInteger(p)?{scope:d,count:p,digest:kr([l],t).root}:w("coordinate group count is outside the exact range")}).sort((d,l)=>v(d.scope,l.scope))}});return{root:a,regions:o.map(f=>({...f,records:[]})),refinements:c}}s(kr,"walkInventory");function Ci(e,t){if(t!==void 0&&(!Number.isSafeInteger(t)||t<0))return w("invalid resolution");let r=e.filter(n=>t===void 0?n.projection==="inventory":n.resolution===t);return r.length!==1?w("undeclared or ambiguous resolution"):["inventory","summary","history"].includes(r[0].projection)?r[0].projection:w("unsupported declared projection")}s(Ci,"walkProjection");function Ps(e,t,r,n,o){let i=Ci(n,r),a=new Map;for(let m of t.regions)a.has(m.scope)&&w("ambiguous peer region "+m.scope),a.set(m.scope,m.digest);let c=n.filter(m=>r===void 0?m.projection==="inventory":m.resolution===r)[0],f=e.regions;if(c.depth!==void 0&&!e.refinements)return w("declared refinement requires a matching snapshot partition");if(e.refinements){if(c.depth===void 0)return w("refined snapshot has no declared resolution partition");if(i==="history"&&c.depth!=="all")return w("history requires complete coordinate regions");if(c.depth!=="all"){let m=e.refinements.find(g=>g.depth===c.depth);if(!m)return w("undeclared coordinate refinement");f=m.regions}}let u=s(m=>{if(a.get(m.scope)===m.digest||e.refinements?.some(y=>y.regions.some(b=>(m.scope===b.scope||m.scope.startsWith(b.scope+"/"))&&a.get(b.scope)===b.digest)))return!0;if(!e.refinements||e.regions.some(y=>y.scope===m.scope))return!1;let g=e.regions.filter(y=>y.scope.startsWith(m.scope+"/")),h=[...a.keys()].filter(y=>y.startsWith(m.scope+"/"));return g.length>0&&h.length===g.length&&g.every(y=>a.get(y.scope)===y.digest)},"covered"),d=f.filter(m=>!u(m)),l=o??d.map(m=>m.scope);new Set(l).size!==l.length&&w("duplicate requested region");for(let m of l)d.some(g=>g.scope===m)||w("region is not an open requested difference "+m);let p=d.filter(m=>l.includes(m.scope));return{root:e.root,regions:(i==="inventory"?f:p).map(m=>({scope:m.scope,digest:m.digest,count:m.count})),records:i==="history"?[...new Set(p.flatMap(m=>e.regions.find(g=>g.scope===m.scope)?.records??[]))].sort(v):[],touched:i==="history"?p.length:0,open:d.length}}s(Ps,"walkAt");function pn(e,t,r,n,o,i,a){let c=un(e,r,n,i,a);new Set(t.map(f=>f.scope)).size!==t.length&&w("ambiguous expected region"),c.regions.length!==t.length&&w("partial or extra payload");for(let f of t){let u=c.regions.find(d=>d.scope===f.scope);(!u||u.digest!==f.digest||u.count!==f.count)&&w("region digest or count mismatch "+f.scope)}return o(e)!==!0&&w("receiver does not admit evidence"),[...new Set(e)].sort(v)}s(pn,"walkPayload");var Or="walk/root",Rr="walk/regions/";function Ke(e){let t=J(e).fields;return!t.type&&(t.scope===Or||!!t.scope?.startsWith(Rr))}s(Ke,"isWalkHeader");function qs(e,t,r,n){let o=s((i,a,c,f,u)=>x({scope:i,form:a,measure:c,value:f,condition:u,role:"writes",at:"receipt:"+t,by:"target"}),"row");return[o(Or,"alphabet","digest",e.root,r),...e.regions.flatMap(i=>[o(Rr+i.scope,"alphabet","digest",i.digest,e.root),...n?[o(Rr+i.scope,"interval","count",`${i.count}..${i.count}`,e.root)]:[]])].sort(v)}s(qs,"walkHeaders");function mn(e,t,r,n){(!e.length||n(e)!==!0)&&w("metadata is not authenticated");let o=["scope","role","form","measure","value","condition","by","at","epoch","sig"],i=e.map(u=>{let d=J(u),l=d.fields;return(d.version!==M.split("/").at(-1)||!Ke(u))&&w("unknown metadata record"),(Object.keys(l).some(p=>!o.includes(p))||o.some(p=>l[p]===void 0))&&w("missing or extra metadata field"),(x(l)!==u||l.role!=="writes"||l.at!=="receipt:"+t)&&w("metadata context or canonical bytes differ"),l}),a=i.filter(u=>u.scope===Or);a.length!==1&&w("missing or ambiguous root");let c=a[0];(c.form!=="alphabet"||c.measure!=="digest"||c.condition!==r)&&w("stale base or wrong root grammar"),i.some(u=>u.by!==c.by||u.epoch!==c.epoch)&&w("metadata mixes signers or epochs");let f=new Map;for(let u of i.filter(d=>d.scope!==Or)){let d=u.scope.slice(Rr.length);(!d||u.condition!==c.value)&&w("region does not rest on the authenticated root");let l=f.get(d)??{scope:d};if(u.form==="alphabet"&&u.measure==="digest")l.digest!==void 0&&w("ambiguous region digest"),l.digest=u.value;else if(u.form==="interval"&&u.measure==="count"){let p=ae(x(u),null);if(p.kind!=="fact"||p.value.bound.kind!=="interval")return w("count has no declared interval encoding");let{lo:m,hi:g}=p.value.bound;if(m===null||l.count!==void 0||m!==g||!Number.isSafeInteger(m)||m<0)return w("count is ambiguous or not discrete");l.count=m}else w("unknown region grammar");f.set(d,l)}return[...f.values()].some(u=>u.digest===void 0)&&w("region digest absent"),{root:c.value,context:t,base:r,signer:c.by,regions:[...f.values()].map(u=>({...u,digest:u.digest})).sort((u,d)=>v(u.scope,d.scope))}}s(mn,"readWalkHeaders");function Ws(e,t){let r=e.filter(Ke),n=e.filter(c=>!Ke(c)),o=mn(r,t.context,t.base,t.authenticateMetadata);o.regions.some(c=>c.count===void 0)&&w("payload was offered without its summary");let i=o.regions.map(c=>({...c,count:c.count})),a=pn(n,i,t.fields,t.digest,c=>t.admitBatch([...r,...c])===!0);return{metadata:o,records:a,headers:r}}s(Ws,"readWalkPayload");function Ds(e,t){t.origin||w("foreign origin identity absent"),t.regionOrigin!==void 0&&t.regionOrigin!==t.origin&&w("region origin differs from authenticated origin");let r=e.filter(Ke),n=e.filter(p=>!Ke(p)),o=mn(r,t.context,t.base,t.authenticatePrefix),i=J(r[0]).fields.epoch;/^(0|[1-9][0-9]*)$/.test(i)||w("invalid sender prefix epoch");let a=Number(i);Number.isSafeInteger(a)||w("invalid sender prefix epoch");for(let p of n){let m=J(p).fields.epoch;(m===void 0||!/^(0|[1-9][0-9]*)$/.test(m)||!Number.isSafeInteger(Number(m))||Number(m)>a)&&w("foreign epoch is outside the authenticated prefix")}o.regions.some(p=>p.count===void 0)&&w("prefix was offered without its summary");let c=o.regions.map(p=>({...p,count:p.count})),f=pn(n,c,t.fields,t.digest,p=>t.authenticateEvidence(p)===!0&&t.validateOriginHistory(p)===!0,t.regionOrigin,t.partition),u=un(f,t.fields,t.digest,t.regionOrigin,t.partition);for(let p of u.regions){let m=t.previousPrefixes.filter(b=>b.scope===p.scope);m.length>1&&w("ambiguous previous origin prefix");let g=m[0];if(!g)continue;a<g.senderEpoch&&w("sender cut precedes the verified origin prefix");let h=new Set(g.records.map(b=>x(Object.fromEntries(Object.entries(J(b).fields).filter(([O])=>O!=="sig"))))),y=new Set(p.records.map(b=>x(Object.fromEntries(Object.entries(J(b).fields).filter(([O])=>O!=="sig")))));[...h].some(b=>!y.has(b))&&w("foreign history is not an extension of its verified prefix");for(let b of p.records){let O=J(b),W=x(Object.fromEntries(Object.entries(O.fields).filter(([B])=>B!=="sig")));Number(O.fields.epoch)<=g.senderEpoch&&!h.has(W)&&w("foreign epoch does not match the verified prefix")}}let d=[x({scope:"receipts/import",role:"writes",form:"alphabet",measure:"digest",value:o.root,condition:t.origin,at:"receipt:"+t.context,by:"target"}),...c.flatMap(p=>[x({scope:p.scope,role:"writes",form:"alphabet",measure:"digest",value:p.digest,at:"receipt:"+t.context,by:"target"}),x({scope:p.scope,role:"writes",form:"interval",measure:"count",value:`${p.count}..${p.count}`,at:"receipt:"+t.context,by:"target"})])],l=st(d,["scope","role","form","measure","value","condition","at"],t.digest).root;return{origin:t.origin,senderEpoch:a,records:f,headers:r,identity:l,importReceiptProposal:x({scope:"receipts",role:"writes",form:"alphabet",measure:"digest",value:l,at:"receipt:"+t.context,by:"target"})}}s(Ds,"readForeignWalk");function zs(e){let t=s(g=>{let h=e.map(J).map(y=>y.fields).filter(y=>y.scope===g&&y.value!=="withdraw");return h.length!==1||h[0].form!=="alphabet"||h[0].measure!=="id"||h[0].role!=="writes"?w("missing or conflicting declaration "+g):h[0].value},"at");t("wire/walk/contract")!=="whole-region@1"&&w("unsupported declared exchange contract");let r=t("wire/walk/fields").split("|"),n=t("wire/walk/metadata-fields").split("|"),o=t("wire/walk/resolutions").split("|");o.some(g=>!/^(0|[1-9][0-9]*)$/.test(g)||!Number.isSafeInteger(Number(g)))&&w("invalid declared resolutions");let i=o.map(Number);(new Set(r).size!==r.length||["scope","by","epoch"].some(g=>!r.includes(g))||r.some(g=>!g||g==="sig"))&&w("incomplete history identity field contract");let a=["scope","role","form","measure","value","condition","by","at","epoch","sig"];(n.length!==a.length||new Set(n).size!==n.length||a.some(g=>!n.includes(g)))&&w("unsupported metadata field contract"),(!i.length||new Set(i).size!==i.length)&&w("missing or conflicting declared resolutions");let c=t("wire/walk/projections").split("|").map(g=>{let h=g.split(":");if(h.length!==2||!/^(0|[1-9][0-9]*)$/.test(h[0]))return w("invalid declared projection");let y=Number(h[0]),b=h[1];return!Number.isSafeInteger(y)||!["inventory","summary","history"].includes(b)?w("unsupported declared projection"):{resolution:y,projection:b}});(c.length!==i.length||new Set(c.map(g=>g.resolution)).size!==c.length||c.some(g=>!i.includes(g.resolution)))&&w("projection does not match declared resolutions");let f=s(g=>e.map(J).map(y=>y.fields).filter(y=>y.scope===g&&y.value!=="withdraw").length?t(g):void 0,"optional"),u=f("wire/walk/partition"),d=f("wire/walk/refinements");if(u===void 0&&d===void 0)return{contract:"whole-region@1",fields:r,metadataFields:n,resolutions:i,projections:c};if(u!=="scope-coordinates@1"||d===void 0)return w("missing or unsupported coordinate partition contract");let l=d.split("|").map(g=>{let h=g.split(":");if(h.length!==2||!/^(0|[1-9][0-9]*)$/.test(h[0])||h[1]!=="all"&&!/^[1-9][0-9]*$/.test(h[1]))return w("invalid declared coordinate refinement");let y=Number(h[0]),b=h[1]==="all"?"all":Number(h[1]);return!Number.isSafeInteger(y)||b!=="all"&&!Number.isSafeInteger(b)?w("invalid declared coordinate refinement"):{resolution:y,depth:b}});if(l.length!==c.length||new Set(l.map(g=>g.resolution)).size!==l.length||l.some(g=>!i.includes(g.resolution)))return w("refinement does not match declared resolutions");let p=c.map(g=>({...g,depth:l.find(h=>h.resolution===g.resolution).depth}));if(p.some(g=>g.projection==="history"&&g.depth!=="all"))return w("history requires complete coordinate regions");let m={kind:u,depths:[...new Set(l.flatMap(g=>g.depth==="all"?[]:[g.depth]))]};return{contract:"whole-region@1",fields:r,metadataFields:n,resolutions:i,projections:p,partition:m}}s(zs,"walkSelection");export{gn as library0_compareEvidence,hn as library0_keyClassFor,yn as library0_verdictDemand,Ke as library10_isWalkHeader,Ds as library10_readForeignWalk,mn as library10_readWalkHeaders,Ws as library10_readWalkPayload,Ps as library10_walkAt,Ts as library10_walkAuthority,qs as library10_walkHeaders,kr as library10_walkInventory,Bs as library10_walkOrigin,pn as library10_walkPayload,Ci as library10_walkProjection,zs as library10_walkSelection,un as library10_walkSnapshot,Lo as library11_CAPSULE,Ce as library11_ENVELOPE,it as library11_EXTENSION,zo as library11_LOCK,Fs as library11_OBJECT_VIEW,le as library11_PLACE_ACT_CONTEXT,M as library11_PROTOCOL,Ko as library11_RECEIPTS,wr as library11_actBytes,cn as library11_actIdentity,ci as library11_actResultOf,li as library11_actResultProfile,_ as library11_alphabet,oi as library11_assertReaderInputs,Ae as library11_atResolution,Te as library11_authorityAtEpoch,or as library11_authorityOf,v as library11_byBytes,x as library11_canonical,Ho as library11_combine,si as library11_contentRequest,lt as library11_decimal,Fe as library11_fields,Qt as library11_formatSignature,ae as library11_fromLine,Eo as library11_isKeyClaim,wo as library11_isWireClaim,T as library11_matches,Oo as library11_namesAt,Vo as library11_objectHistory,rt as library11_originContextBytes,S as library11_parse,Rn as library11_parseForSigning,ee as library11_parseSignature,Re as library11_placeActContextBytes,lr as library11_placeActReceiptsOf,nt as library11_placeReceiptBytes,Xo as library11_publicLock,Go as library11_publicationOf,De as library11_readPlaceActContext,ni as library11_readerAllowsEmpty,ri as library11_readerLifetime,br as library11_recordKind,pt as library11_requirement,Oe as library11_restCoordinates,Ro as library11_roleAt,ko as library11_roleClaimsOf,z as library11_signedBytes,Yt as library11_signedFieldsOf,Yo as library11_signerRequestBytes,Zo as library11_signerResponseBytes,ei as library11_signerResponseOf,ti as library11_signerSelection,So as library11_signersOf,be as library11_steps,ii as library11_transportSelection,Jo as library11_validateObjectContext,fr as library11_verifyOriginalAtAuthorityContext,ze as library11_verifyPlaceActContext,Lt as library11_weakest,nr as library11_windowAt,Be as library11_wireAt,is as library12_answers,Gn as library12_coarsen,Lr as library12_contracts,Se as library12_coordinate,Kr as library12_covers,zr as library12_exclusive,os as library12_foldRegion,Me as library12_key,Hr as library12_outranks,je as library12_passes,Vt as library12_point,V as library12_region,me as library12_resolution,as as library12_retracted,cs as library12_size,ls as library12_sufficientResolution,ss as library12_verified,K as library12_within,Jn as library13_FORMS,Wr as library13_FORM_IMPLEMENTATIONS,oe as library13_alphabetForm,Kt as library13_alphabets,A as library13_continuousForm,U as library13_intervals,xe as library13_ladderForm,Y as library13_latticeForm,xr as library14_amplitude,hi as library14_bites,ki as library14_budget,Gr as library14_cancels,G as library14_cell,dn as library14_choose,Le as library14_coherence,Lr as library14_contracts,oo as library14_converge,Se as library14_coordinate,Kr as library14_covers,$i as library14_decohere,Vr as library14_disagree,Ri as library14_distinct,Si as library14_disturbance,Ze as library14_encounter,io as library14_endsBeforeNow,_i as library14_evolve,zr as library14_exclusive,Dr as library14_foldIn,wi as library14_fragility,gi as library14_fringes,ln as library14_interfere,di as library14_join,Me as library14_key,ro as library14_laminar,Zn as library14_latest,H as library14_live,vi as library14_looksLeft,he as library14_mark,C as library14_meet,Gt as library14_meetAt,Er as library14_observe,Jr as library14_origins,to as library14_pairs,Z as library14_parts,je as library14_passes,xi as library14_pay,Sr as library14_phase,Mi as library14_play,Vt as library14_point,Ye as library14_potential,no as library14_present,Ei as library14_price,ui as library14_refine,V as library14_region,pi as library14_require,me as library14_resolution,ke as library14_restOf,mi as library14_restingOn,Oi as library14_sameObject,yi as library14_seenAs,Ui as library14_selfFold,vr as library14_sign,Xn as library14_state,eo as library14_turned,K as library14_within,Jt as library14_witnessesIn,Yi as library1_counted,Ur as library1_declarationOf,Ir as library1_found,Je as library1_handed,qi as library1_lang,Pi as library1_listed,mt as library1_of,Di as library1_placeOf,Qi as library1_readers,Vi as library1_readsOf,Zi as library1_receiptShell,Wi as library1_receipts,zi as library1_regionLines,Gi as library1_shell,jr as library1_value,Ao as library2_answer,Nt as library2_checkCommandPort,Xe as library2_commandRequest,Ct as library2_commandResponse,Bt as library2_composePolicy,It as library2_foldedEvidence,Dt as library2_inspectionSelection,ws as library2_listen,Es as library2_observed,Ut as library2_originRegion,wt as library2_placeInputs,St as library2_placeRequirements,Tt as library2_policyTransition,Zr as library2_programInputs,zt as library2_programsOf,Fo as library2_publicationCoverage,xt as library2_readReleaseDelivery,yt as library2_readingIdentity,Ee as library2_readingIdentityBytes,Ge as library2_readingReceiptBytes,bt as library2_readingReceiptIdentity,Pt as library2_releaseSuccessors,$o as library2_renderPrograms,At as library2_renderWriter,vs as library2_respond,jt as library2_responseIdentity,xs as library2_responsesOf,Mt as library2_snapshotAccess,Ie as library2_snapshotIdentity,Ft as library2_unionReadings,Wt as library2_vacuityOf,qt as library2_weightOf,Et as library2_withPlaceInputs,le as library3_PLACE_ACT_CONTEXT,_ as library3_alphabet,Ae as library3_atResolution,v as library3_byBytes,x as library3_canonical,Nt as library3_checkCommandPort,Xe as library3_commandRequest,Ct as library3_commandResponse,Bt as library3_composePolicy,Fe as library3_fields,It as library3_foldedEvidence,Qt as library3_formatSignature,Dt as library3_inspectionSelection,rt as library3_originContextBytes,Ut as library3_originRegion,S as library3_parse,ee as library3_parseSignature,Re as library3_placeActContextBytes,lr as library3_placeActReceiptsOf,wt as library3_placeInputs,nt as library3_placeReceiptBytes,St as library3_placeRequirements,Tt as library3_policyTransition,De as library3_readPlaceActContext,xt as library3_readReleaseDelivery,gt as library3_readSemanticStanding,yt as library3_readingIdentity,Ee as library3_readingIdentityBytes,Ge as library3_readingReceiptBytes,bt as library3_readingReceiptIdentity,Pt as library3_releaseSuccessors,At as library3_renderWriter,pt as library3_requirement,jt as library3_responseIdentity,ne as library3_semanticStandingBytes,Rt as library3_shadowAt,Ot as library3_shadowProfile,z as library3_signedBytes,Yt as library3_signedFieldsOf,Mt as library3_snapshotAccess,Ie as library3_snapshotIdentity,be as library3_steps,Ft as library3_unionReadings,Wt as library3_vacuityOf,fr as library3_verifyOriginalAtAuthorityContext,ze as library3_verifyPlaceActContext,qt as library3_weightOf,Et as library3_withPlaceInputs,qo as library4_ALPHABETS,on as library4_INTERVALS,Io as library4_alphabetOfForm,jo as library4_budgetForm,Do as library4_configurationValues,fi as library4_declaredConfig,Mo as library4_distributionForm,Wo as library4_idsOf,Uo as library4_intervalForm,No as library4_ladderOfForm,Co as library4_latticeOfForm,Bo as library4_phaseForm,To as library4_rankForm,sn as library4_spanOf,Po as library4_stretchForm,_o as library4_violationsIn,st as library6_receiptProjection,jn as library7_assertCapsuleDescriptor,In as library7_capsuleDescriptor,ts as library7_capsuleOffers,_t as library7_providerFields,Un as library7_providerInputRegions,Nn as library7_providerInputs,gt as library7_readSemanticStanding,Mn as library7_readStanding,ne as library7_semanticStandingBytes,Rt as library7_shadowAt,Ot as library7_shadowProfile,pe as library7_standingBytes,es as library7_toposStanding,Ni as library8_cellInputProfile,Us as library8_cellInputs,Ns as library8_cellReceiptContract,Cs as library9_renderCells};
44
+ `}return t.localEpoch!==void 0&&(!Number.isSafeInteger(t.localEpoch)||t.localEpoch<0)?oe("invalid commit epoch"):t.digest(v({scope:t.scope,at:t.context,...t.localEpoch===void 0?{}:{epoch:String(t.localEpoch)}})+`
45
+ `+r+o)}s(Bi,"actIdentity");function to(e,t,r){let n=Bi(e,r),o=Ui(t,!1),i=Oc(o);if(o.scope!==r.scope||o.at!==r.context||o.role!=="writes"||o.form!=="alphabet"||o.measure!=="digest"||o.value!==n)return oe("receipt does not bind this act");for(let a of e)if(r.admitsRecord(a,i)!==!0)return oe("record not admitted");return r.verifiesReceipt(t)!==!0?oe("receipt does not verify"):{identity:n,epoch:i,records:[...e],receipt:t}}s(to,"actResultOf");function _c(e){let t=s(i=>{let a=[...new Set(e.flatMap(c=>{let l=x(c);return l.kind==="fact"&&l.value.fields.scope===i&&l.value.fields.role==="writes"&&l.value.fields.value!=="withdraw"?[l.value.fields.value]:[]}))];return a.length>1?oe("conflicting "+i):a[0]},"value"),r=t("wire/act-result");if(r===void 0)return;if(r!=="local-act@1")return oe("unsupported result profile");let n=t("wire/act-result-scope"),o=t("wire/act-result-context");return!n||!o?oe("incomplete result profile"):{scope:n,context:o}}s(_c,"actResultProfile");var ro="topos-action-receipt/1",no="topos-authenticated-link/1",Od=["verb","request","result","key","place","region","before","policy","catalog","standingContract"];function Ti(e){let t=I(e,Od);for(let r of["verb","key"])A(t[r]);for(let r of["place","region"])V(t[r]);for(let r of["request","result","before","policy","catalog","standingContract"])O(t[r]);return{...t}}s(Ti,"statement");function hr(e,t){return H("topos-action-statement/1",Ti(e),t)}s(hr,"actionStatementBytes");function Ic(e){let t=I(e,["statement","act","evidence"]);return O(t.act),O(t.evidence),{statement:Ti(t.statement),act:t.act,evidence:t.evidence}}s(Ic,"packet");function pt(e,t){let r=Ic(e);return H(ro,{statement:hr(r.statement,t),act:r.act,evidence:r.evidence},t)}s(pt,"encodeActionReceipt");function Bt(e,t){let r=Y(ro,e,t);I(r,["statement","act","evidence"]);let n=Ti(Y("topos-action-statement/1",r.statement,t)),o=Ic({statement:n,act:r.act,evidence:r.evidence});return Z(pt(o,t),e),o}s(Bt,"decodeActionReceipt");function Ac(e,t){return{status:"declared",receipt:Bt(pt(e,t),t),authentication:"not verified",effects:"not performed"}}s(Ac,"inspectActionReceipt");function Li(e,t,r,n,o){if(D(t,o,f=>typeof f!="string"?E("action/records"):f),typeof r!="string"||t.reduce((f,u)=>f+u.length,r.length)>o.bytes||t.reduce((f,u)=>f+new TextEncoder().encode(u).length,new TextEncoder().encode(r).length)>o.bytes)return E("action/bytes");if(!n||!n.native||typeof n.native.digest!="function"||typeof n.native.admitsRecord!="function"||typeof n.native.verifiesReceipt!="function")return E("action/consumer-context");V(n.statementScope);let i=Bt(pt(e,o),o),a=hr(i.statement,o);if(!n||a!==hr(n.expectedStatement,o))return E("action/context");let c=to(t,r,n.native);if(c.identity!==i.act||O(n.native.digest(r+`
46
+ `))!==i.evidence)return E("action/receipt-binding");let l=c.records.flatMap(f=>{let u=x(f);return u.kind==="fact"&&u.value.fields.scope===n.statementScope?[u.value.fields]:[]});return l.length!==1||l[0].by!==i.statement.key||l[0].role!=="writes"||l[0].form!=="alphabet"||l[0].measure!=="digest"||l[0].value!==n.native.digest(a+`
47
+ `)?E("action/statement-binding"):{status:"authenticated-action",statement:i.statement,result:c,effects:"not performed"}}s(Li,"verifyActionReceipt");function Fc(e,t){let r=I(e,["emitter","region","reference","action"]);A(r.emitter),V(r.region);let n=Ke(A(r.reference));return{emitter:r.emitter,region:r.region,reference:Ge(n),action:Bt(pt(r.action,t),t)}}s(Fc,"link");function oo(e,t){let r=Fc(e,t);return H(no,{emitter:r.emitter,region:r.region,reference:r.reference,action:pt(r.action,t)},t)}s(oo,"encodeActionLink");function qi(e,t){let r=Y(no,e,t);I(r,["emitter","region","reference","action"]);let n=Fc({emitter:r.emitter,region:r.region,reference:r.reference,action:Bt(r.action,t)},t);return Z(oo(n,t),e),n}s(qi,"decodeActionLink");function Cc(e,t,r,n,o,i,a){let c=qi(oo(e,a),a),l=Li(c.action,t,r,n,a),f=Ke(c.reference);if(c.emitter!==l.statement.key||c.region!==l.statement.region||l.statement.result!==n.native.digest(at(f)+`
48
+ `))return E("action/link-binding");let u=_n(f,o,i);return{status:"authenticated-link",action:l,object:u,...u.kind==="needs"?{needs:["needs/bytes/"+f.blob]}:{},locationAuthentication:"not established",objectAuthentication:"not demonstrated"}}s(Cc,"verifyActionLink");var io="topos-governance-record/1";function yr(e,t){if(e?.kind==="group"){let r=I(e,["kind","place","snapshot","name","regions"],["previous"]);return V(r.place),A(r.name),O(r.snapshot),r.previous!==void 0&&O(r.previous),{...e,regions:Ut(r.regions,t,V)}}if(e?.kind==="member"){let r=I(e,["kind","place","group","key","horizon","evidence"]);return V(r.place),A(r.key),O(r.group),O(r.evidence),{...e,horizon:Ye(e.horizon)}}if(e?.kind==="decision"){let r=I(e,["kind","place","group","membership","proposal","context","quorum","horizon","proofs"]);V(r.place);for(let i of["group","membership","proposal","context"])O(r[i]);let n=D(r.proofs,t,i=>{let a=I(i,["key","evidence"]);return{key:A(a.key),evidence:O(a.evidence)}}).sort((i,a)=>w(i.key,a.key));if(new Set(n.map(i=>i.key)).size!==n.length)return E("governance/duplicate-proof-key");D(e.quorum?.eligible,t,A);let o=gi(e.quorum);return{...e,proofs:n,quorum:o,horizon:Ye(e.horizon)}}return E("governance/kind")}s(yr,"checked");function Tt(e,t){let r=yr(e,t);return H(io,Object.fromEntries(Object.entries(r).map(([n,o])=>[n,typeof o=="string"?o:JSON.stringify(o)])),t)}s(Tt,"encodeGovernanceRecord");function Di(e,t){let r=Y(io,e,t),n={...r};for(let i of["regions","horizon","quorum","proofs"])r[i]!==void 0&&(n[i]=Q(r[i]));let o=yr(n,t);return Z(Tt(o,t),e),o}s(Di,"decodeGovernanceRecord");function Nc(e,t){let r=Di(Tt(e,t),t),n=r.kind==="group"?["governance/admission-under-prior-authority"]:r.kind==="member"?["needs/bytes/"+r.group,"governance/member-signature-and-validity"]:["needs/bytes/"+r.group,"needs/bytes/"+r.membership,"needs/bytes/"+r.proposal,"governance/verified-eligibility-signatures-and-deadline","governance/native-threshold-admission"];return{status:"declared",record:r,needs:n,authority:"not established",quorumDecision:"not evaluated",independence:"not established"}}s(Nc,"inspectGovernanceRecord");function jc(e,t,r,n,o){let i=yr(e,o),a=yr(t,o),c=yr(r,o);if(i.kind!=="group"||a.kind!=="group"||c.kind!=="decision")return E("governance/change-kind");let l=O(n(Tt(i,o)+`
49
+ `)),f=O(n(Tt(a,o)+`
50
+ `));return a.previous!==l||c.group!==l||c.proposal!==f||i.place!==a.place||i.place!==c.place||i.name!==a.name?E("governance/prior-group-binding"):{status:"declared-change",previous:l,next:f,needs:["governance/native-threshold-admission"],authority:"not established"}}s(jc,"inspectGroupChange");var so="topos-portable-birth/1",_d=["scope","role","form","measure","value","at","needs","shape","about","restsOn"];function $c(e,t){let r=I(e,["origin","declarations"]);O(r.origin);let n=D(r.declarations,t,o=>{let i=Id(o,t),a=x(i);if(a.kind!=="fact")return E("pack/declaration");let c=a.value.fields;return Object.keys(c).some(l=>!_d.includes(l))||!c.scope||!c.measure||c.value===void 0||c.role!=="writes"||c.form!=="alphabet"?E("pack/envelope"):(V(c.scope),A(c.measure),c.value==="withdraw"||/^(?:keys|authority|grants|coverage|root|store|derived)(?:\/|$)/.test(c.scope)||["public-key","key-class","coverage","grant","signature","private-key"].includes(c.measure)?E("pack/authority-material"):v(c)!==i?E("pack/canonical-declaration"):i)}).sort(w);return n.length?new Set(n).size!==n.length?E("pack/duplicate"):{origin:r.origin,declarations:n}:E("pack/empty")}s($c,"checked");function Id(e,t){return typeof e!="string"||e.length>t.bytes||/[\r\n\0]/.test(e)?E("pack/declaration"):e}s(Id,"recordTextLine");function ao(e,t){let r=$c(e,t);return H(so,{origin:r.origin,declarations:JSON.stringify(r.declarations)},t)}s(ao,"encodePortableBirth");function zi(e,t){let r=Y(so,e,t);I(r,["origin","declarations"]);let n=$c({origin:r.origin,declarations:Q(r.declarations)},t);return Z(ao(n,t),e),n}s(zi,"decodePortableBirth");function Pc(e,t,r){let n=zi(ao(e,r),r),o=new Set(D(t,r,V)),i=n.declarations.map(c=>{let l=x(c);return l.kind!=="fact"?E("pack/declaration"):l.value.fields.scope}),a=[...new Set(i.filter(c=>o.has(c)))].sort(w);return{status:a.length?"open":"declared",pack:n,collisions:a,needs:a.map(c=>"pack/collision/"+c),admission:"not performed",authority:"not transferred"}}s(Pc,"inspectPortableBirth");var co="topos-source-exhaustion/1",Wi=s(e=>!Number.isSafeInteger(e)||Number(e)<0?E("source-exhaustion/time"):e,"tick");function Mc(e,t){let r=I(e,["card","source","unit","frame","exhaustedAt","knownSince","evidence","events","recovery"]);for(let f of["card","evidence"])O(r[f]);A(r.source),A(r.unit);let n=Ye(e.frame),o=Wi(r.exhaustedAt),i=Wi(r.knownSince);if(o<n.from||i<n.from||n.through!==void 0&&(o>n.through||i>n.through))return E("source-exhaustion/frame");let a=D(r.events,t,f=>{let u=I(f,["id","evidence"]);return{id:A(u.id),evidence:O(u.evidence)}}).sort((f,u)=>w(f.id,u.id));if(new Set(a.map(f=>f.id)).size!==a.length)return E("source-exhaustion/duplicate-event");let c=I(r.recovery,["kind"],r.recovery?.kind==="declared"?["at","evidence"]:[]),l;if(c.kind==="unknown")l={kind:"unknown"};else if(c.kind==="declared"){let f=Wi(c.at);if(f<o)return E("source-exhaustion/recovery-before-exhaustion");l={kind:"declared",at:f,evidence:O(c.evidence)}}else return E("source-exhaustion/recovery");return{card:r.card,source:r.source,unit:r.unit,frame:n,exhaustedAt:o,knownSince:i,evidence:r.evidence,events:a,recovery:l}}s(Mc,"checked");function lo(e,t){let r=Mc(e,t);return H(co,Object.fromEntries(Object.entries(r).map(([n,o])=>[n,typeof o=="string"?o:JSON.stringify(o)])),t)}s(lo,"encodeSourceExhaustion");function Ji(e,t){let r=Y(co,e,t),n={...r};for(let i of["frame","events","recovery","exhaustedAt","knownSince"])n[i]=Q(r[i]);let o=Mc(n,t);return Z(lo(o,t),e),o}s(Ji,"decodeSourceExhaustion");function Uc(e,t,r,n,o){let i=Ji(lo(e,o),o),a=dt(lt(t));return O(n(lt(a)+`
51
+ `))!==i.card||i.source!==a.source||i.source!==r.source||i.unit!==a["cost-unit"]||i.frame.clock!==r.clock||i.frame.unit!==r.unit?E("source-exhaustion/context"):{status:"declared",record:i,needs:["source-exhaustion/verify-observation",...i.recovery.kind==="unknown"?["source-exhaustion/recovery-unknown"]:["source-exhaustion/verify-recovery"]],budgetDecision:"not evaluated",retry:"not scheduled"}}s(Uc,"inspectSourceExhaustion");var fo="topos-profile-composition/1";function Bc(e,t){let r=I(e,["name","parents","fields","pins","witnesses"]);A(r.name);let n=D(r.parents,t,O).sort(w);if(new Set(n).size!==n.length)return E("profile/duplicate-parent");let o=D(r.fields,t,c=>{let l=I(c,["coordinate","contract","value"]);return typeof l.value!="string"?E("profile/value"):{coordinate:V(l.coordinate),contract:O(l.contract),value:l.value}}).sort((c,l)=>w(c.coordinate,l.coordinate)),i=D(r.pins,t,c=>{let l=I(c,["category","class","algorithm","digest"]);return l.algorithm!=="sha256"?E("profile/pin-algorithm"):{category:V(l.category),class:A(l.class),algorithm:"sha256",digest:O(l.digest)}}).sort((c,l)=>w(c.category,l.category)),a=D(r.witnesses,t,c=>{let l=I(c,["coordinate","reading"]);return{coordinate:V(l.coordinate),reading:pr(Mt(l.reading))}}).sort((c,l)=>w(c.coordinate,l.coordinate));for(let c of[o.map(l=>l.coordinate),i.map(l=>l.category),a.map(l=>l.coordinate)])if(new Set(c).size!==c.length)return E("profile/duplicate-coordinate");return{name:r.name,parents:n,fields:o,pins:i,witnesses:a}}s(Bc,"checked");function po(e,t){let r=Bc(e,t);return H(fo,{name:r.name,parents:JSON.stringify(r.parents),fields:JSON.stringify(r.fields),pins:JSON.stringify(r.pins),witnesses:JSON.stringify(r.witnesses)},t)}s(po,"encodeProfileComposition");function uo(e,t){let r=Y(fo,e,t);I(r,["name","parents","fields","pins","witnesses"]);let n=Bc({name:r.name,parents:Q(r.parents),fields:Q(r.fields),pins:Q(r.pins),witnesses:Q(r.witnesses)},t);return Z(po(n,t),e),n}s(uo,"decodeProfileComposition");function Tc(e,t,r){let n=uo(po(e,r),r),o=new Set,i=new Map,a=new Set;function c(g){if(o.has(g))return E("profile/cycle");if(i.has(g))return;if(i.size+o.size>=r.items)return E("profile/closure-budget");let m=t.profiles.get(g);if(m===void 0){a.add("needs/bytes/"+g);return}if(O(t.digest(m+`
52
+ `))!==g)return E("profile/integrity");o.add(g);let y=uo(m,r);for(let b of y.parents)c(b);o.delete(g),i.set(g,y)}s(c,"visit");for(let g of n.parents)c(g);if(a.size)return{status:"open",needs:[...a].sort(w),authority:"not established"};let f=[...[...i].sort(([g],[m])=>w(g,m)).map(([g,m])=>({source:g,p:m})),{source:"self",p:n}],d=[...new Set(f.flatMap(g=>g.p.fields.map(m=>m.coordinate)))].sort(w).map(g=>{let m=f.flatMap(k=>k.p.fields.filter(z=>z.coordinate===g).map(z=>({...z,source:k.source}))),y=[...new Set(m.map(k=>k.contract))];if(y.length!==1)return E("profile/field-contract");let b=t.fields.get(y[0]);if(!b||b.coordinate!==g)return E("profile/undeclared-field");let F=m.filter(k=>k.source!=="self"),P=m.find(k=>k.source==="self"),G=it(b,F.map(k=>({...k,own:!1}))),ge=it(b,m.map(k=>({...k,own:k.source==="self"}))),N="addition";G.kind==="incompatible"?N="inherited-incompatible":P&&G.kind==="compatible"?N=Rt(b,G.value,b.decode(P.value)):P||(N="inherited"),(N==="widening-needs-authority"||N==="non-meet")&&a.add("profile/authorize-transition/"+g);let C=n.witnesses.find(k=>k.coordinate===g);return C&&a.add("profile/verify-witness/"+g),{coordinate:g,composition:ge.kind,transition:N,witness:!!C}}),h=[...new Set(f.flatMap(g=>g.p.pins.map(m=>m.category)))].sort(w).map(g=>{let m=f.flatMap(y=>y.p.pins.filter(b=>b.category===g));return new Set(m.map(y=>JSON.stringify(y))).size!==1?E("profile/ambiguous-pin"):m[0]});return{status:"declared",fields:d,pins:h,needs:[...a].sort(w),authority:"not established"}}s(Tc,"inspectProfileComposition");var mo="topos-reference-projection/1";function Lc(e,t,r){let n=I(e,["reference","duplicates","relations"],["inline"]);if(!Number.isSafeInteger(r)||r<0)return E("reference-projection/budget");let o=Ge(Ke(A(n.reference)));if(n.duplicates!=="preserve"&&n.duplicates!=="refuse")return E("reference-projection/duplicates-policy");let i=D(n.relations,t,c=>{let l=I(c,["relation","target"]);return{relation:A(l.relation),target:O(l.target)}}).sort((c,l)=>w(c.relation,l.relation)||w(c.target,l.target));if(n.duplicates==="refuse"&&new Set(i.map(c=>JSON.stringify(c))).size!==i.length)return E("reference-projection/duplicate-relation");let a;if(n.inline!==void 0){let c=I(n.inline,["profile","text","digest"]);if(A(c.profile),O(c.digest),typeof c.text!="string")return E("reference-projection/text");if(new TextEncoder().encode(c.text).length>r)return E("reference-projection/inline-budget");a={profile:c.profile,text:c.text,digest:c.digest}}return{reference:o,duplicates:n.duplicates,relations:i,...a?{inline:a}:{}}}s(Lc,"checked");function go(e,t,r){let n=Lc(e,t,r);return H(mo,{reference:n.reference,duplicates:n.duplicates,relations:JSON.stringify(n.relations),...n.inline?{inline:JSON.stringify(n.inline)}:{}},t)}s(go,"encodeReferenceProjection");function Hi(e,t,r){let n=Y(mo,e,t);I(n,["reference","duplicates","relations"],["inline"]);let o=Lc({...n,relations:Q(n.relations),...n.inline?{inline:Q(n.inline)}:{}},t,r);return Z(go(o,t,r),e),o}s(Hi,"decodeReferenceProjection");function qc(e,t,r,n){let o=Hi(go(e,r,n),r,n);if(o.inline&&O(t(new TextEncoder().encode(o.inline.text)))!==o.inline.digest)return E("reference-projection/inline-integrity");let i=Ke(o.reference);return{status:"declared",referenceIdentity:at(i),projection:o.inline??null,relations:o.relations,needs:["needs/bytes/"+i.blob],projectionCompleteness:"not demonstrated",authentication:"not verified",fragmentPrivacy:"not promised"}}s(qc,"inspectReferenceProjection");var ho="topos-refusal-catalog/1",Gi=s(e=>typeof e!="string"||!e.trim()||/[\u0000-\u001f\u007f]/.test(e)?E("catalog/prose"):e,"prose");function Dc(e,t){let r=I(e,["actions","entries","demands"]),n=D(r.actions,t,a=>{let c=I(a,["name","meaning"]);return{name:A(c.name),meaning:Gi(c.meaning)}}).sort((a,c)=>w(a.name,c.name));if(new Set(n.map(a=>a.name)).size!==n.length)return E("catalog/duplicate-action");let o=D(r.entries,t,a=>{let c=I(a,["producer","implementation","code","class","meaning","next","vector","case"]),l={producer:A(c.producer),implementation:O(c.implementation),code:A(c.code),class:A(c.class),meaning:Gi(c.meaning),next:A(c.next),vector:A(c.vector),case:A(c.case)};return n.some(f=>f.name===l.next)?l:E("catalog/unresolved-next")}).sort((a,c)=>w(a.producer,c.producer)||w(a.code,c.code));if(new Set(o.map(a=>a.producer+"\0"+a.code)).size!==o.length)return E("catalog/duplicate-code");let i=D(r.demands,t,a=>{let c=I(a,["producer","name","needs"]);return{producer:A(c.producer),name:A(c.name),needs:Gi(c.needs)}}).sort((a,c)=>w(a.producer,c.producer)||w(a.name,c.name));return new Set(i.map(a=>a.producer+"\0"+a.name)).size!==i.length?E("catalog/duplicate-demand"):{actions:n,entries:o,demands:i}}s(Dc,"checked");function br(e,t){let r=Dc(e,t);return H(ho,{actions:JSON.stringify(r.actions),entries:JSON.stringify(r.entries),demands:JSON.stringify(r.demands)},t)}s(br,"encodeRefusalCatalog");function Ki(e,t){let r=Y(ho,e,t);I(r,["actions","entries","demands"]);let n=Dc({actions:Q(r.actions),entries:Q(r.entries),demands:Q(r.demands)},t);return Z(br(n,t),e),n}s(Ki,"decodeRefusalCatalog");function zc(e,t,r,n){let o=Ki(br(e,n),n),i=o.entries.find(a=>a.producer===t&&a.code===r);return i?{status:"declared",entry:i,authentication:"not verified"}:{status:"open",needs:["catalog/producer/"+A(t)+"/"+A(r)]}}s(zc,"lookupRefusal");function Wc(e,t,r){return O(t(br(e,r)+`
53
+ `))}s(Wc,"refusalCatalogIdentity");function Jc(e,t,r){try{let n=s(()=>{let i=t.reads??[],a=Object.fromEntries(Object.entries(t.regions??{}).filter(([c])=>i.some(l=>ee(l,`region/${c}`))).map(([c,l])=>[c,{lines:Kt(["**"],l.lines),receipts:Kt(["**"],l.receipts)}]));return{...t.place===void 0?{}:{place:t.place},...t.provider===void 0?{}:{provider:Xr(t.provider)},region:t.region??"",at:t.at??3,shape:t.shape??"",name:t.name??"",reads:i,lines:Kt(i,t.lines??[]),regions:a}},"asked");if(t.verb==="render"&&e.render)return{protocol:re,kind:"fact",lines:e.render(n())};if(t.verb==="read"&&e.receipt&&t.reads!==void 0)return{protocol:re,kind:"fact",claims:e.receipt(n())};let o=t.files[0];return t.verb==="read"&&e.observe&&o!==void 0?{protocol:re,kind:"fact",claims:e.observe(new TextEncoder().encode(o.text),t.rootScope,t.region,t.files,n())}:t.verb==="read"&&e.run?{protocol:re,kind:"fact",claims:e.run(t.rootScope,r,t.held??[],t.region,n())}:t.verb==="read"&&e.observe?{protocol:re,kind:"refuse",why:"no file was handed to observe"}:{protocol:re,kind:"abstain",why:`no export answers ${t.verb}`}}catch(n){return{protocol:re,kind:"refuse",why:String(n)}}}s(Jc,"answer");var Ad=s(e=>{let t=globalThis.__boundRead;return globalThis.__boundRead=e,t},"listen"),Fd=s((e,t)=>{let r=globalThis.__boundRead;if(r===void 0||!Array.isArray(e.cases))return e;let n=e.cases.map((o,i)=>new Proxy(o,{get:s((a,c,l)=>(typeof c=="string"&&r(`${t}#${i}:${c}`),Reflect.get(a,c,l)),"get")}));return{...e,cases:n}},"observed"),Cd=s((e,t,r)=>JSON.stringify(JSON.parse(t).map(n=>Jc(e,n,r))),"respond");function Nd(e,t){let r=/(?:^|\n)([^\n]*)$/.exec(e.trimEnd())?.[1]??"",n=r.startsWith("[")?JSON.parse(r):[];return Array.from({length:t},(o,i)=>n[i]??{protocol:re,kind:"refuse",why:"no answer"})}s(Nd,"responsesOf");var Te="place-act-context@1",S=s(e=>{throw Error("REFUSE\xB7place-act "+e)},"refuse"),ce=s(e=>typeof e=="string"&&e.length>0,"exactString"),wr=s(e=>!ce(e)||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>String(Number.MAX_SAFE_INTEGER).length||!Number.isSafeInteger(Number(e))?S("unknown or invalid clock"):e,"clock"),bo=s(e=>{(!e||typeof e!="object")&&S("missing resource budget");for(let t of["bytes","records","placements","policies","proofs","signers"])(!Number.isSafeInteger(e[t])||e[t]<1)&&S("missing resource "+t)},"budget"),qt=s(e=>new TextEncoder().encode(e).byteLength,"bytes"),Vi=s(e=>{let t=x(e);return t.kind!=="fact"||v(t.value.fields,t.value.version)!==e||!t.value.fields.sig||!t.value.fields.by?S("noncanonical or unsigned original"):t.value.fields},"fields"),jd=s(e=>{e!=="."&&(!e.endsWith("/TARGET.bound")||e.startsWith("/")||e.split("/").some(t=>t===""||t==="."||t===".."))&&S("unknown place coordinate")},"place"),Lt=s(e=>JSON.stringify(e)+`
54
+ `,"frame"),yo=s(e=>[e.namespace,e.snapshot,e.epoch,e.prefix,e.head,e.policies],"rootTuple");function vr(e,t,r,n){mt({root:e,places:[t]},n),ce(r)||S("unknown origin signer"),r.length>n.bytes&&S("byte budget");let o=Lt([Te,"origin",r,t.place,t.epoch,t.originPrefix,e.snapshot,t.records]);return(r.length>n.bytes||qt(o)>n.bytes)&&S("byte budget"),o}s(vr,"originContextBytes");function mt(e,t){bo(t),(!e||typeof e!="object"||!e.root||!Array.isArray(e.places)||!Array.isArray(e.root.policies))&&S("incomplete context"),e.places.some(c=>!c||!Array.isArray(c.records)||!Array.isArray(c.proofs))&&S("incomplete place context"),(e.places.length>t.placements||e.root.policies.length>t.policies)&&S("dependency/placement budget");let r=0,n=0,o=0,i=s(c=>{if(!ce(c))return S("unknown context reference");c.length>t.bytes&&S("byte budget"),o+=c.length,o>t.bytes&&S("byte budget")},"scalar");for(let c of[e.root.namespace,e.root.snapshot,e.root.epoch,e.root.prefix,e.root.head,...e.root.policies])i(c);for(let c of e.places){r+=c.records.length,n+=c.proofs.length,(r>t.records||n>t.proofs)&&S("record/proof budget");for(let l of[c.place,c.previous,c.epoch,c.originPrefix,...c.records])i(l);for(let l of c.proofs)(!l||typeof l!="object")&&S("unknown origin proof"),i(l.by),i(l.signature)}let a=Lt([Te,"transaction",yo(e.root),e.places.map(c=>[c.place,c.previous,c.epoch,c.originPrefix,c.records,c.proofs.map(l=>[l.by,l.signature])])]);return qt(a)>t.bytes&&S("byte budget"),Dt(a,t),a}s(mt,"placeActContextBytes");function Dt(e,t){bo(t),(typeof e!="string"||qt(e)>t.bytes)&&S("byte budget");let r;try{r=JSON.parse(e)}catch{return S("invalid framing")}(!Array.isArray(r)||r.length!==4||r[0]!==Te||r[1]!=="transaction")&&S("unsupported clock profile");let n=r[2],o=r[3];(!Array.isArray(n)||n.length!==6||!Array.isArray(n[5])||!Array.isArray(o))&&S("incomplete context"),(n[5].length>t.policies||o.length>t.placements)&&S("dependency/placement budget");let i=0,a=0;for(let f of o)(!Array.isArray(f)||f.length!==6||!Array.isArray(f[4])||!Array.isArray(f[5]))&&S("incomplete place context"),i+=f[4].length,a+=f[5].length;(i>t.records||a>t.proofs)&&S("record/proof budget"),(!o.length||!i)&&S("empty transaction"),(!n.slice(0,5).every(ce)||!n[5].every(ce))&&S("unknown authority context"),wr(n[2]),(new Set(n[5]).size!==n[5].length||n[5].some((f,u)=>u>0&&w(n[5][u-1],f)>=0))&&S("noncanonical policy dependencies");let c=o.map(f=>{(!f.slice(0,4).every(ce)||!f[4].every(ce)||!f[4].length)&&S("unknown place context"),jd(f[0]),wr(f[2]),f[5].some(d=>!Array.isArray(d)||d.length!==2||!d.every(ce))&&S("unknown origin proof");let u=f[5].map(d=>({by:d[0],signature:d[1]}));return(new Set(u.map(d=>d.by)).size!==u.length||u.some((d,p)=>p>0&&w(u[p-1].by,d.by)>=0))&&S("duplicate/noncanonical origin proofs"),{place:f[0],previous:f[1],epoch:f[2],originPrefix:f[3],records:f[4],proofs:u}});(new Set(c.map(f=>f.place)).size!==c.length||c.some((f,u)=>u>0&&w(c[u-1].place,f.place)>=0))&&S("duplicate/noncanonical places");let l={namespace:n[0],snapshot:n[1],epoch:n[2],prefix:n[3],head:n[4],policies:n[5]};return Lt([Te,"transaction",yo(l),o])!==e&&S("noncanonical framing"),{root:l,places:c}}s(Dt,"readPlaceActContext");function $d(e,t,r,n,o){let i=t.place==="."?e.scope:[o,t.place.slice(0,-13),e.scope].join("/"),a=It(e,r,Number(wr(n.epoch)),i,"authority");a.kind!=="admitted"&&S("authority "+a.kind+" "+a.why)}s($d,"eligibility");function Pd(e,t,r){let n=Vi(e),o=r.signers.find(i=>i.id===n.by);if(!o||r.verifiesOriginal(e,o,r.root)!==!0)return S("original signature");wr(n.epoch)!==t.epoch&&S("origin clock mismatch"),$d(n,t,o,r.root,r.regionFamily)}s(Pd,"verifyAuthenticatedOriginal");function zt(e,t){(!t||typeof t!="object")&&S("missing instrument trust");let r=Dt(e,t.budget);for(let n of["verifiesRootContext","verifiesNamespaceAdmission","verifiesNewLocalPrefix","verifiesOriginal","verifiesProof","digest"])typeof t[n]!="function"&&S("missing instrument verifier "+n);(!t.root||!Array.isArray(t.signers)||!Array.isArray(t.places))&&S("missing authenticated context"),new Set(t.signers.map(n=>n.id)).size!==t.signers.length&&S("duplicate signer id"),(t.signers.length>t.budget.signers||!t.places.length||!ce(t.regionFamily))&&S("trusted context budget/mapping"),(Lt(yo(r.root))!==Lt(yo(t.root))||t.verifiesRootContext(r.root)!==!0)&&S("unauthenticated authority context");for(let n of r.places){(!t.places.includes(n.place)||t.verifiesNamespaceAdmission(n.place,r.root)!==!0)&&S("namespace not admitted"),t.verifiesNewLocalPrefix(n.place,n.originPrefix,n.epoch,n.records)!==!0&&S("origin prefix or legacy reinterpretation");let o=[...new Set(n.records.map(a=>Vi(a).by))].sort(w);(o.length!==n.proofs.length||o.some((a,c)=>n.proofs[c].by!==a))&&S("missing/borrowed origin proof");for(let a of n.proofs){let c=t.signers.find(l=>l.id===a.by);(!c||t.verifiesProof(vr(r.root,n,a.by,t.budget),a.signature,c,r.root)!==!0)&&S("origin proof signature")}let i=n.records.map(a=>t.digest(pe(Vi(a))));new Set(i).size!==i.length&&S("duplicate original");for(let a of n.records)Pd(a,n,t)}return{identity:t.digest(e),context:r,dependencies:r.root}}s(zt,"verifyPlaceActContext");function Er(e,t,r,n,o,i){mt({root:r,places:[t]},i),(!ce(e)||!ce(n)||!ce(o))&&S("unknown receipt identity/signer"),(e.length>i.bytes||n.length>i.bytes||o.length>i.bytes)&&S("byte budget");let a=Lt([Te,"receipt",n,o,e,t.place,t.previous,t.epoch,r.snapshot]);return qt(a)>i.bytes&&S("byte budget"),a}s(Er,"placeReceiptBytes");function wo(e,t,r){(!r||typeof r!="object")&&S("missing instrument trust"),bo(r.budget),Array.isArray(t)||S("unknown receipt set"),t.length>r.budget.placements&&S("receipt budget");let n=0;for(let c of t){(!c||typeof c!="object")&&S("unknown receiver receipt");for(let l of[c.by,c.place,c.signature])(!ce(l)||l.length>r.budget.bytes)&&S("receipt byte budget"),n+=l.length}(n>r.budget.bytes||qt(JSON.stringify(t))>r.budget.bytes)&&S("receipt byte budget"),t.length>r.budget.placements&&S("receipt budget"),ce(r.receiptScope)||S("unknown receiver scope");let o=zt(e,r);(t.length!==o.context.places.length||new Set(t.map(c=>c.place)).size!==t.length)&&S("incomplete/duplicate receiver receipts");let i=r.signers.find(c=>c.id===r.receiptSigner);if(!i)return S("unknown receiver signer");let a=It({scope:r.receiptScope,by:i.id},i,Number(wr(r.root.epoch)),r.receiptScope,"authority");a.kind!=="admitted"&&S("receiver authority "+a.kind+" "+a.why);for(let c of o.context.places){let l=t.find(f=>f.place===c.place);(!l||l.by!==r.receiptSigner||r.verifiesProof(Er(o.identity,c,o.context.root,l.by,r.receiptScope,r.budget),l.signature,i,r.root)!==!0)&&S("receiver receipt signature")}return{identity:o.identity,places:o.context.places.map(c=>({place:c.place,epoch:c.epoch}))}}s(wo,"placeActReceiptsOf");function vo(e,t,r){(!r||typeof r!="object")&&S("missing instrument trust"),bo(r.budget),(typeof e!="string"||e.length>r.budget.bytes||qt(e)>r.budget.bytes)&&S("byte budget");let n=mt({root:r.root,places:[t]},r.budget);t.records.includes(e)||S("original not in bound context"),zt(n,r)}s(vo,"verifyOriginalAtAuthorityContext");function Xi(e){let t=Be("distribution",e,"buckets"),r=Be("distribution",e,"levels"),n=t.reduce(o=>o.flatMap(i=>r.map(a=>[...i,a])),[[]]);return{buckets:t,levels:r,tuples:n}}s(Xi,"product");var Yi=s(e=>{let{levels:t,tuples:r}=Xi(e),n=s(o=>o.map(i=>t.findIndex(a=>a===i)),"at");return{levels:r.map(o=>JSON.stringify(o)),leq:r.map(o=>r.map(i=>n(o).every((a,c)=>a<=(n(i)[c]??-1))))}},"orderOver"),Hc={id:"distribution",lattice:s(e=>Ee.lattice(Yi(e)),"lattice"),parse(e,t){let{buckets:r,levels:n}=Xi(e),o=s(f=>r.find(u=>!u.includes(":")&&f.startsWith(`${u}:`)),"bucketOf"),i=M(t).members,a=new Map(i.flatMap(f=>(u=>u===void 0?[]:[[u,f.slice(u.length+1)]])(o(f)))),c=i.find(f=>o(f)===void 0)??r.find(f=>!a.has(f));c!==void 0&&ke("distribution",`\`${c}\` is not the bucket list it is given, every bucket named once`);let l=r.map(f=>At("distribution",n,a.get(f)??""));return{subject:"",floor:JSON.stringify(l.map(f=>f.floor)),ceiling:JSON.stringify(l.map(f=>f.ceiling))}},emit(e,t){let[r,n]=[JSON.parse(t.floor),JSON.parse(t.ceiling)];return kn(Xi(e).buckets.map((o,i)=>r[i]===n[i]?`${o}:${r[i]}`:`${o}:${r[i]}..${n[i]}`))},show:s((e,t)=>Ee.lattice(Yi(e)).show(t),"show"),points:s((e,t,r)=>Ee.points(Yi(e),t,r),"points")};var Eo=s(e=>({lo:se("interval",e,"lo"),hi:se("interval",e,"hi")}),"span"),Gc={id:"interval",lattice:s(e=>j.lattice(Eo(e)),"lattice"),parse:s((e,t)=>we("interval",Eo(e),t),"parse"),emit:s((e,t)=>Ne(t),"emit"),show:s((e,t)=>j.lattice(Eo(e)).show(t),"show"),points:s((e,t,r)=>j.points(Eo(e),t,r),"points")};var xo=s(e=>({levels:Be("ladder",e,"levels")}),"over"),Kc={id:"ladder",lattice:s(e=>Ze.lattice(xo(e)),"lattice"),parse:s((e,t)=>At("ladder",xo(e).levels,t),"parse"),emit:s((e,t)=>t.floor===t.ceiling?t.floor:`${t.floor}..${t.ceiling}`,"emit"),show:s((e,t)=>Ze.lattice(xo(e)).show(t),"show"),points:s((e,t,r)=>Ze.points(xo(e),t,r),"points")};function Ro(e){let t=Be("lattice",e,"levels"),r=Sn(e).leq;return(!Array.isArray(r)||r.length!==t.length||r.some(n=>!Array.isArray(n)||n.length!==t.length))&&ke("lattice","takes leq as a square of truths over its levels"),{levels:t,leq:r}}s(Ro,"orderOf");var Vc={id:"lattice",lattice:s(e=>Ee.lattice(Ro(e)),"lattice"),parse:s((e,t)=>At("lattice",Ro(e).levels,t),"parse"),emit:s((e,t)=>t.floor===t.ceiling?t.floor:`${t.floor}..${t.ceiling}`,"emit"),show:s((e,t)=>Ee.lattice(Ro(e)).show(t),"show"),points:s((e,t,r)=>Ee.points(Ro(e),t,r),"points")};var So=s(e=>({lo:se("phase",e,"lo"),hi:se("phase",e,"hi")}),"span"),Yc={id:"phase",lattice:s(e=>j.lattice(So(e)),"lattice"),parse:s((e,t)=>we("phase",So(e),t),"parse"),emit:s((e,t)=>Ne(t),"emit"),show:s((e,t)=>j.lattice(So(e)).show(t),"show"),points:s((e,t,r)=>j.points(So(e),t,r),"points")};var ko=s(e=>({lo:0,hi:se("rank",e,"n")}),"span"),Xc={id:"rank",lattice:s(e=>j.lattice(ko(e)),"lattice"),parse:s((e,t)=>we("rank",ko(e),t),"parse"),emit:s((e,t)=>Ne(t),"emit"),show:s((e,t)=>j.lattice(ko(e)).show(t),"show"),points:s((e,t,r)=>j.points(ko(e),t,r),"points")};var Oo=s(e=>({lo:se("stretch",e,"lo"),hi:se("stretch",e,"hi")}),"span"),Qc={id:"stretch",lattice:s(e=>j.lattice(Oo(e)),"lattice"),parse:s((e,t)=>we("stretch",Oo(e),t),"parse"),emit:s((e,t)=>Ne(t),"emit"),show:s((e,t)=>j.lattice(Oo(e)).show(t),"show"),points:s((e,t,r)=>j.points(Oo(e),t,r),"points")};var Qi=ne(-1/0,1/0),Zc=kr(),Md={K:1e3,M:1e6,G:1e9};function Zi(e){let t=/^(-?\d+(?:\.\d+)?)([KMG])?\.\.((-?\d+(?:\.\d+)?)([KMG])?|\*)$/.exec(e);if(!t)return null;let r=s((n,o)=>Number(n)*(o?Md[o]:1),"n");return{lo:r(t[1],t[2]),hi:t[3]==="*"?1/0:r(t[4],t[5])}}s(Zi,"spanOf");function el(e){let t=e.startsWith("not:");return{polarity:t?"forbid":"permit",values:new Set((t?e.slice(4):e).split("|").filter(r=>r!==""&&r!=="none"))}}s(el,"idsOf");function tl(e){if(!e.length)return;if(e[0].form==="interval"){let o=e.map(i=>Zi(i.value));return o.every(i=>i!==null)?{L:Qi,spans:o}:void 0}if(e[0].form!=="alphabet")return;let t="\0",r=e.map(o=>({forbid:o.value.startsWith("not:"),names:(o.value.startsWith("not:")?o.value.slice(4):o.value).split("|").filter(Boolean)})),n={tokens:[...new Set([t,...r.flatMap(o=>o.names)])].sort()};return{L:Fe.lattice(n),spans:r.map(o=>Fe.parse(n,{want:o.forbid?n.tokens.filter(i=>!o.names.includes(i)):o.names}))}}s(tl,"configurationValues");var xr=".bound",rl=`TARGET${xr}`,nl=`capsule${xr}`,ol=`receipts${xr}`;var Ud=ne(-1/0,1/0),Bd={count:"sum",size:"sum",shown:"sum",longest:"max"};function il(e,t){let r=Bd[e];if(r==="max")return t.reduce((n,o)=>Ud.join(n,{lo:-1/0,hi:o}),{lo:-1/0,hi:0}).hi;if(r==="sum"||t.length<=1)return t.reduce((n,o)=>n+o,0);throw new Error(`REFUSE\xB7measure ${e}: ${t.length} readings and no combination the wire names for them`)}s(il,"combine");function sl(e,t){let r=s(u=>$(`object context: ${u}`),"fail"),n=new Map;for(let u of e){if(!t.admit(u))return r(`signature or authority does not admit ${u.fields.id}`);let d=n.get(u.fields.id);if(d&&pe(d.fields)!==pe(u.fields))return r(`record ID collision ${u.fields.id}`);d||n.set(u.fields.id,u)}let o=[...n.values()],i=new Map(o.map((u,d)=>[u.fields.id,d])),a=new Map;for(let u of o.filter(d=>d.record==="cell")){if(a.has(u.fields.scope))return r(`cell definition is not unique at ${u.fields.scope}`);a.set(u.fields.scope,u)}let c=new Map;for(let[u,d]of a)try{let p=t.resolve(d);if(p.digest!==d.fields.topos||p.form.id!==d.fields.form)return r(`selected digest/form does not match ${u}`);p.form.lattice(p.params),c.set(u,p)}catch(p){return r(`codec/pin/decoder stop at ${u}: ${String(p)}`)}let l=new Map;for(let[u,d]of a){let p=st(d.fields.restsOn);if(p===void 0)return r(`invalid declared rest at ${u}`);for(let h of p){let g=a.get(h);if(!g)return r(`missing rest target ${h}`);if(Number(g.fields.epoch)>Number(d.fields.epoch))return r(`rest target ${h} did not exist at cell declaration`);if(["topos","form","params","measure"].some(m=>g.fields[m]!==d.fields[m]))return r(`incompatible rest component ${u}/${h}`)}l.set(u,p)}let f=new Map;for(let u of a.keys()){if(f.get(u)===2)continue;let d=[{name:u,exit:!1}];for(;d.length;){let p=d.pop();if(p.exit){f.set(p.name,2);continue}if(f.get(p.name)===1)return r(`declared rest cycle reachable from ${u}`);if(f.get(p.name)!==2){f.set(p.name,1),d.push({name:p.name,exit:!0});for(let h of[...l.get(p.name)].reverse())d.push({name:h,exit:!1})}}}for(let u of o.filter(d=>d.record!=="cell")){let d=u.fields,p=a.get(d.scope);if(!p||Number(p.fields.epoch)>Number(d.epoch)||Number(p.fields.epoch)===Number(d.epoch)&&i.get(p.fields.id)>i.get(d.id))return r(`cell not declared before ${d.id}`);if(d.sign==="-1"){let h=n.get(d.takes);if(!h||h.record!==u.record||h.fields.scope!==d.scope||h.fields.sign!=="+1"||h.fields.by!==d.by||Number(h.fields.epoch)>=Number(d.epoch))return r(`unauthorized or incompatible withdrawal target ${d.takes}`)}else{let h=c.get(d.scope);try{h.form.parse(h.params,d.value)}catch(g){return r(`span codec stop at ${d.id}: ${String(g)}`)}if(u.record==="claim"&&!t.origin(d.origin,d.by,d.scope))return r(`origin is not attested for ${d.id}`);if(d.widens!==void 0&&!t.witness(d.widens,d.by,d.scope))return r(`join witness is not admitted for ${d.id}`)}}for(let u of a.keys()){let d=new Set,p=[...l.get(u)];for(;p.length;){let m=p.pop();d.has(m)||(d.add(m),p.push(...l.get(m)))}let h=o.filter(m=>m.record==="mark"&&m.fields.sign==="+1"&&m.fields.pole==="ceiling"&&(m.fields.scope===u||d.has(m.fields.scope)&&m.fields.reach==="travels")),g=new Map;for(let m of h)g.set(m.fields.epoch,[...g.get(m.fields.epoch)??[],m]);for(let m of g.values())if(m.length>1&&m.some(y=>y.fields.widens!==void 0))return r(`ambiguous same-epoch ceiling acts at ${u}`)}return fe(o)}s(sl,"validateObjectContext");function _o(e){let t=x(e,{preserveKeys:!0});if(t.kind!=="fact")return t;if(!t.value.keys.includes("type"))return fe("config");let r=t.value.fields.type;return r==="cell"||r==="claim"||r==="mark"?fe(r):$("an explicit type names cell, claim or mark","type")}s(_o,"recordKind");function al(e){let t=[];for(let o of e){let i=x(o);if(i.kind!=="fact")return i;t.push(i.value.fields)}let r=[],n=[];for(let o=0;o<e.length;o++){let i=_o(e[o]);if(i.kind!=="fact")return i;if(i.value==="config"){n.push(t[o]);continue}let a=Se(e[o],_t(t,Number(t[o].epoch)));if(a.kind!=="fact")return a;if(!("record"in a.value))throw Error("typed history returned configuration");r.push(a.value)}return fe({objects:r,configuration:n})}s(al,"objectHistory");function cl(e){return e.map(t=>{let r=x(t);if(r.kind!=="fact")throw Error(`REFUSE\xB7publication ${r.why}`);let n=r.value.fields;if(n.value==="withdraw")throw Error("REFUSE\xB7publication a withdrawal is history, not standing");if(n.type!==void 0)throw Error("REFUSE\xB7publication object history needs its semantic projection");if(dl(n))return v(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!Ot.has(i)));return v({...o,by:"target"})}).sort(w)}s(cl,"publicationOf");function ll(e){let t=e.map(r=>{let n=x(r);if(n.kind!=="fact")throw Error(`REFUSE\xB7publication ${n.why}`);return n.value.fields});if(!t.some(r=>r.sig!==void 0&&!dl(r))){for(let r of t){if(r.type!==void 0)throw Error("REFUSE\xB7publication object history needs its semantic projection");if(r.sig===void 0&&r.by!==void 0&&r.by!=="target")throw Error("REFUSE\xB7publication unsigned delivery signer");if(r.value==="withdraw")throw Error("REFUSE\xB7publication withdrawal in a public lock");if(r.sig===void 0&&[...Ot].some(n=>n!=="by"&&r[n]!==void 0))throw Error("REFUSE\xB7publication delivery envelope in a public lock")}return[...e]}}s(ll,"publicLock");function dl(e){return e.scope?.startsWith("keys/")===!0&&e.measure==="public-key"}s(dl,"isPublicKey");function ul(e){if(!e.bytes.length)throw new Error("REFUSE\xB7signer empty lot");for(let t of e.bytes){let r=x(t);if(r.kind!=="fact"||r.value.fields.sig!==void 0||r.value.fields.by!==e.keyId||pe(r.value.fields)!==t)throw new Error("REFUSE\xB7signer noncanonical payload")}return e.bytes.join(`
55
+ `)+`
56
+ `}s(ul,"requestBytes");function fl(e){return e.map(t=>v({by:t.keyId,sig:t.signature})).join(`
57
+ `)+`
58
+ `}s(fl,"responseBytes");function pl(e,t){if(!e.endsWith(`
59
+ `))throw new Error("REFUSE\xB7signer truncated response");let r=e.slice(0,-1).split(`
60
+ `);if(r.length!==t.bytes.length)throw new Error("REFUSE\xB7signer response count");return r.map(n=>{let o=x(n);if(o.kind!=="fact")throw new Error("REFUSE\xB7signer response grammar");let i=o.value.fields,a=Re(i.sig??"");if(Object.keys(i).length!==2||i.by!==t.keyId||!a||a.algorithm!==t.algorithm||v(i)!==n)throw new Error("REFUSE\xB7signer response identity or signature form");return{keyId:i.by,signature:i.sig}})}s(pl,"responseOf");function ml(e,t){let r=s((o,i)=>{let a=e.filter(l=>l.scope===o&&l.measure===i&&l.role==="writes"&&l.value!=="withdraw"),c=[...new Set(a.map(l=>l.value))];if(c.length!==1||!c[0])throw new Error(`REFUSE\xB7signer ${t} missing or conflicting ${o}`);return c[0]},"value"),n=s((o,i)=>{if(e.some(c=>c.scope===o&&c.measure===i&&c.role==="writes"&&c.value!=="withdraw"&&c.form!=="interval"))throw new Error(`REFUSE\xB7signer ${t} invalid ${o}`);let a=Ce("interval",r(o,i));if(!a||a.kind!=="interval"||a.lo===null||a.lo!==a.hi||!Number.isSafeInteger(a.lo)||a.lo<=0)throw new Error(`REFUSE\xB7signer ${t} invalid ${o}`);return a.lo},"exact");return{name:r(`keys/${t}`,"signer"),timeoutMs:n("signer/timeout","milliseconds"),responseBytes:n("signer/response-bytes","bytes")}}s(ml,"signerSelection");function gl(e,t){let r=e.filter(c=>(c.scope==="wire/reader-lifetime"||c.scope==="audit/wire/reader-lifetime")&&c.value!=="withdraw");if(!r.length)return;if(new Set(r.map(c=>c.value)).size!==1)throw Error("REFUSE\xB7wire conflicting reader lifetime profiles");let o=r[0].value;if(!["bounded-process@1","bounded-process@2"].includes(o??""))throw Error("REFUSE\xB7wire unsupported reader lifetime");let i=typeof t=="string"?t:o==="bounded-process@1"?t.module:t.id,a=s((c,l)=>{let f=[`reader/${c}`,`reader/${i}/${c}`],u=e.filter(g=>f.includes(g.scope??"")&&g.measure===l&&g.value!=="withdraw"&&g.role==="writes");if(!u.length)throw Error(`REFUSE\xB7reader ${i} no declared ${c}`);let d=u.map(g=>{let m=g.form==="interval"?Ce("interval",g.value??""):void 0;if(!m||m.kind!=="interval"||m.hi===null||!Number.isSafeInteger(m.hi)||m.hi<=0||m.lo===null||m.lo<0||m.lo>m.hi)throw Error(`REFUSE\xB7reader ${i} invalid ${g.scope}`);return{lo:m.lo,hi:m.hi}});if(o==="bounded-process@1")return Math.min(...d.map(g=>g.hi));let p=ne(0,1/0),h=d.reduce((g,m)=>p.meet(g,m),p.top);if(!p.inhabited(h))throw Error(`REFUSE\xB7reader ${i} conflicting ${c}`);return h.hi},"limit");return{timeoutMs:a("timeout","milliseconds"),responseBytes:a("response-bytes","bytes")}}s(gl,"readerLifetime");function hl(e,t){let r=e.filter(o=>(o.scope==="wire/reader-empty"||o.scope==="audit/wire/reader-empty")&&o.value!=="withdraw");if(!r.length)return!1;if(r.some(o=>o.value!=="declared-empty@1"))throw Error("REFUSE\xB7wire unsupported empty-reading contract");let n=e.filter(o=>["reader/empty",`reader/${t}/empty`].includes(o.scope??"")&&o.measure==="id"&&o.role==="writes"&&o.value!=="withdraw");if(!n.length)return!1;if(n.some(o=>o.form!=="alphabet"||!["allow","required"].includes(o.value??"")))throw Error(`REFUSE\xB7reader ${t} invalid empty policy`);return n.every(o=>o.value==="allow")}s(hl,"readerAllowsEmpty");function yl(e,t,r){let n=e.filter(i=>(i.scope==="wire/reader-inputs"||i.scope==="audit/wire/reader-inputs")&&i.value!=="withdraw");if(!n.length)return;if(n.some(i=>i.value!=="declared-presence@1"))throw Error("REFUSE\xB7wire unsupported reader input presence");let o=e.filter(i=>["reader/inputs",`reader/${t}/inputs`].includes(i.scope??"")&&i.measure==="id"&&i.role==="writes"&&i.value!=="withdraw");if(!o.length||o.some(i=>i.form!=="alphabet"||!["required","optional"].includes(i.value??"")))throw Error(`REFUSE\xB7reader ${t} no valid input presence policy`);if(r===0&&o.some(i=>i.value==="required"))throw Error(`REFUSE\xB7reader ${t} required input selection is empty`)}s(yl,"assertReaderInputs");function bl(e,t){let r=e.filter(a=>(a.scope==="wire/transport"||a.scope==="audit/wire/transport")&&a.value!=="withdraw");if(!r.length)return;if(r.some(a=>a.value!=="content-request/1"))throw Error("REFUSE\xB7wire unsupported content transport");let o=s((a,c)=>{let l=e.filter(f=>f.scope===a&&f.measure===c&&f.role==="writes"&&f.value!=="withdraw");if(!l.length||new Set(l.map(f=>f.value)).size!==1)throw Error(`REFUSE\xB7transport ${t} missing or conflicting ${a}`);return l[0]},"one")(`transport/${t}`,"id").value;if(!o)throw Error(`REFUSE\xB7transport ${t} has no mechanism`);let i=s((a,c)=>{let l=e.filter(d=>d.scope===a&&d.measure===c&&d.role==="writes"&&d.value!=="withdraw");if(!l.length)throw Error(`REFUSE\xB7transport ${t} missing ${a}`);let f=ne(0,1/0),u=l.reduce((d,p)=>{let h=p.form==="interval"?Ce("interval",p.value??""):void 0;if(!h||h.kind!=="interval"||h.lo===null||h.lo<0||h.hi===null||!Number.isSafeInteger(h.hi)||h.hi<=0||h.lo>h.hi)throw Error(`REFUSE\xB7transport ${t} invalid ${a}`);return f.meet(d,{lo:h.lo,hi:h.hi})},f.top);if(!f.inhabited(u))throw Error(`REFUSE\xB7transport ${t} conflicting ${a}`);return u.hi},"limit");return{name:o,timeoutMs:i("transport/timeout","milliseconds"),responseBytes:i("transport/response-bytes","bytes")}}s(bl,"transportSelection");function wl(e,t,r){let n={protocol:"content-request/1",location:e,digest:t,timeoutMs:r.timeoutMs,responseBytes:r.responseBytes};return JSON.stringify(n)+`
61
+ `}s(wl,"contentRequest");var Td="object";var Le=s((e,t,r=null)=>({kind:e,bits:null,premium:null,degenerate:null,why:t,distributive:r}),"unknown");function Ld(e,t){let r=s(a=>{let[c="",l=""]=a.split(".");return{numerator:BigInt(`${c}${l}`),scale:10n**BigInt(l.length)}},"rational"),n=r(e),o=r(t),i=n.numerator*o.scale-o.numerator*n.scale;return i<0n?-1:i>0n?1:0}s(Ld,"compareDecimal");function vl(e){let t=x(e);if(t.kind!=="fact")return Le("invalid",t.why);let{form:r,value:n,type:o}=t.value.fields;if(o!==void 0)return Le("unsupported","object freedom needs its selected valuation; a configuration estimate cannot measure it");if(r===void 0||n===void 0)return Le("invalid","a declaration must name its form and value");if(n==="withdraw")return Le("inactive","a withdrawal declares no current freedom");if(r==="alphabet"){let i;try{i=M(n)}catch(a){return Le("invalid",a instanceof Error?a.message:String(a))}return i.polarity==="forbid"?Le("complement","the complement names exclusions but declares no universe to count"):{kind:"finite",form:r,bits:new Set(i.members).size,premium:0,degenerate:!0,distributive:!0}}if(r==="interval"){let[i="",a=""]=n.split("..");return i==="*"||a==="*"?Le("unbounded","the interval has an open endpoint and declares no discrete state count",!1):Ld(i,a)>=0?{kind:"finite",form:r,bits:0,premium:0,degenerate:!0,distributive:!0}:Le("continuous","the interval declares no discrete step or state count",!1)}return Le("unsupported",`freedom is not defined here for form ${r}`)}s(vl,"declaredConfig");function qd(e,t="semantic-live@1"){if(!["semantic-live@1","semantic-live@2"].includes(t))throw Error("REFUSE\xB7receipt undeclared semantic input profile");let r=e.filter(a=>a.record==="cell"),n=new Map(r.map(a=>[a.fields.scope,ye(a.fields.scope,Number(a.fields.epoch),[],st(a.fields.restsOn))])),o=s(a=>{let c={...a.fields};for(let l of["sig","by","epoch","expires","repo","shape"])delete c[l];return v(c)},"encode"),i=s((a,c)=>{let l=e.filter(d=>d.record===c&&d.fields.scope===a),f=new Map(l.map(d=>[d.fields.id,d])),u=ue(l.map(d=>({id:d.fields.id,at:Number(d.fields.epoch),...d.fields.takes?{takes:d.fields.takes}:{}}))).map(d=>f.get(d.id));return t==="semantic-live@2"?u.sort((d,p)=>Number(d.fields.epoch)-Number(p.fields.epoch)):u},"acts");return new Map(r.map(a=>{let c=a.fields.scope,l=et(n.get(c),n),f=l.map(g=>r.find(m=>m.fields.scope===g)),u=l.flatMap(g=>i(g,"mark").filter(m=>m.fields.reach==="travels"&&!m.fields.widens)),d=[...i(c,"mark"),...i(c,"claim")],p=[a,...f,...u,...d].map(o),h=[...new Set(p)];return[c,t==="semantic-live@1"?h.sort(w):h]}))}s(qd,"cellInputs");function Dd(e){if(El(e),e.filter(r=>r.scope==="valuation/cells").some(r=>r.value!=="unquantified"))throw Error("REFUSE\xB7valuation cells have an unsupported valuation; no discrete quantum is invented");return{valuation:"unknown"}}s(Dd,"cellReceiptContract");function El(e){let t=e.filter(r=>r.scope==="wire/receipt-inputs");if(t.length!==1||!["semantic-live@1","semantic-live@2"].includes(t[0].value))throw Error("REFUSE\xB7receipt wire/receipt-inputs has no admitted semantic input contract");return t[0].value}s(El,"cellInputProfile");var zd=s(e=>e.map(t=>"CELL "+JSON.stringify(t)),"renderCells");export{Sl as library0_answers,ts as library0_coarsen,Ao as library0_contracts,Qe as library0_coordinate,Fo as library0_covers,Io as library0_exclusive,Rl as library0_foldRegion,ht as library0_key,Co as library0_outranks,gt as library0_passes,Sr as library0_point,he as library0_region,qe as library0_resolution,Ol as library0_retracted,_l as library0_size,Il as library0_sufficientResolution,kl as library0_verified,le as library0_within,da as library10_assertCapsuleDescriptor,la as library10_capsuleDescriptor,Xl as library10_capsuleOffers,Xr as library10_providerFields,fa as library10_providerInputRegions,pa as library10_providerInputs,Et as library10_readSemanticStanding,ua as library10_readStanding,be as library10_semanticStandingBytes,Yr as library10_shadowAt,Vr as library10_shadowProfile,Je as library10_standingBytes,Yl as library10_toposStanding,El as library11_cellInputProfile,qd as library11_cellInputs,Dd as library11_cellReceiptContract,zd as library12_renderCells,Ve as library13_isWalkHeader,yd as library13_readForeignWalk,fi as library13_readWalkHeaders,hd as library13_readWalkPayload,md as library13_walkAt,pd as library13_walkAuthority,gd as library13_walkHeaders,Nn as library13_walkInventory,fd as library13_walkOrigin,ui as library13_walkPayload,Pn as library13_walkProjection,bd as library13_walkSelection,di as library13_walkSnapshot,nl as library14_CAPSULE,Ot as library14_ENVELOPE,xr as library14_EXTENSION,rl as library14_LOCK,Td as library14_OBJECT_VIEW,Te as library14_PLACE_ACT_CONTEXT,re as library14_PROTOCOL,ol as library14_RECEIPTS,eo as library14_actBytes,Bi as library14_actIdentity,to as library14_actResultOf,_c as library14_actResultProfile,M as library14_alphabet,yl as library14_assertReaderInputs,vt as library14_atResolution,It as library14_authorityAtEpoch,Rn as library14_authorityOf,w as library14_byBytes,v as library14_canonical,il as library14_combine,wl as library14_contentRequest,$r as library14_decimal,wt as library14_fields,gn as library14_formatSignature,Se as library14_fromLine,_a as library14_isKeyClaim,Oa as library14_isWireClaim,ee as library14_matches,Na as library14_namesAt,al as library14_objectHistory,vr as library14_originContextBytes,x as library14_parse,oa as library14_parseForSigning,Re as library14_parseSignature,mt as library14_placeActContextBytes,wo as library14_placeActReceiptsOf,Er as library14_placeReceiptBytes,ll as library14_publicLock,cl as library14_publicationOf,Dt as library14_readPlaceActContext,hl as library14_readerAllowsEmpty,gl as library14_readerLifetime,_o as library14_recordKind,Br as library14_requirement,st as library14_restCoordinates,ja as library14_roleAt,Ca as library14_roleClaimsOf,pe as library14_signedBytes,hn as library14_signedFieldsOf,ul as library14_signerRequestBytes,fl as library14_signerResponseBytes,pl as library14_signerResponseOf,ml as library14_signerSelection,Fa as library14_signersOf,rt as library14_steps,bl as library14_transportSelection,sl as library14_validateObjectContext,vo as library14_verifyOriginalAtAuthorityContext,zt as library14_verifyPlaceActContext,pn as library14_weakest,xn as library14_windowAt,_t as library14_wireAt,fs as library1_FORMS,Uo as library1_FORM_IMPLEMENTATIONS,Fe as library1_alphabetForm,kr as library1_alphabets,j as library1_continuousForm,ne as library1_intervals,Ze as library1_ladderForm,Ee as library1_latticeForm,Cr as library2_amplitude,Ss as library2_bites,Ms as library2_budget,qo as library2_cancels,ye as library2_cell,Wo as library2_choose,yt as library2_coherence,Ao as library2_contracts,Os as library2_converge,Qe as library2_coordinate,Fo as library2_covers,Ls as library2_decohere,Lo as library2_disagree,Bs as library2_distinct,Ps as library2_disturbance,Ht as library2_encounter,_s as library2_endsBeforeNow,Ts as library2_evolve,Io as library2_exclusive,Bo as library2_foldIn,Cs as library2_fragility,Is as library2_fringes,Do as library2_interfere,vs as library2_join,ht as library2_key,ws as library2_laminar,hs as library2_latest,ue as library2_live,js as library2_looksLeft,De as library2_mark,ie as library2_meet,Ir as library2_meetAt,Ar as library2_observe,To as library2_origins,bs as library2_pairs,xe as library2_parts,gt as library2_passes,$s as library2_pay,Nr as library2_phase,Js as library2_play,Sr as library2_point,Jt as library2_potential,ks as library2_present,Ns as library2_price,Es as library2_refine,he as library2_region,xs as library2_require,qe as library2_resolution,et as library2_restOf,Rs as library2_restingOn,Us as library2_sameObject,As as library2_seenAs,Hs as library2_selfFold,Fr as library2_sign,ps as library2_state,ys as library2_turned,le as library2_within,_r as library2_witnessesIn,Ks as library3_compareEvidence,Gs as library3_keyClassFor,Vs as library3_verdictDemand,Kl as library4_counted,Qo as library4_declarationOf,Vo as library4_found,Kt as library4_handed,Ml as library4_lang,Pl as library4_listed,Tr as library4_of,Bl as library4_placeOf,Gl as library4_readers,Wl as library4_readsOf,Vl as library4_receiptShell,Ul as library4_receipts,Tl as library4_regionLines,Jl as library4_shell,Yo as library4_value,ro as library5_ACTION_RECEIPT_PROFILE,Xn as library5_ATTRIBUTED_ORIGIN_PROFILE,no as library5_AUTHENTICATED_LINK_PROFILE,Vn as library5_AUTHORITY_CARD_PROFILE,dr as library5_CI_FORM_PROFILE,io as library5_GOVERNANCE_RECORD_PROFILE,Zt as library5_LOCATION_REFERENCE_PROFILE,or as library5_M0_MEASURE_PROFILE,er as library5_MODULE_INVENTORY_PROFILE,Ai as library5_PHYSICAL_LINES_MODEL,Kn as library5_PHYSICAL_LINES_PROFILE,so as library5_PORTABLE_BIRTH_PROFILE,fo as library5_PROFILE_COMPOSITION_PROFILE,Oi as library5_PROJECTION_CHAIN_MODEL,Hn as library5_PROJECTION_CHAIN_PROFILE,fr as library5_READING_WITNESS_PROFILE,mo as library5_REFERENCE_PROJECTION_PROFILE,ho as library5_REFUSAL_CATALOG_PROFILE,Un as library5_REGION_READING_PROFILE,cr as library5_REGISTRY_PLACE_PROFILE,nr as library5_SOURCE_CARD_PROFILE,co as library5_SOURCE_EXHAUSTION_PROFILE,Qn as library5_WRITTEN_REFUSAL_PROFILE,hr as library5_actionStatementBytes,Jc as library5_answer,Sc as library5_authenticateOrigin,Ec as library5_authorityCardAnswer,ji as library5_authorityCardStatement,sn as library5_checkCommandPort,Ft as library5_checkLocatedReference,Xt as library5_commandRequest,an as library5_commandResponse,it as library5_composePolicy,qi as library5_decodeActionLink,Bt as library5_decodeActionReceipt,Zn as library5_decodeAttributedOrigin,Yn as library5_decodeAuthorityCard,bi as library5_decodeCiDeclaration,Di as library5_decodeGovernanceRecord,ai as library5_decodeInventoryRow,Ke as library5_decodeLocatedReference,Wa as library5_decodeM0Measure,zi as library5_decodePortableBirth,uo as library5_decodeProfileComposition,pr as library5_decodeReadingWitness,Hi as library5_decodeReferenceProjection,Ki as library5_decodeRefusalCatalog,Tn as library5_decodeRegistryEntry,dt as library5_decodeSourceCard,Ji as library5_decodeSourceExhaustion,kc as library5_decodeWrittenRefusal,oo as library5_encodeActionLink,pt as library5_encodeActionReceipt,gr as library5_encodeAttributedOrigin,mr as library5_encodeAuthorityCard,Wn as library5_encodeCiDeclaration,Tt as library5_encodeGovernanceRecord,tr as library5_encodeInventoryRow,Ge as library5_encodeLocatedReference,li as library5_encodeM0Measure,ao as library5_encodePortableBirth,po as library5_encodeProfileComposition,Mt as library5_encodeReadingWitness,go as library5_encodeReferenceProjection,br as library5_encodeRefusalCatalog,Ka as library5_encodeRegionReading,jt as library5_encodeRegistryEntry,lt as library5_encodeSourceCard,lo as library5_encodeSourceExhaustion,Mi as library5_encodeWrittenRefusal,tn as library5_foldedEvidence,Ac as library5_inspectActionReceipt,Rc as library5_inspectAttributedOrigin,vc as library5_inspectAuthorityCard,rc as library5_inspectCiDeclaration,Nc as library5_inspectGovernanceRecord,jc as library5_inspectGroupChange,_n as library5_inspectLocatedReference,ir as library5_inspectM0Measure,Pc as library5_inspectPortableBirth,Tc as library5_inspectProfileComposition,pc as library5_inspectReadingWitness,qc as library5_inspectReferenceProjection,Qa as library5_inspectRegistryEntry,Nt as library5_inspectSourceCard,Uc as library5_inspectSourceExhaustion,un as library5_inspectionSelection,An as library5_inventoryBytes,La as library5_inventoryDiff,Ad as library5_listen,at as library5_locatedReferenceIdentity,zc as library5_lookupRefusal,Ja as library5_m0MeasureRefines,uc as library5_measureProjectionChain,Ta as library5_moduleInventory,Fd as library5_observed,on as library5_originRegion,Pi as library5_originStatement,zr as library5_placeInputs,Gr as library5_placeRequirements,Rt as library5_policyTransition,ni as library5_programInputs,fn as library5_programsOf,Ma as library5_publicationCoverage,bc as library5_readPhysicalLines,Ga as library5_readRegions,Hr as library5_readReleaseDelivery,qr as library5_readingIdentity,ot as library5_readingIdentityBytes,Yt as library5_readingReceiptBytes,Dr as library5_readingReceiptIdentity,Ii as library5_readingWitnessStatementBytes,Wc as library5_refusalCatalogIdentity,hi as library5_registryEntryBytes,Za as library5_registryLines,cn as library5_releaseSuccessors,Pa as library5_renderPrograms,en as library5_renderWriter,Cd as library5_respond,rn as library5_responseIdentity,Nd as library5_responsesOf,nn as library5_snapshotAccess,xt as library5_snapshotIdentity,Da as library5_sourceCardRefines,Zr as library5_unionReadings,dn as library5_vacuityOf,Cc as library5_verifyActionLink,Li as library5_verifyActionReceipt,ln as library5_weightOf,Wr as library5_withPlaceInputs,Te as library6_PLACE_ACT_CONTEXT,M as library6_alphabet,vt as library6_atResolution,w as library6_byBytes,v as library6_canonical,sn as library6_checkCommandPort,Xt as library6_commandRequest,an as library6_commandResponse,it as library6_composePolicy,wt as library6_fields,tn as library6_foldedEvidence,gn as library6_formatSignature,un as library6_inspectionSelection,vr as library6_originContextBytes,on as library6_originRegion,x as library6_parse,Re as library6_parseSignature,mt as library6_placeActContextBytes,wo as library6_placeActReceiptsOf,zr as library6_placeInputs,Er as library6_placeReceiptBytes,Gr as library6_placeRequirements,Rt as library6_policyTransition,Dt as library6_readPlaceActContext,Hr as library6_readReleaseDelivery,Et as library6_readSemanticStanding,qr as library6_readingIdentity,ot as library6_readingIdentityBytes,Yt as library6_readingReceiptBytes,Dr as library6_readingReceiptIdentity,cn as library6_releaseSuccessors,en as library6_renderWriter,Br as library6_requirement,rn as library6_responseIdentity,be as library6_semanticStandingBytes,Yr as library6_shadowAt,Vr as library6_shadowProfile,pe as library6_signedBytes,hn as library6_signedFieldsOf,nn as library6_snapshotAccess,xt as library6_snapshotIdentity,rt as library6_steps,Zr as library6_unionReadings,dn as library6_vacuityOf,vo as library6_verifyOriginalAtAuthorityContext,zt as library6_verifyPlaceActContext,ln as library6_weightOf,Wr as library6_withPlaceInputs,Zc as library7_ALPHABETS,Qi as library7_INTERVALS,qn as library7_alphabetOfForm,Ct as library7_budgetForm,tl as library7_configurationValues,vl as library7_declaredConfig,Hc as library7_distributionForm,el as library7_idsOf,Gc as library7_intervalForm,Kc as library7_ladderOfForm,Vc as library7_latticeOfForm,Yc as library7_phaseForm,Xc as library7_rankForm,Zi as library7_spanOf,Qc as library7_stretchForm,$a as library7_violationsIn,sr as library9_receiptProjection};