@panphora/clayjs 1.12.2 → 1.13.1
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.
- package/dist/clay.standalone.js +3235 -2997
- package/docs/guide.md +1847 -0
- package/entries/sap.js +6 -6
- package/package.json +3 -1
- package/packed-contract.json +1 -1
- package/src/lib/unsaved-state.js +11 -2
- package/src/live/checkpoint.js +7 -0
- package/src/live/fast-lane.js +24 -10
- package/src/live/local-lane.js +14 -7
- package/src/live/moves.js +11 -0
- package/src/live/server-lane.js +2 -1
- package/src/live/store.js +32 -1
- package/src/page/binding.js +647 -0
- package/src/page/inline.js +113 -0
- package/src/page/model.js +49 -21
- package/src/page/replay.js +578 -0
- package/src/page/schema.js +1 -1
- package/src/plugins/live.js +49 -2
- package/src/plugins/visitor-drafts/prompt.js +4 -6
- package/src/vendor/hypercms.vendor.js +20 -20
package/entries/sap.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// GENERATED — do not edit. Vendored from sapjs/dist/sap.min.js via sapjs
|
|
2
2
|
// `npm run copy-to-clayjs`. Edit the sapjs source and re-run.
|
|
3
3
|
(function () {
|
|
4
|
-
var Sap=(()=>{var ne=Object.defineProperty;var
|
|
5
|
-
`+(e[0]==="W"?"sap \u26A0 ":"sap \u2717 ")+e+" "+o];return a.push(` at ${s.el}${s.attr?` \u2014 ${s.attr}="${s.expr??""}"`:""}`),s.problem&&a.push(` problem: ${s.problem}`),s.didYouMean&&a.push(` did you mean: ${s.didYouMean}`),s.fix&&a.push(` fix: ${s.fix}`),console.error(a.join(`
|
|
6
|
-
`)),s}error(e,r,n={}){let o=this.block(e,r,n);return this.errors.push(o),o}warn(e,r,n={}){let o=this.block(e,r,n);return this.warnings.push(o),o}report(){return{ok:this.errors.length===0&&!this.halted,app:this.appName,halted:this.halted,haltReason:this.haltReason,errors:this.errors.slice(),warnings:this.warnings.slice()}}};function ut(t,e){t&&t.getAttribute("sap-error")!==e&&t.setAttribute("sap-error",e)}function Ft(t){t&&t.hasAttribute("sap-error")&&t.removeAttribute("sap-error")}function Nt(t,e){let r=null,n=3;for(let o of e){let s=
|
|
7
|
-
${t}`:`"use strict"; return (${t});`;n={fn:new Function(...
|
|
4
|
+
var Sap=(()=>{var ne=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var kn=Object.prototype.hasOwnProperty;var $n=(t,e)=>{for(var r in e)ne(t,r,{get:e[r],enumerable:!0})},_n=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Sn(e))!kn.call(t,o)&&o!==r&&ne(t,o,{get:()=>e[o],enumerable:!(n=xn(e,o))||n.enumerable});return t};var Tn=t=>_n(ne({},"__esModule",{value:!0}),t);var Sr={};$n(Sr,{Sap:()=>O,default:()=>xr,mount:()=>vn,mountAll:()=>te,runtime:()=>mt});function Ee(t){let e=!1,r=new Set,n=[];function o(l){l&&(n.push(l),n.length>8&&n.shift())}function s(l,w){o(w),!l._broken&&(r.add(l),!e&&(e=!0,queueMicrotask(a)))}function a(){e=!1;let l=[...r];r.clear();for(let w of l)k(w)}function k(l,w=!1){if(!l._broken){if(l._passes=(l._passes||0)+1,l._passes>50){l._broken=!0,l._breakerRing=n.slice(),t(l,{breaker:!0});return}l._resetArmed||(l._resetArmed=!0,setTimeout(()=>{l._passes=0,l._resetArmed=!1},0)),t(l,w?{full:!0}:{})}}function $(l,w){o(w),k(l,!0)}function A(l){l._broken=!1,l._passes=0}return{schedule:s,runNow:$,rearm:A,ring:n}}var re={E01:{slug:"foreign-dialect",behavior:"HALT"},E02:{slug:"moustaches-in-text",behavior:"HALT"},E04:{slug:"duplicate-declaration",behavior:"HALT"},E05:{slug:"reserved-name",behavior:"HALT"},E06:{slug:"global-html-name",behavior:"HALT"},E07:{slug:"calc-cycle",behavior:"ERR"},E08:{slug:"expression-syntax",behavior:"HALT"},E10:{slug:"orphan-item",behavior:"HALT"},E12:{slug:"unknown-state-key",behavior:"ERR"},E15:{slug:"write-to-undeclared-key",behavior:"ERR"},E16:{slug:"write-to-computed-field",behavior:"ERR"},E17:{slug:"unresolvable-action-target",behavior:"HALT"},E18:{slug:"paint-on-form-control",behavior:"HALT"},E20:{slug:"bind-on-non-control",behavior:"HALT"},E22:{slug:"format-type",behavior:"ERR"},E24:{slug:"runtime-expression-throw",behavior:"ERR"},E26:{slug:"circuit-breaker",behavior:"HALT"},E30:{slug:"attr-on-bound-control",behavior:"HALT"},E31:{slug:"password-without-transient",behavior:"HALT"},E32:{slug:"file-bind",behavior:"HALT"},E33:{slug:"dialog-state-open",behavior:"HALT"},E34:{slug:"transient-persist-collision",behavior:"HALT"},E35:{slug:"presence-state-misuse",behavior:"HALT"},E40:{slug:"each-not-array",behavior:"ERR"},E41:{slug:"each-bad-key",behavior:"ERR"},E42:{slug:"each-template",behavior:"ERR"},E43:{slug:"bind-in-each-row",behavior:"ERR"},W03:{slug:"unknown-colon-attribute",behavior:"WARN"},W04:{slug:"expression-in-when",behavior:"WARN"},W30:{slug:"nonzero-mount-writes",behavior:"WARN"},W31:{slug:"detail-dialog-saved-open",behavior:"WARN"}},bt=["disabled","readonly","required","checked","selected","multiple","open","inert","autofocus","novalidate","hidden"],Tt=new Set(["title","style","hidden","lang","dir","translate","class","id","nonce","autofocus","tabindex","contenteditable","spellcheck","draggable","role","slot","part","name","value","type","itemscope","itemtype","itemid","itemprop","itemref"]),It=new Set(["sap","scope","items","item","template","bind","calc","text","show","attr","set","trigger","move","sort","detail","each","effect","invalid","confirm","transient","default","persist","sortable","editmode"]);function Ot(t){if(!t||t.nodeType!==1)return"?";if(t.id)return`${t.tagName.toLowerCase()}#${t.id}`;let e=[],r=t,n=0;for(;r&&r.nodeType===1&&n<4;){let o=r.tagName.toLowerCase();if(r.hasAttribute("sap"))o+="[sap]";else if(r.parentElement){let s=0,a=0;for(let k=r.parentElement.firstElementChild;k;k=k.nextElementSibling)k.tagName===r.tagName&&(s++,k===r&&(a=s));s>1&&(o+=`:nth-of-type(${a})`)}if(e.unshift(o),r.hasAttribute("sap"))break;r=r.parentElement,n++}return e.join(" > ")}function ve(t){let e=t.toLowerCase();return/^x-text$|^x-html$/.test(e)?'use text="state.x" (Sap paints text only)':/^x-show$|^v-show$|^v-if$/.test(e)?'use show="expr" (toggles native hidden)':/^x-model$|^v-model$/.test(e)?'use bind="field"':/^@|^x-on:|^v-on:|^on:/.test(e)?"use native onclick + Sap(this) (no event directive)":/^:|^x-bind:class$|^v-bind:class$/.test(e)?'use class:NAME="expr" or attr:NAME="expr"':/^x-for$|^v-for$/.test(e)?'use items="name" on the container and item template on the row':/^x-data$/.test(e)?"declare state with state= / bind / items (no JS state object)":/^x-init$/.test(e)?"use a <script> or onclick + Sap(this)":/^bind:/.test(e)?'use bind="field"; one-way paint is attr:NAME="expr"':/^x-/.test(e)||/^v-/.test(e)?"this is a foreign-dialect attribute; Sap has no x-/v- attributes":null}var ht=class{constructor(e){this.appName=e,this.errors=[],this.warnings=[],this.halted=!1,this.haltReason=null}block(e,r,n={}){let o=(re[e]||{}).slug||"error",s={code:e,slug:o,el:Ot(r),attr:n.attr||null,expr:n.expr||null,key:n.key||null,problem:n.problem||"",didYouMean:n.didYouMean||null,fix:n.fix||null,phase:n.phase||"runtime"},a=[`
|
|
5
|
+
`+(e[0]==="W"?"sap \u26A0 ":"sap \u2717 ")+e+" "+o];return a.push(` at ${s.el}${s.attr?` \u2014 ${s.attr}="${s.expr??""}"`:""}`),s.problem&&a.push(` problem: ${s.problem}`),s.didYouMean&&a.push(` did you mean: ${s.didYouMean}`),s.fix&&a.push(` fix: ${s.fix}`),(e[0]==="W"?console.warn:console.error)(a.join(`
|
|
6
|
+
`)),s}error(e,r,n={}){let o=this.block(e,r,n);return this.errors.push(o),o}warn(e,r,n={}){let o=this.block(e,r,n);return this.warnings.push(o),o}report(){return{ok:this.errors.length===0&&!this.halted,app:this.appName,halted:this.halted,haltReason:this.haltReason,errors:this.errors.slice(),warnings:this.warnings.slice()}}};function ut(t,e){t&&t.getAttribute("sap-error")!==e&&t.setAttribute("sap-error",e)}function Ft(t){t&&t.hasAttribute("sap-error")&&t.removeAttribute("sap-error")}function Nt(t,e){let r=null,n=3;for(let o of e){let s=Nn(t,o);s<n&&(n=s,r=o)}return r}function Nn(t,e){let r=t.length,n=e.length,o=Array.from({length:r+1},(s,a)=>[a,...new Array(n).fill(0)]);for(let s=0;s<=n;s++)o[0][s]=s;for(let s=1;s<=r;s++)for(let a=1;a<=n;a++)o[s][a]=Math.min(o[s-1][a]+1,o[s][a-1]+1,o[s-1][a-1]+(t[s-1]===e[a-1]?0:1));return o[r][n]}var Ln=new Set(bt),Cn={readonly:"readOnly",novalidate:"noValidate"},Rn=0,xe=new WeakMap;function Bt(t,e="sap"){let r=t.getAttribute("data-id");if(r)return r;if(t.id)return t.id;let n=xe.get(t);return n||(n=`${e}-${(Rn++).toString(36)}`,xe.set(t,n)),n}function Se(t,e="row"){for(;;){let r=`${e}-${Math.random().toString(36).slice(2,8)}`;if(!t.getElementById(r)&&!t.querySelector(`[data-id="${r}"]`))return r}}function Dn(t){return t.hasAttribute("scope")||t.hasAttribute("items")||t.hasAttribute("detail")||t.hasAttribute("each")}function Mn(t){return t.tagName==="TEMPLATE"||t.hasAttribute("sap-ignore")||t.hasAttribute("template")||t.hasAttribute("cms-template")}function et(t,e){for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(Mn(n))return;let o=Dn(n);if(e(n,o),!o)for(let s=n.firstElementChild;s;s=s.nextElementSibling)r(s)}}function Q(t){let e=t;for(;e;){if(e.hasAttribute("sap")||e.hasAttribute("scope")||e.hasAttribute("item")||e.hasAttribute("detail"))return e;e=e.parentElement}return null}function lt(t){for(let e=t;e&&e.nodeType===1;e=e.parentElement){if(e._sapEachRow)return e;if(e.hasAttribute("item")||e.hasAttribute("sap"))return null}return null}function Wt(t){let e=t;for(;e;){if(e.hasAttribute("detail")||e.hasAttribute("item"))return e;e=e.parentElement}return null}function Lt(t){let e=t;for(;e;){if(e.hasAttribute("detail"))return e;e=e.parentElement}return null}function ft(t,e){if(t.hasAttribute("item")&&t.getAttribute("bind")===e)return t;let r=null;return et(t,n=>{!r&&n.getAttribute("bind")===e&&(r=n)}),r}function gt(t,e){let r=null;return et(t,n=>{!r&&n.getAttribute("items")===e&&(r=n)}),r}function wt(t,e){return!t||t.nodeType!==1||!t.hasAttribute("item")?!1:ft(t,e)||gt(t,e)?!0:V(t.getAttribute("state")||"").some(r=>r.name===e)}function ke(t){let e=t&&t.$el;return e&&e.nodeType===1&&e.isConnected&&e.hasAttribute("item")?e:null}function qt(t){return!!t.closest("form[trigger-add]")}function rt(t){let e=[];for(let r=t.firstElementChild;r;r=r.nextElementSibling)r.hasAttribute("item")&&!r.hasAttribute("template")&&!r.hasAttribute("cms-template")&&e.push(r);return e}function oe(t,e){if(!t||!e)return null;let r=[...t.querySelectorAll(`template[items="${e}"]`)].find(o=>o.closest("[sap]")===t),n=r&&r.content.firstElementChild;return n&&n.hasAttribute("item")?n:null}function Vt(t){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(e.hasAttribute("item")&&e.hasAttribute("template"))return e;return oe(t.closest("[sap]"),t.getAttribute("items"))}function V(t){let e=[];if(!t)return e;for(let r of t.trim().split(/\s+/)){if(!r)continue;let n=r,o,s=n.indexOf("=");s>=0&&(o=n.slice(s+1),n=n.slice(0,s));let a=n.split(":"),k=a[0],$="string",A=!1;for(let N of a.slice(1))N==="num"?$="num":N==="bool"?$="bool":N==="presence"?$="presence":N==="transient"&&(A=!0);let l=k,w=l.startsWith("data-")&&l.length>5?l.slice(5).replace(/-([a-z])/g,(N,P)=>P.toUpperCase()):l;e.push({name:w,attr:l,type:$,default:o,transient:A})}return e}function ct(t,e){if(e==="num"){if(t==null||t==="")return 0;let r=Number(t);return Number.isNaN(r)?0:r}return e==="bool"?t==="true"||t===""||t==="1":t??""}function ie(t,e){return e==="bool"?t?"true":"false":t==null?"":String(t)}function se(t,e){return Ln.has(e)&&typeof t[Cn[e]||e]=="boolean"}function yt(t,e){return e.type==="presence"||e.type!=="num"&&se(t,e.attr||e.name)}function Ct(t){return t.default!=null?t.default:t.type==="num"?"0":t.type==="bool"?"false":""}function $e(t,e){let r=e.attr||e.name;if(yt(t,e))return t.hasAttribute(r);let n=t.getAttribute(r);return ct(n??Ct(e),e.type)}function _e(t,e){return yt(t,e)?e.default!=null?ct(e.default,"bool"):!1:ct(Ct(e),e.type)}function Rt(t,e,r){let n=e.attr||e.name;if(yt(t,e)){r?t.hasAttribute(n)||t.setAttribute(n,""):t.hasAttribute(n)&&t.removeAttribute(n);return}t.setAttribute(n,ie(r,e.type))}function zt(t,e){let r=e.attr||e.name,n=t._sapTransient||(t._sapTransient={});if(!(e.name in n)){let o=t.getAttribute(r);o==null&&(o=Ct(e)),n[e.name]=ct(o,e.type)}return t.hasAttribute(r)&&t.removeAttribute(r),n[e.name]}function Dt(t,e,r){let n=e.attr||e.name;(t._sapTransient||(t._sapTransient={}))[e.name]=r,t.hasAttribute(n)&&t.removeAttribute(n)}function Mt(t,e,r){let n=String(r).split("."),o=n[n.length-1];if(n.length===1){let k=Pn(e,o);return k||(t.getAttribute("items")===o?t:t.querySelector(`[items="${o}"]:not(template)`))}let s=n[n.length-2],a=[...t.querySelectorAll(`[scope="${s}"]`)].find(k=>gt(k,o));return a?gt(a,o):null}function Pn(t,e){let r=Q(t);for(;r;){if(r.getAttribute("items")===e)return r;let n=gt(r,e);if(n)return n;r=Q(r.parentElement)}return null}function Z(t){if(typeof t=="number")return t;if(t==null||t==="")return 0;let e=Number(typeof t=="string"?t.replace(/[$,%\s]/g,""):t);return Number.isNaN(e)?0:e}function Ht(t,e){return Array.isArray(t)?e==null?t:t.map(r=>typeof e=="function"?e(r):r?.[e]):[]}function ae(t,e){return Ht(t,e).reduce((r,n)=>r+Z(n),0)}function Te(t,e){return Array.isArray(t)?e==null?t.length:t.reduce((r,n)=>r+(e(n)?1:0),0):0}function Ne(t,e){let r=Ht(t,e);return r.length?ae(t,e)/r.length:0}function Le(t,e){let r=Ht(t,e).filter(n=>n!=null&&n!=="");return r.length?r.every(n=>typeof n=="number"||!Number.isNaN(Number(n)))?Math.min(...r.map(Number)):r.reduce((n,o)=>String(n)<=String(o)?n:o):0}function Ce(t,e){let r=Ht(t,e).filter(n=>n!=null&&n!=="");return r.length?r.every(n=>typeof n=="number"||!Number.isNaN(Number(n)))?Math.max(...r.map(Number)):r.reduce((n,o)=>String(n)>=String(o)?n:o):0}function Re(t,e,r){let n=Z(t)===1?e:r??e+"s";return`${t} ${n}`}function De(t,e){let r=new Date(t),n=new Date(e);return Number.isNaN(+r)||Number.isNaN(+n)?0:Math.round((n-r)/864e5)}function nt(t){return typeof t=="number"?t:Number(t)}var At={usd:t=>"$"+nt(t).toLocaleString("en-US",{maximumFractionDigits:0}),usd2:t=>"$"+nt(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),pct:t=>Math.round(nt(t))+"%",pct1:t=>nt(t).toFixed(1)+"%",int:t=>Math.round(nt(t)).toLocaleString("en-US"),num:t=>nt(t).toLocaleString("en-US"),num2:t=>nt(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),compact:t=>nt(t).toLocaleString("en-US",{notation:"compact"}),date:t=>{let e=new Date(t);return Number.isNaN(+e)?String(t):e.toLocaleDateString("en-US")},clock:t=>{let e=nt(t),r=Math.floor(e/100),n=r%10,o=Math.floor(r/10)%60;return`${Math.floor(r/600)}:${String(o).padStart(2,"0")}.${n}`}},In=new Set(["usd","usd2","pct","pct1","int","num","num2","compact","clock"]);function Me(t,e){if(!t)return e==null?"":String(e);let r=At[t];if(typeof r!="function"){let n=new Error(`unknown format "${t}"`);throw n.sapCode="E22",n}if(In.has(t)){let n=typeof e=="number"?e:Number(e);if(!Number.isFinite(n)){let o=new Error(`format "${t}" received ${typeof e=="string"?`"${e}"`:e}`);throw o.sapCode="E22",o}}return r(e)}var On=["state","item","el","root","fmt","num","sum","count","avg","min","max","plural","days"],jt=new Map,Pe=/\bstate\.([a-z][a-z0-9_]*)/g,Ie=/\bitem\.([a-z][a-z0-9_]*)/g;function Fn(t){let e=new Set,r=new Set,n;for(Pe.lastIndex=0;n=Pe.exec(t);)e.add(n[1]);for(Ie.lastIndex=0;n=Ie.exec(t);)r.add(n[1]);return{state:e,item:r}}function q(t,e=!1){let r=(e?"!":"")+t,n=jt.get(r);if(n)return n;jt.size>512&&jt.clear();try{let o=e?`"use strict";
|
|
7
|
+
${t}`:`"use strict"; return (${t});`;n={fn:new Function(...On,o),src:t,statement:e,deps:Fn(t),error:null}}catch(o){n={fn:null,src:t,statement:e,deps:{state:new Set,item:new Set},error:o}}return jt.set(r,n),n}function Et(t,e){return dt(t,e.state,e.item,e.el??null,e.root)}function dt(t,e,r,n,o){if(t.error)throw t.error;return t.fn(e,r,n,o,At,Z,ae,Te,Ne,Le,Ce,Re,De)}function Oe(t){let e=new Map;for(let a of t)e.set(a.name,a);let r=[],n=new Map,o=[];function s(a){let k=n.get(a.name);if(k!==1){if(k===0){let $=[...o.slice(o.indexOf(a.name)),a.name].join(" -> "),A=new Error(`calc: cycle: ${$}`);throw A.sapCode="E07",A.cycle=$,A}n.set(a.name,0),o.push(a.name);for(let $ of a.entry.deps.state){let A=e.get($);A&&A!==a&&s(A)}for(let $ of a.entry.deps.item){let A=e.get($);A&&A!==a&&s(A)}o.pop(),n.set(a.name,1),r.push(a)}}for(let a of t)s(a);return r}var Pt=0,pt=null,Be=!0,Gt=!1;function We(){Pt++}function qe(t){let e=Gt;return pt?ce(pt.takeRecords()):Be&&Bn(),Gt=!!pt&&t.getRootNode()===document,e}function Ve(t){Gt=t}function ue(){pt&&ce(pt.takeRecords())}function Bn(){if(typeof document>"u"||typeof MutationObserver!="function"){Be=!1;return}pt=new MutationObserver(ce),pt.observe(document,{attributes:!0,childList:!0,subtree:!0})}function ce(t){for(let e of t)if(e.type==="attributes")e.target._sapPlan&&(e.target._sapPlan=null);else for(let r of e.addedNodes)r.nodeType===1&&ze(r)}function ze(t){t._sapPlan&&(t._sapPlan=null);for(let e=t.firstElementChild;e;e=e.nextElementSibling)ze(e)}function vt(t){if(!Gt)return Fe(t);let e=t._sapPlan;return e&&e.gen===Pt?e:t._sapPlan=Fe(t)}function Fe(t){let e={gen:Pt,inert:t.tagName==="TEMPLATE",template:!1,item:!1,scope:!1,items:!1,detail:!1,each:!1,boundary:null,bind:null,transient:!1,decls:null,calcs:null,paints:null,effects:null,invalids:null};for(let r of t.attributes){let n=r.name,o=r.value,s=n.indexOf(":");if(s<0){switch(n){case"sap-ignore":e.inert=!0;break;case"cms-template":e.inert=!0;break;case"template":e.inert=!0,e.template=!0;break;case"item":e.item=!0;break;case"scope":e.scope=!0;break;case"items":e.items=!0;break;case"detail":e.detail=!0;break;case"each":e.each=!0;break;case"bind":e.bind=o;break;case"transient":e.transient=!0;break;case"state":e.decls=V(o);break;case"text":(e.paints||(e.paints=[])).push({kind:"text",fmt:null,entry:q(o)});break;case"show":(e.paints||(e.paints=[])).push({kind:"show",entry:q(o)});break;case"effect":(e.effects||(e.effects=[])).push({entry:q(o,!0)});break;case"invalid":(e.invalids||(e.invalids=[])).push({entry:q(o)});break}continue}let a=n.slice(0,s),k=n.slice(s+1);switch(a){case"calc":(e.calcs||(e.calcs=[])).push({name:k,entry:q(o)});break;case"text":(e.paints||(e.paints=[])).push({kind:"text",fmt:k,entry:q(o)});break;case"attr":(e.paints||(e.paints=[])).push({kind:"attr",arg:k,entry:q(o)});break;case"class":(e.paints||(e.paints=[])).push({kind:"class",arg:k,entry:q(o)});break;case"css":(e.paints||(e.paints=[])).push({kind:"css",arg:k,entry:q(o)});break;case"show-when":case"option":(e.paints||(e.paints=[])).push({kind:"when",match:"show",field:k,values:o.split("|")});break;case"hide-when":(e.paints||(e.paints=[])).push({kind:"when",match:"hide",field:k,values:o.split("|")});break;case"option-not":(e.paints||(e.paints=[])).push({kind:"when",match:"show-not",field:k,values:o.split("|")});break}}return e.boundary=e.scope?"scope":e.items?"items":e.detail?"detail":e.each?"each":null,qn(e)?Wn():e}var Ut=null;function Wn(){return(!Ut||Ut.gen!==Pt)&&(Ut=Object.freeze({gen:Pt,inert:!1,template:!1,item:!1,scope:!1,items:!1,detail:!1,each:!1,boundary:null,bind:null,transient:!1,decls:null,calcs:null,paints:null,effects:null,invalids:null})),Ut}function qn(t){return!t.inert&&!t.item&&t.boundary===null&&t.bind===null&&!t.transient&&!t.decls&&!t.calcs&&!t.paints&&!t.effects&&!t.invalids}function He(t){return(t.getAttribute("type")||"text").toLowerCase()}function xt(t){let e=t.tagName;if(e==="INPUT"){let r=He(t);r==="checkbox"||r==="radio"?t.checked?t.setAttribute("checked",""):t.removeAttribute("checked"):t.setAttribute("value",t.value);return}if(e==="TEXTAREA"){t.setAttribute("data-value",t.value);return}if(e==="SELECT"){let r=t.options;for(let n=0;n<r.length;n++)r[n].selected?r[n].setAttribute("selected",""):r[n].removeAttribute("selected")}}function je(t,e=t){let r=t.tagName;if(r==="INPUT"){let n=He(t);n==="checkbox"||n==="radio"?e.checked?t.hasAttribute("checked")||t.setAttribute("checked",""):t.removeAttribute("checked"):e.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",e.value);return}if(r==="TEXTAREA"){let n=e.value.startsWith(`
|
|
8
8
|
`)?`
|
|
9
|
-
`+e.value:e.value;t.textContent!==n&&(t.textContent=n),t.removeAttribute("data-value");return}if(r==="SELECT"){let n=t.options,o=e.options;for(let s=0;s<n.length;s++)o[s]&&o[s].selected?n[s].hasAttribute("selected")||n[s].setAttribute("selected",""):n[s].removeAttribute("selected")}}function Yt(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function Q(t){if(typeof window>"u")return null;let e=window.clay,r=window.hyperclay;return t==="consent"?e?.confirm||r?.consent||null:e?.[t]||r?.[t]||null}var le=["clay:mutation-ready","hyperclay:mutation-ready"],qn=["clay:sync-applied","hyperclay:livesync-applied"],Vn=["clay:ready","hyperclay:ready"],zn=["clay:route"];function St(t,e,r){let n=null,o=s=>{n!==null&&n!==s.type||(n=s.type,queueMicrotask(()=>{n=null}),r(s))};for(let s of e)t.addEventListener(s,o);return()=>{for(let s of e)t.removeEventListener(s,o)}}function Ue(t){let e=typeof window<"u"&&window.clay&&window.clay.ready;e&&typeof e.then=="function"?e.then(()=>t(),()=>t()):t()}function Xt(t){let e=Q("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function Ge(){let t=Q("consent");return typeof t=="function"?t:null}function Ye(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let r=Q("undo");r&&r.flush&&r.flush();let n=e();if(n&&typeof n.then=="function")throw new Error("Sap.batch fn must be synchronous (it returned a promise)");return r&&r.commitCaptured&&r.commitCaptured(t),n}function Xe(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let s=!1;for(let a of t.apps())a.root.isConnected?t.runNow(a,"platform"):s=!0;s&&(t.pruneDisconnected(),t.remountIfPresent())};St(document,qn,e),St(document,zn,e);let r=!1,n=()=>{},o=()=>{if(r)return!0;let s=Q("undo");if(!s||typeof s.on!="function")return!1;let a=s.on("undo",e);return typeof a!="function"?!1:typeof s.on("redo",e)!="function"?(a(),!1):(r=!0,n(),!0)};if(!o()){let s=St(document,le,o),a=St(document,Vn,o);n=()=>{s(),a()};let k=Q("ready");k&&typeof k.then=="function"&&k.then(o,()=>{})}}function Kt(t){let e=t.tagName;if(e==="INPUT"){let r=(t.getAttribute("type")||"text").toLowerCase();return r==="checkbox"?"checkbox":r==="radio"?"radio":r==="number"||r==="range"?"number":r==="hidden"?"hidden":"text"}return e==="TEXTAREA"?"text":e==="SELECT"?t.multiple?"select-multiple":"select-one":"leaf"}function Hn(t){if(t.validity&&t.validity.badInput)return t.hasAttribute("value")?Number(t.getAttribute("value"))||0:t._sapLastGood??0;if(t.value==="")return 0;let e=Number(t.value);return Number.isNaN(e)?t._sapLastGood??0:(t._sapLastGood=e,e)}function Ke(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return Hn(t);case"select-one":return t.value;case"select-multiple":return[...t.selectedOptions].map(r=>r.value);case"hidden":case"text":return t.value;case"leaf":return t.textContent;default:return t.value}}function Je(t,e,r){switch(e){case"checkbox":t.checked=!!r;break;case"radio":t.checked=String(t.value)===String(r);break;case"number":case"text":case"hidden":t.value=r==null?"":String(r);break;case"select-one":t.value=r==null?"":String(r);break;case"select-multiple":{let n=new Set((Array.isArray(r)?r:[r]).map(String));for(let o of t.options)o.selected=n.has(o.value);break}case"leaf":t.textContent=r==null?"":String(r);break;default:t.value=r==null?"":String(r)}}function fe(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}Xt(t)||xt(t)}function jn(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function de(t,e){return Ke(t,e)}function Qe(t,e,r){Je(t,e,r),fe(t)}function G(t){let e=Kt(t);return{el:t,kind:e,read(){return Ke(t,e)},write(r,n={}){Je(t,e,r),n.noMirror||fe(t),n.silent||jn(t)},mirror(){fe(t)}}}var ot=null,Qt=!1,kt=null;function Ze(t){let e=null;return{kind:"hub",subscribe(r){let n=t.onAnyChange({debounce:0,require:"observed"},r);typeof n=="function"&&(e=n)},suppress(r){t.pause();try{return r()}finally{t.resume()}},teardown(){if(e){try{e()}catch{}e=null}}}}function Un(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(n=>e(Gn(n)));let r=typeof document<"u"&&document.body||typeof document<"u"&&document.documentElement;r&&t.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0})},suppress(e){let r=Q("undo");r&&r.pause&&r.pause();try{return e()}finally{t&&t.takeRecords(),r&&r.resume&&r.resume()}},teardown(){t&&(t.disconnect(),t=null)}}}function Gn(t){let e=[];for(let r of t)if(r.type==="attributes"){let n=r.target;n&&n.nodeType===1&&!Jt(n)&&e.push({type:"attribute",element:n})}else if(r.type==="characterData"){let n=r.target&&r.target.parentElement;n&&!Jt(n)&&e.push({type:"characterData",element:n})}else if(r.type==="childList"){for(let n of r.addedNodes)if(!(n.nodeType!==1||Jt(n))&&(e.push({type:"add",element:n}),n.querySelectorAll))for(let o of n.querySelectorAll("*"))Jt(o)||e.push({type:"add",element:o});for(let n of r.removedNodes)n.nodeType===1&&e.push({type:"remove",element:n,parent:r.target})}return e}function Jt(t){return!!(t.closest&&t.closest("[sap-ignore],[template],[cms-template]"))}function Yn(t,e){t.pruneDisconnected();let r=new Set,n=!1;for(let o of e){let s=o.type==="remove"?o.parent:o.element,a=s&&t.appFor(s);a&&r.add(a),o.type==="add"&&o.element&&o.element.nodeType===1&&o.element.hasAttribute&&o.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(o.element))&&(n=!0)}n&&t.remountIfPresent();for(let o of r)o.root.isConnected&&t.schedule(o,"mutation")}function tn(t){if(ot)return ot.suppress(t);let e=Q("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function pe(t,e){Qt=!0,ot=t,t.subscribe(r=>Yn(e,r))}function me(t){if(Qt||typeof window>"u"||typeof document>"u")return;let e=Q("Mutation");if(e&&typeof e.onAnyChange=="function"){pe(Ze(e),t);return}typeof MutationObserver=="function"&&(pe(Un(),t),kt=St(document,le,function(){let n=Q("Mutation");n&&(kt(),kt=null,ot&&ot.teardown(),Qt=!1,pe(Ze(n),t))}))}function en(){if(ot)try{ot.teardown()}catch{}kt&&typeof document<"u"&&kt(),ot=null,Qt=!1,kt=null}var Xn=new Set(bt);function $t(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),ut(t.root,"loop");return}e.full&&We();let r=qe(t.root);try{tn(()=>Kn(t,e))}finally{Ve(r)}t._viewsChanged&&(t._viewsChanged=!1,t.root.dispatchEvent(new CustomEvent("sap:views-updated",{bubbles:!0})))}function Kn(t,e){let r=t.root,n={},o=[],s=[],a=[],k=[],$=[],A=[],l=[],w=new Set;t.diag.errors=[];let N={root:n,state:n,item:null,ownerEl:r,projection:!1};function P(i,h){let f=h.attr||h.name,g=i.getAttribute(f);return g==null&&(g=Ct(h),$.push({el:i,name:h.name,attr:f,value:ie(ct(g,h.type),h.type)})),ct(g,h.type)}function z(i,h,f){let g=h.decls;if(g)for(let T of g){if(T.transient){f[T.name]=zt(i,T);continue}if(yt(i,T)){f[T.name]=i.hasAttribute(T.attr);continue}f[T.name]=P(i,T)}}function m(i,h,f){let g=h.bind,T=f.item||f.state,I=Kt(i);I==="radio"?(g in T||(T[g]=""),i.checked&&(T[g]=i.value)):T[g]=de(i,I),h.transient&&(i.removeAttribute("value"),i.removeAttribute("checked"))}function d(i,h,f){if(h.calcs){let g=f.item||f.state;for(let T of h.calcs)o.push({owner:g,ownerEl:f.ownerEl,name:T.name,entry:T.entry,def:T,el:i,ctx:f})}if(h.paints)for(let g of h.paints)g.kind==="when"&&w.add(g.field),s.push({def:g,el:i,ctx:f});if(h.effects)for(let g of h.effects)a.push({def:g,el:i,ctx:f});if(h.invalids)for(let g of h.invalids)k.push({def:g,el:i,ctx:f});if(h.bind!=null&&(f.view||f.projection)&&!qt(i)){let g=h.bind;f.view?wt(ke(f.item),g)?(i._sapViewBind="item",s.push({def:{kind:"projection",field:g,from:"item"},el:i,ctx:f})):g in f.state||g in f.root?(i._sapViewBind="drawn",s.push({def:{kind:"projection",field:g,from:"drawn"},el:i,ctx:f})):(i._sapViewBind=null,t.diag.error("E43",i,{attr:"bind",expr:g,problem:`bind="${g}" inside an each row matches no field of the row's record or of the scope the row is drawn in`,fix:"bind a field the record owns (bind, state= or items= on the [item]), or declare it with state= where the list is drawn"})):s.push({def:{kind:"projection",field:g,from:null},el:i,ctx:f})}}function p(i,h,f){Object.defineProperty(i,"$key",{value:Bt(h,"row"),enumerable:!1}),Object.defineProperty(i,"$index",{value:f,enumerable:!1}),Object.defineProperty(i,"$el",{value:h,enumerable:!1})}function y(i,h,f){let g=vt(i);z(i,g,h),i._sapScope=h,!f.projection&&g.bind!=null&&m(i,g,f),d(i,g,f),g.items?M(i,h,f):E(i,h,f)}function E(i,h,f){for(let g=i.firstElementChild;g;g=g.nextElementSibling)S(g,h,f)}function S(i,h,f){let g=vt(i);if(!g.inert){if(g.boundary){g.boundary==="scope"?_(i,h,f):g.boundary==="items"?(d(i,g,f),M(i,h,f)):g.boundary==="detail"?c(i,h,f):(d(i,g,f),l.push({el:i,ctx:f}));return}!f.projection&&!f.view&&g.bind!=null&&m(i,g,f),d(i,g,f);for(let T=i.firstElementChild;T;T=T.nextElementSibling)S(T,h,f)}}function _(i,h,f){let g=i.getAttribute("scope"),T={};h[g]=T;let I={root:f.root,state:T,item:null,ownerEl:i,projection:f.projection};y(i,T,I)}function M(i,h,f){let g=i.getAttribute("items"),T=[];h[g]=T,i._sapList=T;let I=0;for(let W=i.firstElementChild;W;W=W.nextElementSibling){let Y=vt(W);if(!Y.item||Y.template||W.hasAttribute("cms-template"))continue;let X={};p(X,W,I);let U={root:f.root,state:f.state,item:X,ownerEl:W,projection:f.projection};y(W,X,U),T.push(X),I++}}function H(i,h){let f=String(i).split("."),g=I=>{for(let W of f){if(I==null)return;I=Array.isArray(I)?I.flatMap(Y=>Y&&Y[W]!=null?Y[W]:[]):I[W]}return I},T=g(h.state);return T===void 0?g(h.root):T}function c(i,h,f){for(let g of V(i.getAttribute("state")||""))g.name in h||(h[g.name]=yt(i,g)?i.hasAttribute(g.attr):P(i,g));A.push({el:i,parentObj:h,ctx:f})}function u(i,h,f){i._sapScope=h;let g=i.getAttribute("detail")||"",T=/^([\w.]+)\s+by\s+(.+)$/.exec(g);if(!T){i.hidden=!0,i._sapDetailRow=null;return}let I=T[1],W=T[2].trim(),Y=H(I,f),X;try{X=Et(q(W),{state:h,item:f.item,el:i,root:f.root})}catch{X=void 0}let U=Array.isArray(Y)&&X!=null?Y.find(j=>j&&typeof j=="object"&&j.$el&&String(j.$key)===String(X)):null;if(i._sapDetailRow=U?U.$el:null,i.tagName==="DIALOG"){let j=U?String(U.$key):null;if(j!==i._sapDetailKey&&(i._sapDetailKey=j,i._sapDismissed=!1),!U){i._sapOpenedFor=null,i.open&&typeof i.close=="function"&&(i._sapEngineClose=!0,i.close());return}i.open?i._sapOpenedFor=j:(i._sapOpenedFor===j&&(i._sapDismissed=!0),i._sapOpenedFor=null,!i._sapDismissed&&i.isConnected&&typeof i.showModal=="function"&&(i.hidden&&(i.hidden=!1),i.showModal(),i._sapOpenedFor=j))}else{if(!U){i.hidden||(i.hidden=!0);return}i.hidden&&(i.hidden=!1)}ue();let at={root:f.root,state:h,item:U,ownerEl:U.$el,projection:!0};d(i,vt(i),at),E(i,U,at)}function b(i,h){for(let f=i.parentElement;f;f=f.parentElement)if(f._sapScope===h&&!f.hasAttribute("detail")||f.hasAttribute("sap"))return f;return r}function v(i,h){i._sapDrawnEl=b(i,h.state);let f=null;for(let B=i.firstElementChild;B;B=B.nextElementSibling)if(B.tagName==="TEMPLATE"){f=B;break}let g=f&&f.content.children.length===1?f.content.firstElementChild:null;if(!g)return t.diag.error("E42",i,{attr:"each",problem:"each needs one <template> child with exactly one element root"}),0;let T=i.getAttribute("each"),I;try{I=Et(q(T),{state:h.state,item:h.item,el:i,root:h.root})}catch(B){return t.diag.error("E24",i,{attr:"each",expr:T,problem:String(B.message)}),0}if(!Array.isArray(I))return t.diag.error("E40",i,{attr:"each",expr:T,problem:"each must evaluate to an array; the list keeps its last good rows"}),0;let W=q(i.getAttribute("key")||"item.$key"),Y=[],X=new Set;for(let B of I){let K;try{K=dt(W,h.state,B,i,h.root)}catch{K=void 0}let D=K==null?"":String(K);if(D===""||X.has(D))return t.diag.error("E41",i,{attr:"key",expr:W.src,problem:D===""?"an item has no key; the list keeps its last good rows":`duplicate key "${D}"; the list keeps its last good rows`}),0;X.add(D),Y.push(D)}let U=i._sapEach||new Map,at=new Map,j=0,ee=f;Y.forEach((B,K)=>{let D=U.get(B);if(!D||D.parentElement!==i){D=i.ownerDocument.importNode(g,!0);let _t=(D.getAttribute("clay")||"").split(/\s+/).filter(Boolean);_t.includes("editor-ui")||D.setAttribute("clay",[..._t,"editor-ui"].join(" ")),D._sapEachRow=!0,j++}D.getAttribute("data-key")!==B&&D.setAttribute("data-key",B),ee.nextElementSibling!==D&&(er(i,D,ee),j++),D._sapEachItem=I[K],at.set(B,D),ee=D});for(let[B,K]of U)at.get(B)!==K&&K.parentElement===i&&(K.remove(),j++);return i._sapEach=at,ue(),Y.forEach((B,K)=>{let D=at.get(B),_t={root:h.root,state:h.state,item:I[K],ownerEl:D,projection:!1,view:!0};d(D,vt(D),_t),E(D,{},_t)}),j}y(r,n,N);for(let i=0;i<A.length;i++){let{el:h,parentObj:f,ctx:g}=A[i];u(h,f,g)}if($.length&&w.size)for(let i of $)w.has(i.attr)&&i.el.getAttribute(i.attr)==null&&i.el.setAttribute(i.attr,i.value);let x=new Map;for(let i of o){let h=x.get(i.owner);h||(h={ownerEl:i.ownerEl,list:[]},x.set(i.owner,h)),h.list.push(i)}let L=[...x.values()].sort((i,h)=>on(h.ownerEl)-on(i.ownerEl));for(let i of L){let h;try{h=Oe(i.list)}catch(f){t.diag.error("E07",i.list[0].el,{problem:f.message}),h=i.list}for(let f of h)try{f.owner[f.name]=dt(f.entry,f.ctx.state,f.ctx.item,f.el,f.ctx.root),Ft(f.el)}catch(g){f.owner[f.name]=void 0,t.diag.error("E24",f.el,{attr:"calc:"+f.name,expr:f.entry.src,problem:String(g.message)}),ut(f.el,g.sapCode||"E24")}}let C=0;for(let i=0;i<l.length;i++)C+=v(l[i].el,l[i].ctx);let R=0,F=C;for(let i of s){let h=Qn(i,t);i.ctx.view?F+=h:R+=h}for(let i of a)Zn(i,t);for(let i of k)tr(i);t._state=n,t._stats={fields:Object.keys(n).filter(i=>typeof n[i]!="function").length,calcs:o.length,paints:s.length,lists:x.size,writes:R,viewWrites:F},t._viewsChanged=F>0,t._lastPass={trigger:e.trigger||"refresh",writes:R},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${R}/${s.length}`)}function Jn(t){return t.kind==="text"?t.fmt?"text:"+t.fmt:"text":t.kind==="attr"?"attr:"+t.arg:t.kind==="class"?"class:"+t.arg:t.kind==="css"?"css:"+t.arg:t.kind==="when"?(t.match==="hide"?"hide-when:":t.match==="show-not"?"option-not:":"show-when:")+t.field:t.kind}function he(t,e,r,n){let o=t;for(;o&&o.nodeType===1;){if(o.hasAttribute&&o.hasAttribute(e)){let s=r.includes(o.getAttribute(e));if(n?!s:s)return!0}o=o.parentElement}return!1}function nn(t,e){if(t===t.ownerDocument.activeElement)return 0;if(t.type==="radio"){let s=e!=null&&String(t.value)===String(e);return t.checked===s?0:(t.checked=s,1)}let r=Kt(t),n=de(t,r),o=e??"";return String(n)!==String(o)?(Qe(t,r,o),1):0}function Qn(t,e){let r=t.def,n=t.el;if(r.kind==="projection"){if(r.from==="drawn"){let o=r.field in t.ctx.state?t.ctx.state:t.ctx.root;return nn(n,o[r.field])}return nn(n,t.ctx.item?t.ctx.item[r.field]:"")}if(r.kind==="when")return rn(r,n,null);try{let o=dt(r.entry,t.ctx.state,t.ctx.item,n,t.ctx.root),s=rn(r,n,o);return Ft(n),s}catch(o){return e.diag.error(o.sapCode==="E22"?"E22":"E24",n,{attr:Jn(r),expr:r.entry&&r.entry.src,problem:String(o.message)}),ut(n,o.sapCode||"E24"),0}}function rn(t,e,r){switch(t.kind){case"text":{let n=t.fmt!=null?Me(t.fmt,r):r==null?"":String(r);return e.textContent!==n?(e.textContent=n,1):0}case"show":{let n=!r;return e.hidden!==n?(e.hidden=n,1):0}case"when":{let n=Q("optionVisibility");if(n&&n._started)return e._sapWhen&&e.hidden?(e.hidden=!1,e._sapWhen=!1,1):0;let o;t.match==="hide"?o=!he(e,t.field,t.values,!1):t.match==="show-not"?o=he(e,t.field,t.values,!0):o=he(e,t.field,t.values,!1),e._sapWhen=!0;let s=!o;return e.hidden!==s?(e.hidden=s,1):0}case"attr":{let n=t.arg;if((n==="checked"||n==="selected")&&typeof e[n]=="boolean"&&!e.hasAttribute("bind")&&!e.closest("select[bind]")){let s=0;return e[n]!==!!r&&(e[n]=!!r,s=1),!!r!==e.hasAttribute(n)&&(r?e.setAttribute(n,""):e.removeAttribute(n),s=1),s}if(Xn.has(n)){let s=e.hasAttribute(n);return r&&!s?(e.setAttribute(n,""),1):!r&&s?(e.removeAttribute(n),1):0}let o=typeof r=="boolean"?String(r):r==null?"":String(r);return e.getAttribute(n)!==o?(e.setAttribute(n,o),1):0}case"class":{let n=!!r;return e.classList.contains(t.arg)!==n?(e.classList.toggle(t.arg,n),1):0}case"css":{let n=r==null?"":String(r);return e.style.getPropertyValue("--"+t.arg)!==n?(e.style.setProperty("--"+t.arg,n),1):0}default:return 0}}function Zn(t,e){try{dt(t.def.entry,t.ctx.state,t.ctx.item,t.el,t.ctx.root),Ft(t.el)}catch(r){e.diag.error("E24",t.el,{attr:"effect",expr:t.def.entry&&t.def.entry.src,problem:String(r.message)}),ut(t.el,"E24")}}function tr(t){let e="";try{let r=dt(t.def.entry,t.ctx.state,t.ctx.item,t.el,t.ctx.root);e=typeof r=="string"?r:""}catch{e=""}typeof t.el.setCustomValidity=="function"&&t.el.setCustomValidity(e)}function on(t){let e=0,r=t;for(;r&&!(r.hasAttribute&&r.hasAttribute("sap"));)r=r.parentElement,e++;return e}function er(t,e,r){let n=r.nextSibling;if(e.isConnected&&t.moveBefore)try{t.moveBefore(e,n);return}catch{}t.insertBefore(e,n)}var nr=new Set(bt),sn=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode"]),rr=new Set(["show-when","hide-when","option","option-not"]),or=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,an=new Set(["sap","scope","items","item","template","bind","show","effect","invalid","detail","state","transient","confirm","default","persist","sortable","trigger-add","trigger-remove","trigger-reset","sap-ignore","sap-error","no-save","no-watch","no-undo","no-trigger-autosave","freeze","mutations-ignore","save-remove","save-ignore","save-freeze"]);function ir(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function be(t){return t.hasAttribute("bind")}function sr(t,e){e(t);for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(!n.hasAttribute("sap-ignore")){if(n.tagName==="TEMPLATE"){if(n.hasAttribute("items"))for(let o=n.content.firstElementChild;o;o=o.nextElementSibling)r(o);return}e(n);for(let o=n.firstElementChild;o;o=o.nextElementSibling)r(o)}}}function Zt(t,e){let r=!1,n=(a,k,$)=>{e.error(a,k,$),r=!0},o=t.ownerDocument.createTreeWalker(t,4),s;for(;s=o.nextNode();)if(/\{\{.*\}\}/.test(s.nodeValue||"")){n("E02",s.parentElement||t,{problem:"moustaches in text content are not a Sap feature",fix:'move the expression onto the element: text="state.x"'});break}return sr(t,a=>{let k=a.closest&&a.closest("[detail]");for(let $ of[...a.attributes]){let A=$.name,l=ve(A);if(l){n("E01",a,{attr:A,expr:$.value,problem:`"${A}" is a foreign-dialect attribute; Sap has no ${A.split(/[:=]/)[0]} directive`,fix:l+" \u2014 or wrap the subtree in sap-ignore if intentional"});continue}if(A.includes(":")){let N=A.slice(0,A.indexOf(":"));if(sn.has(N)){if(rr.has(N)&&or.test($.value)){let P=A.slice(A.indexOf(":")+1);e.warn("W04",a,{attr:A,expr:$.value,problem:`${N}: compares the "${P}" attribute against a literal value, not a JS expression`,fix:`use show="${$.value}" for an expression, or a literal like ${N}:${P}="overview"`})}}else{let P=Nt(N,[...sn]);e.warn("W03",a,{attr:A,problem:`unknown "${N}:" attribute`,didYouMean:P?`${P}:`:null})}}else if(!an.has(A)&&!Tt.has(A)&&!nr.has(A)&&!/^(data-|aria-|on)/.test(A)&&!(A in a)){let N=Nt(A,[...an]);N&&e.warn("W03",a,{attr:A,problem:`unknown "${A}" attribute`,didYouMean:N})}A==="attr:hidden"&&e.warn("W03",a,{attr:A,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'});let w=be(a)||A==="attr:selected"&&a.tagName==="OPTION"&&!!a.closest("select[bind]");(A==="attr:value"||A==="attr:checked"||A==="attr:selected")&&w&&n("E30",a,{attr:A,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),A==="effect"&&be(a)&&/\b(value|checked)\s*=[^=]/.test($.value)&&n("E30",a,{attr:A,expr:$.value,problem:"effect writes value/checked on a bound control (writes a stale value with no synthetic event)",fix:"write through onclick + Sap(this) instead"}),(A==="text"||A.startsWith("text:")||A==="show")&&ir(a)&&(A==="show"||n("E18",a,{attr:A,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(a.hasAttribute("state")){let $=V(a.getAttribute("state")),A=new Set;for(let l of $){l.name.includes("-")&&n("E08",a,{attr:"state",problem:`field "${l.name}" is not a valid identifier (the hyphen parses as subtraction)`,fix:`rename to ${l.name.replace(/-/g,"")}`}),A.has(l.name)&&n("E04",a,{attr:"state",problem:`field "${l.name}" is declared twice in one scope`}),A.add(l.name),It.has(l.attr)&&n("E05",a,{attr:"state",problem:`"${l.name}" is a reserved Sap word`}),Tt.has(l.attr)&&n("E06",a,{attr:"state",problem:`"${l.name}" is a global HTML attribute name; pick another field name`}),l.name==="open"&&a.tagName==="DIALOG"&&n("E33",a,{attr:"state",problem:"dialog open is transient",fix:"use showModal() \u2014 declare state= only on <details> or popovers"});let w=se(a,l.attr);w&&(l.attr==="checked"||l.attr==="selected")&&n("E35",a,{attr:"state",problem:`"${l.attr}" on a form control is the control's own state, not a declared field`,fix:'bind the control instead, e.g. <input type="checkbox" bind="done">'}),w&&l.type==="num"&&n("E35",a,{attr:"state",problem:`"${l.attr}" is an HTML boolean attribute; it cannot hold a number`,fix:`declare it bare: state="${l.attr}"`}),l.transient&&(w||l.type==="presence")&&n("E35",a,{attr:"state",problem:`"${l.name}" is carried by attribute presence, which transient would strip`,fix:"declare a separate name:bool:transient field and paint the attribute from it"})}}if(be(a)){if(a.hasAttribute("-"),a.tagName==="INPUT"){let $=(a.getAttribute("type")||"text").toLowerCase();$==="file"&&n("E32",a,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),$==="password"&&!a.hasAttribute("transient")&&n("E31",a,{attr:"bind",problem:"a password must never serialize into a world-readable file",fix:"add transient to the password input"})}else if(a.tagName!=="SELECT"&&a.tagName!=="TEXTAREA"){let $=a.getAttribute("contenteditable");!($!=null&&$!=="false")&&a.children.length>0&&n("E20",a,{attr:"bind",problem:"bind on a container element is not a control; a write would overwrite its children",fix:"bind a control (input/select/textarea), a contenteditable, or an empty text leaf"})}}if(a.hasAttribute("transient")&&a.hasAttribute("persist")&&n("E34",a,{problem:"transient and persist are opposite: persist forces the live value into the saved bytes, leaking exactly what transient drops",fix:"remove one \u2014 transient to keep it out of the file, or persist to save it"}),a.tagName==="DIALOG"&&a.hasAttribute("detail")&&!(a.parentElement&&a.parentElement.closest('[clay~="freeze"], [freeze], [save-freeze]'))&&e.warn("W31",a,{attr:"detail",problem:"a detail dialog writes open when it opens, and that attribute would be saved into the file",fix:'wrap the dialog in an element with clay="freeze" (not editor-ui, which removes it from the file), and make its key field transient'}),a.hasAttribute("item")&&!a.hasAttribute("template")&&a.parentNode&&a.parentNode.nodeType===1){let $=a.parentElement;(!$||!$.hasAttribute("items"))&&n("E10",a,{problem:"an [item] must be a direct child of an [items] list",fix:'wrap it in a container with items="name"'})}if(a.hasAttribute("items")&&k&&n("E17",a,{attr:"items",problem:"nested items inside a detail panel is a v1 mount error (nested collections ship in v1.1)"}),a.hasAttribute("items")){let $=t.querySelector(`[trigger-add="${a.getAttribute("items")}"]`);!Vt(a)&&!oe(t,a.getAttribute("items"))&&rt(a).length===0&&$&&n("E17",a,{attr:"items",problem:`trigger-add targets items="${a.getAttribute("items")}" but it has no [item template] to clone`})}}),r&&(e.halted=!0,e.haltReason=e.errors[0]?e.errors[0].code:"halt",ut(t,e.haltReason)),!r}var un="sap-styles",cn="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",ge=new WeakSet;function ar(t){if(ge.has(t))return;let e=t.defaultView,r=e&&e.CSSStyleSheet;if(r&&"adoptedStyleSheets"in t)try{let n=new r;n.replaceSync(cn),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],ge.add(t);return}catch{}if(!t.getElementById(un)){let n=t.createElement("style");n.id=un,n.textContent=cn,(t.head||t.documentElement).appendChild(n)}ge.add(t)}var ur=0;function ln(){return typeof performance<"u"&&performance.now?performance.now():0}function we(t){let e=t.id||t.getAttribute("sap")||`app-${ur++}`,r=new ht(e),n={root:t,name:e,diag:r,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Zt(t,r))return n.halted=!0,n;ar(t.ownerDocument);for(let a of t.querySelectorAll("textarea[data-value]"))Yt(a);let s=ln();return $t(n,{trigger:"mount",full:!0}),n._mountMs=ln()-s,n._mountWrites=n._stats?n._stats.writes:0,n._mountWrites>0&&r.warn("W30",t,{problem:`${n._mountWrites} paint(s) ran at mount; the saved file was out of sync with its declared state`,fix:"re-save once so the file mounts clean (a settled file writes nothing)"}),n}var cr=["for","form","list","headers","popovertarget","commandfor","anchor","aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"];function lr(t,e){let r=null;return et(t,n=>{!r&&n.getAttribute("scope")===e&&(r=n)}),r}function fn(t,e,r){let n=J(t)||e;for(;n;){for(let o of V(n.getAttribute("state")||""))if(o.name===r)return{el:n,decl:o};if(n.hasAttribute("sap"))break;n=J(n.parentElement)}return null}function fr(t){return typeof t=="number"?"num":typeof t=="boolean"?"bool":"string"}function dn(t){function e(m){let d=t.appFor(m);if(!d)return null;let p=lt(m),y=p&&p._sapEachItem&&p._sapEachItem.$el;if(y&&y.isConnected)return{ctxEl:y,appRec:d,isRow:!0};let E=Lt(m);if(E)return E._sapDetailRow?{ctxEl:E._sapDetailRow,appRec:d,isRow:!0}:{ctxEl:J(E.parentElement)||d.root,appRec:d,isRow:!1};let S=Wt(m);if(S&&S.hasAttribute("item"))return{ctxEl:S,appRec:d,isRow:!0};let _=J(m)||d.root;return{ctxEl:_,appRec:d,isRow:_.hasAttribute("item")}}function r(m){let d=typeof m=="string"?document.querySelector(m):m;if(!d||d.nodeType!==1)return null;let p=e(d);return p?z(p.ctxEl,p.appRec,p.isRow):null}function n(m,d){let p=lt(m);if(!p)return r(m);let y=t.appFor(m),E=p._sapEachItem&&p._sapEachItem.$el;if(E&&E.nodeType===1&&E.hasAttribute("item")&&wt(E,d))return E.isConnected?z(E,y,!0):null;let S=p.parentElement&&p.parentElement._sapDrawnEl;return!S||!S.isConnected?null:z(S,y,S.hasAttribute("item"))}function o(m,d,p){let y=ft(m,p);if(y)return G(y).read();let E=gt(m,p);if(E)return rt(E).map(H=>z(H,d,!0));let S=lr(m,p);if(S)return z(S,d,!1);let _=fn(m,d.root,p);if(_)return _.decl.transient?zt(_.el,_.decl):$e(_.el,_.decl);let M=m._sapScope;return M?M[p]:void 0}function s(m,d,p,y,E){y.transient?Dt(m,y,p):Rt(m,y,p),t.schedule(E,"set:"+d)}function a(m,d){let p=new Set,y=J(m)||d;for(;y;){for(let E of V(y.getAttribute("state")||""))p.add(E.name);if(y.hasAttribute("sap"))break;y=J(y.parentElement)}return et(m,E=>{let S=E.getAttribute("bind");S&&p.add(S)}),p}function k(m,d,p,y){let E=ft(m,p);if(E){G(E).write(y);return}let S=m;for(;S;){for(let x of S.attributes)if(x.name==="calc:"+p){d.diag.error("E16",S,{attr:"calc:"+p,problem:`"${p}" is a computed field; computed fields are read-only`});return}if(S.hasAttribute("sap"))break;S=S.parentElement}let _=fn(m,d.root,p);if(_){s(_.el,p,y,_.decl,d);return}let M=a(m,d.root);M.delete(p);let H=p.length>=4?Nt(p,[...M]):null;if(H){d.diag.error("E12",m,{key:p,problem:`unknown state key "${p}"`,didYouMean:H});return}if(It.has(p)||Tt.has(p)){d.diag.error("E15",m,{key:p,problem:`cannot write undeclared field "${p}" \u2014 it is a reserved/global name and cannot become state`,fix:"pick a different field name, or declare it explicitly in a state= attribute"});return}let c=d.root,u=fr(y),b=c.getAttribute("state")||"",v=u==="string"?p:`${p}:${u}`;c.setAttribute("state",b?`${b} ${v}`:v),s(c,p,y,{name:p,attr:p,type:u,transient:!1},d)}function $(m){let d=m.ownerDocument,p=new Map,y=(E,S)=>{let _=Se(d),M=E.getAttribute(S);M&&S==="id"&&p.set(M,_),E.setAttribute(S,_)};m.querySelectorAll("[id]").forEach(E=>y(E,"id")),m.querySelectorAll("[data-id]").forEach(E=>y(E,"data-id")),m.querySelectorAll("[sap-error]").forEach(E=>E.removeAttribute("sap-error")),m.removeAttribute("sap-error"),m.hasAttribute("data-id")?(m.removeAttribute("id"),y(m,"data-id")):y(m,"id");for(let E of[m,...m.querySelectorAll("*")])for(let S of cr){let _=E.getAttribute(S);if(_==null)continue;let M=_.split(/\s+/).map(H=>p.get(H)||H).join(" ");M!==_&&E.setAttribute(S,M)}}function A(m,d,p){let y=Mt(d.root,m,p);if(!y)return d.diag.error("E17",m,{problem:`cannot resolve a list named "${p}" from here`}),null;let E=Vt(y);if(!E)return d.diag.error("E17",y,{problem:`items="${p}" has no [item template] to clone`}),null;let S=y.ownerDocument.importNode(E,!0);return S.removeAttribute("template"),$(S),y.appendChild(S),t.schedule(d,"trigger-add:"+p),z(S,d,!0)}function l(m,d){et(m,p=>{if(p.hasAttribute("bind")){let y=G(p),E=p.getAttribute("default");y.kind==="checkbox"||y.kind==="radio"?y.write(E!=null?E===""||E==="true"||p.value===E:p.hasAttribute("checked")):y.write(E??(p.getAttribute("value")||""))}});for(let p of V(m.getAttribute("state")||"")){let y=_e(m,p);p.transient?Dt(m,p,y):Rt(m,p,y)}t.schedule(d,"trigger-reset")}function w(m,d){if(!m.isConnected)throw new Error("stale row handle: $remove() on a removed row");m.remove(),t.schedule(d,"trigger-remove")}function N(m,d,p){if(!m.isConnected)throw new Error("stale row handle: $move() on a removed row");let y=null;if(p&&p.nodeType===1?y=p:typeof p=="string"&&(y=Mt(d.root,m,p)),!y){d.diag.error("E17",m,{problem:`$move() cannot resolve target "${p}"`});return}t.moveInto(y,m),t.schedule(d,"trigger-move")}function P(m){let d=m.parentElement;return d?rt(d).indexOf(m):-1}function z(m,d,p){let y={get $el(){return m},get $key(){return Bt(m,p?"row":"scope")},get $index(){return P(m)},$add(S){return A(m,d,S)},$reset(){return l(m,d),E},$remove(){w(m,d)},$move(S){N(m,d,S)},get $appRec(){return d}},E=new Proxy(y,{get(S,_){return typeof _=="symbol"||_[0]==="$"?S[_]:o(m,d,_)},set(S,_,M){return typeof _=="string"&&_[0]==="$"?(S[_]=M,!0):(k(m,d,_,M),!0)},has(S,_){return typeof _=="string"&&_[0]==="$"?_ in S:o(m,d,_)!==void 0}});return E}return{Sap:r,contextElFor:e,readField:o,writeField:k,makeProxy:z,writeTargetFor:n}}var dr=["trigger-add","trigger-remove","trigger-reset"];function pr(t){if(t.nodeType!==1)return!1;for(let e of t.attributes){let r=e.name;if(r.startsWith("set:")||r.startsWith("move:")||r.startsWith("sort:")||dr.includes(r))return!0}return!1}function mr(t,e){let r=t,n=e.parentElement;for(;r&&r!==n;){if(r.nodeType===1&&pr(r)&&!(r.tagName==="FORM"&&r.hasAttribute("trigger-add")))return r;r=r.parentElement}return null}function pn(t,e){let{Sap:r}=e;function n(c,u){let b=null,v=lt(c),x=Lt(c);if(v)b=v._sapEachItem??null;else if(x&&x._sapDetailRow)b=x._sapDetailRow._sapScope||null;else{let R=Wt(c);R&&R.hasAttribute("item")&&(b=R._sapScope||null)}return{state:(J(c)||u.root)._sapScope||u._state||{},item:b,el:c,root:u._state||{}}}function o(c,u,b){if(!c.hasAttribute("confirm")){b();return}let v=c.getAttribute("confirm"),x=v,L=q(v);if(!L.error)try{let F=Et(L,n(c,u));(typeof F=="string"||typeof F=="number")&&(x=String(F))}catch{}let C=Ge();if(!C){window.confirm(x)&&b();return}if(c._sapGatePending)return;c._sapGatePending=!0;let R=()=>{c._sapGatePending=!1};C(x,()=>{R(),b()}).catch(R)}function s(c,u){for(let b of c.attributes){if(!b.name.startsWith("set:"))continue;let v=b.name.slice(4),x=q(b.value);if(x.error){u.diag.error("E08",c,{attr:b.name,expr:b.value,problem:String(x.error.message)});continue}let L;try{L=Et(x,n(c,u))}catch(R){u.diag.error("E24",c,{attr:b.name,expr:b.value,problem:String(R.message)});continue}let C=e.writeTargetFor(c,v);C&&(C[v]=L)}}function a(c){let u=lt(c);if(!u)return c.closest("[item]");let b=u._sapEachItem&&u._sapEachItem.$el;return b&&b.nodeType===1&&b.hasAttribute("item")?b:null}function k(c,u){let b=a(c);if(!b)return;let v=rt(b.parentElement),x=v.indexOf(b);u==="up"&&x>0?t.placeBefore(b,v[x-1]):u==="down"&&x<v.length-1&&t.placeBefore(v[x+1],b)}function $(c,u,b){if(u)return Mt(b.root,c,u);let v=c;for(;v;){if(v.hasAttribute&&v.hasAttribute("items"))return v;v=v.parentElement}let x=J(c)||b.root,L=[];return et(x,C=>{C.hasAttribute("items")&&L.push(C)}),L[0]||null}function A(c,u){let b=c==null||c==="",v=u==null||u==="";if(b&&v)return 0;if(b)return 1;if(v)return-1;let x=Number(c),L=Number(u);return!Number.isNaN(x)&&!Number.isNaN(L)?x-L:String(c)<String(u)?-1:String(c)>String(u)?1:0}function l(c,u,b,v){let x=$(c,b,v);if(!x){v.diag.error("E17",c,{attr:"sort:"+u,problem:`no items list resolvable for sort:${u}`});return}let L=rt(x),C=h=>h._sapScope?h._sapScope[u]:void 0,R=[...L].sort((h,f)=>A(C(h),C(f))),i=R.every((h,f)=>h===L[f])?[...R].reverse():R;for(let h of i)t.moveInto(x,h);t.schedule(v,"sort:"+u)}function w(c){if(!c||c.hidden)return;let u=c.querySelector("[bind]:not([type=hidden]), [contenteditable]");u&&typeof u.focus=="function"&&u.focus()}function N(c,u){o(c,u,()=>{let b=r(c);for(let v of[...c.attributes]){let x=v.name;if(x==="trigger-remove")b&&b.$remove();else if(x==="trigger-reset")b&&b.$reset();else if(x==="trigger-add"){let L=b&&b.$add(v.value);L&&w(L.$el)}else x==="move:up"?(k(c,"up"),t.schedule(u,"move:up")):x==="move:down"?(k(c,"down"),t.schedule(u,"move:down")):x.startsWith("move:to")?b&&b.$move(v.value):x.startsWith("sort:")&&l(c,x.slice(5),v.value,u)}[...c.attributes].some(v=>v.name.startsWith("set:"))&&s(c,u)})}function P(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;let v=mr(u,b.root);v&&N(v,b)}function z(c){let u=G(c),b=c.getAttribute("default");u.kind==="checkbox"?u.write(b===""||b==="true"):u.write(b??"")}function m(c,u,b){let v=r(c);if(!v)return;let x=v.$add(b);if(!x)return;let L=[];et(c,C=>{C.hasAttribute("bind")&&L.push(C)});for(let C of L){if(C.type==="radio"&&!C.checked)continue;let R=C.getAttribute("bind"),F=ft(x.$el,R);F?G(F).write(G(C).read()):wt(x.$el,R)&&(x[R]=G(C).read())}L.forEach(z),L.length?typeof L[0].focus=="function"&&L[0].focus():w(x.$el)}function d(c){let u=c.target;if(!u||!u.hasAttribute||!u.hasAttribute("trigger-add"))return;let b=t.appFor(u);b&&(c.preventDefault(),o(u,b,()=>m(u,b,u.getAttribute("trigger-add"))))}function p(c){let u=c.target,b=t.appFor(u);b&&setTimeout(()=>{u.querySelectorAll("[bind]").forEach(v=>{v.dispatchEvent(new Event("input",{bubbles:!0})),v.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(b,"reset")},0)}function y(c){let u=t.appFor(c.target);u&&t.schedule(u,"toggle")}function E(c){let u=c.target;if(!u||u.tagName!=="DIALOG"||!u.hasAttribute("detail"))return;if(u._sapEngineClose){u._sapEngineClose=!1;return}if(u.open)return;let b=/^[\w.]+\s+by\s+state\.(\w+)\s*$/.exec(u.getAttribute("detail")||""),v=t.appFor(u);if(!b||!v)return;let x=V(u.getAttribute("state")||"").find(C=>C.name===b[1]);if(x){x.transient?Dt(u,x,""):Rt(u,x,""),t.schedule(v,"close");return}let L=r(u.parentElement);L&&L[b[1]]!==""&&(L[b[1]]="")}function S(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;u.hasAttribute("persist")&&!Xt(u)&&xt(u);let v=u.hasAttribute("bind")&&qt(u);if(!v&&u.hasAttribute("bind")&<(u)){let L=u.getAttribute("bind"),C=u._sapViewBind?e.writeTargetFor(u,L):null;C&&(C[L]=G(u).read());return}let x=Lt(u);if(x&&x._sapDetailRow&&u.hasAttribute("bind")&&!v){let L=x._sapDetailRow,C=u.getAttribute("bind"),R=ft(L,C);if(R&&R!==u){G(R).write(G(u).read());return}if(!R&&V(L.getAttribute("state")||"").some(F=>F.name===C)){e.writeField(L,b,C,G(u).read());return}}t.schedule(b,c.type+" "+(u.id||u.tagName.toLowerCase()))}function _(c){let u=c.detail||{};for(let b of[u.from,u.to,c.target]){if(!b||b.nodeType!==1)continue;let v=t.appFor(b);v&&t.schedule(v,"sorted")}}function M(c){if(c.key!=="ArrowUp"&&c.key!=="ArrowDown")return;let u=c.target;if(!u||u.nodeType!==1||u.tagName!=="INPUT"||!u.hasAttribute("bind")||!u.hasAttribute("step"))return;let b=(u.getAttribute("type")||"text").toLowerCase();if(b!=="text"&&b!=="tel"&&b!=="search"||!t.appFor(u))return;c.preventDefault();let x=Z(u.getAttribute("step"))||1,L=c.key==="ArrowUp"?1:-1,C=Z(u.value)+x*(c.shiftKey?10:1)*L,R=u.getAttribute("min"),F=u.getAttribute("max");R!==null&&R!==""&&C<Z(R)&&(C=Z(R)),F!==null&&F!==""&&C>Z(F)&&(C=Z(F)),G(u).write(String(Number(C.toFixed(2))))}function H(c=document){c.addEventListener("click",P),c.addEventListener("submit",d),c.addEventListener("reset",p),c.addEventListener("toggle",y,!0),c.addEventListener("close",E,!0),c.addEventListener("input",S),c.addEventListener("change",S),c.addEventListener("clay:sorted",_),c.addEventListener("keydown",M)}return{install:H}}var mn=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function ye(t){return`${t.tagName.toLowerCase()}[sap]`}function hr(t){let e=0;for(let r of t.querySelectorAll("*"))for(let n of r.attributes)if(mn.test(n.name)){e++;break}for(let r of t.attributes)if(mn.test(r.name)){e++;break}return e}function hn(t){let e=[],r=n=>{for(let o of n.attributes){let s=o.name;(s.startsWith("calc:")||s==="text"||s.startsWith("text:")||s==="show"||s.startsWith("attr:")||s.startsWith("class:")||s.startsWith("css:")||s==="effect"||s==="invalid"||s.startsWith("set:")||s==="detail")&&e.push({el:n,attr:s,src:o.value})}};r(t);for(let n of t.querySelectorAll("*"))r(n);return e}function bn(t){function e(l){let w=l._stats||{},N=l.root;return{root:ye(N),fields:w.fields||0,calcs:w.calcs||0,paints:w.paints||0,actions:hr(N),lists:(N.hasAttribute("items")?1:0)+N.querySelectorAll("[items]").length,rows:N.querySelectorAll("[item]:not([template])").length,warnings:l.diag.warnings.length,errors:l.diag.errors.length,mountWrites:l._mountWrites||0,ms:Math.round((l._mountMs||0)*10)/10,passes:l._passes||0,lastPass:l._lastPass||null,ok:l.diag.errors.length===0&&!l.halted}}function r(){let l=t.apps().map(e);return{ok:l.every(w=>w.ok),apps:l}}function n(l){let w=e(l);return w.ok?`sap \u2713 ${w.root} \xB7 fields ${w.fields} \xB7 calcs ${w.calcs} \xB7 paints ${w.paints} \xB7 actions ${w.actions} \xB7 lists ${w.lists} \xB7 rows ${w.rows} \xB7 warnings ${w.warnings} \xB7 mount writes ${w.mountWrites} \xB7 ${w.ms}ms`:`sap \u2717 ${w.root} \xB7 errors ${w.errors} \xB7 warnings ${w.warnings} \xB7 ${w.ms}ms`}function o(){for(let l of t.apps()){let w=n(l);l.diag.errors.length||l.halted?console.error(w):console.log(w)}}function s(){let l=[],w=[];for(let N of t.apps())l.push(...N.diag.errors),w.push(...N.diag.warnings);return{ok:l.length===0,errors:l,warnings:w,counts:{errors:l.length,warnings:w.length}}}function a(l){return l?typeof l=="string"?document.querySelector(l):l.nodeType===1?l:null:null}function k(l,w){let N=a(l);if(!N)return console.warn("sap why: element not found"),null;let P=[`sap why <${N.tagName.toLowerCase()}> \u2014 ${Ot(N)}`],z=[...N.attributes].filter(d=>/^(bind|text|show|effect|invalid|detail|calc:|text:|attr:|class:|css:|set:|state|items|scope)/.test(d.name));for(let d of z)P.push(` ${d.name}="${d.value}"`);let m=N;for(;m&&!m._sapScope;)m=m.parentElement;if(m&&m._sapScope){let d=m._sapScope,p=w?[w]:Object.keys(d);P.push(" reads:");for(let y of p){let E=d[y];typeof E!="function"&&P.push(` ${y} = ${JSON.stringify(Array.isArray(E)?`[${E.length} rows]`:E)}`)}}return P.push(" serialization: textContent and value/checked attributes save with the file; reads live from properties"),console.log(P.join(`
|
|
10
|
-
`)),null}function $(l){let w=l===void 0?!0:!!l;for(let N of t.apps())N._debug=w;return console.log(`sap debug ${w?"on":"off"} \u2014 per-pass headers will ${w?"":"no longer "}log`),w}function A(){let l=[],w=0;for(let d of t.apps()){let p=d.root,y=ye(p);w++;let E=new ht(d.name);Zt(p,E);for(let c of E.errors)l.push({code:c.code,severity:"error",message:`${y}: ${c.code} ${c.slug} at ${c.el}`});for(let c of E.warnings)l.push({code:c.code,severity:"warn",message:`${y}: ${c.code} ${c.slug} at ${c.el}`});w++,$t(d,{trigger:"doctor-dryrun"});let S=d._stats?d._stats.writes:0;S>0&&l.push({code:"W30",severity:"warn",message:`${y}: dry recompute wrote ${S} cells on a quiet page; an element is stale or non-idempotent`}),w++;let _=
|
|
9
|
+
`+e.value:e.value;t.textContent!==n&&(t.textContent=n),t.removeAttribute("data-value");return}if(r==="SELECT"){let n=t.options,o=e.options;for(let s=0;s<n.length;s++)o[s]&&o[s].selected?n[s].hasAttribute("selected")||n[s].setAttribute("selected",""):n[s].removeAttribute("selected")}}function Yt(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function X(t){if(typeof window>"u")return null;let e=window.clay,r=window.hyperclay;return t==="consent"?e?.confirm||r?.consent||null:e?.[t]||r?.[t]||null}function Ue(){let t=X("visitorDrafts");return!!(t&&typeof t.restored=="function"&&t.restored()?.restored)}var le=["clay:mutation-ready","hyperclay:mutation-ready"],Vn=["clay:sync-applied","hyperclay:livesync-applied"],zn=["clay:ready","hyperclay:ready"],Hn=["clay:route"];function St(t,e,r){let n=null,o=s=>{n!==null&&n!==s.type||(n=s.type,queueMicrotask(()=>{n=null}),r(s))};for(let s of e)t.addEventListener(s,o);return()=>{for(let s of e)t.removeEventListener(s,o)}}function Ge(t){let e=typeof window<"u"&&window.clay&&window.clay.ready;e&&typeof e.then=="function"?e.then(()=>t(),()=>t()):t()}function Xt(t){let e=X("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function Ye(){let t=X("consent");return typeof t=="function"?t:null}function Xe(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let r=X("undo");r&&r.flush&&r.flush();let n=e();if(n&&typeof n.then=="function")throw new Error("Sap.batch fn must be synchronous (it returned a promise)");return r&&r.commitCaptured&&r.commitCaptured(t),n}function Ke(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let s=!1;for(let a of t.apps())a.root.isConnected?t.runNow(a,"platform"):s=!0;s&&(t.pruneDisconnected(),t.remountIfPresent())};St(document,Vn,e),St(document,Hn,e);let r=!1,n=()=>{},o=()=>{if(r)return!0;let s=X("undo");if(!s||typeof s.on!="function")return!1;let a=s.on("undo",e);return typeof a!="function"?!1:typeof s.on("redo",e)!="function"?(a(),!1):(r=!0,n(),!0)};if(!o()){let s=St(document,le,o),a=St(document,zn,o);n=()=>{s(),a()};let k=X("ready");k&&typeof k.then=="function"&&k.then(o,()=>{})}}function Kt(t){let e=t.tagName;if(e==="INPUT"){let r=(t.getAttribute("type")||"text").toLowerCase();return r==="checkbox"?"checkbox":r==="radio"?"radio":r==="number"||r==="range"?"number":r==="hidden"?"hidden":"text"}return e==="TEXTAREA"?"text":e==="SELECT"?t.multiple?"select-multiple":"select-one":"leaf"}function jn(t){if(t.validity&&t.validity.badInput)return t.hasAttribute("value")?Number(t.getAttribute("value"))||0:t._sapLastGood??0;if(t.value==="")return 0;let e=Number(t.value);return Number.isNaN(e)?t._sapLastGood??0:(t._sapLastGood=e,e)}function Je(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return jn(t);case"select-one":return t.value;case"select-multiple":return[...t.selectedOptions].map(r=>r.value);case"hidden":case"text":return t.value;case"leaf":return t.textContent;default:return t.value}}function Qe(t,e,r){switch(e){case"checkbox":t.checked=!!r;break;case"radio":t.checked=String(t.value)===String(r);break;case"number":case"text":case"hidden":t.value=r==null?"":String(r);break;case"select-one":t.value=r==null?"":String(r);break;case"select-multiple":{let n=new Set((Array.isArray(r)?r:[r]).map(String));for(let o of t.options)o.selected=n.has(o.value);break}case"leaf":t.textContent=r==null?"":String(r);break;default:t.value=r==null?"":String(r)}}function fe(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}Xt(t)||xt(t)}function Un(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function de(t,e){return Je(t,e)}function Ze(t,e,r){Qe(t,e,r),fe(t)}function G(t){let e=Kt(t);return{el:t,kind:e,read(){return Je(t,e)},write(r,n={}){Qe(t,e,r),n.noMirror||fe(t),n.silent||Un(t)},mirror(){fe(t)}}}var ot=null,Qt=!1,kt=null;function tn(t){let e=null;return{kind:"hub",subscribe(r){let n=t.onAnyChange({debounce:0,require:"observed"},r);typeof n=="function"&&(e=n)},suppress(r){t.pause();try{return r()}finally{t.resume()}},teardown(){if(e){try{e()}catch{}e=null}}}}function Gn(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(n=>e(Yn(n)));let r=typeof document<"u"&&document.body||typeof document<"u"&&document.documentElement;r&&t.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0})},suppress(e){let r=X("undo");r&&r.pause&&r.pause();try{return e()}finally{t&&t.takeRecords(),r&&r.resume&&r.resume()}},teardown(){t&&(t.disconnect(),t=null)}}}function Yn(t){let e=[];for(let r of t)if(r.type==="attributes"){let n=r.target;n&&n.nodeType===1&&!Jt(n)&&e.push({type:"attribute",element:n})}else if(r.type==="characterData"){let n=r.target&&r.target.parentElement;n&&!Jt(n)&&e.push({type:"characterData",element:n})}else if(r.type==="childList"){for(let n of r.addedNodes)if(!(n.nodeType!==1||Jt(n))&&(e.push({type:"add",element:n}),n.querySelectorAll))for(let o of n.querySelectorAll("*"))Jt(o)||e.push({type:"add",element:o});for(let n of r.removedNodes)n.nodeType===1&&e.push({type:"remove",element:n,parent:r.target})}return e}function Jt(t){return!!(t.closest&&t.closest("[sap-ignore],[template],[cms-template]"))}function Xn(t,e){t.pruneDisconnected();let r=new Set,n=!1;for(let o of e){let s=o.type==="remove"?o.parent:o.element,a=s&&t.appFor(s);a&&r.add(a),o.type==="add"&&o.element&&o.element.nodeType===1&&o.element.hasAttribute&&o.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(o.element))&&(n=!0)}n&&t.remountIfPresent();for(let o of r)o.root.isConnected&&t.schedule(o,"mutation")}function en(t){if(ot)return ot.suppress(t);let e=X("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function pe(t,e){Qt=!0,ot=t,t.subscribe(r=>Xn(e,r))}function me(t){if(Qt||typeof window>"u"||typeof document>"u")return;let e=X("Mutation");if(e&&typeof e.onAnyChange=="function"){pe(tn(e),t);return}typeof MutationObserver=="function"&&(pe(Gn(),t),kt=St(document,le,function(){let n=X("Mutation");n&&(kt(),kt=null,ot&&ot.teardown(),Qt=!1,pe(tn(n),t))}))}function nn(){if(ot)try{ot.teardown()}catch{}kt&&typeof document<"u"&&kt(),ot=null,Qt=!1,kt=null}var Kn=new Set(bt);function $t(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),ut(t.root,"loop");return}e.full&&We();let r=qe(t.root);try{en(()=>Jn(t,e))}finally{Ve(r)}t._viewsChanged&&(t._viewsChanged=!1,t.root.dispatchEvent(new CustomEvent("sap:views-updated",{bubbles:!0})))}function Jn(t,e){let r=t.root,n={},o=[],s=[],a=[],k=[],$=[],A=[],l=[],w=new Set;t.diag.errors=[];let N={root:n,state:n,item:null,ownerEl:r,projection:!1};function P(i,h){let f=h.attr||h.name,g=i.getAttribute(f);return g==null&&(g=Ct(h),$.push({el:i,name:h.name,attr:f,value:ie(ct(g,h.type),h.type)})),ct(g,h.type)}function z(i,h,f){let g=h.decls;if(g)for(let T of g){if(T.transient){f[T.name]=zt(i,T);continue}if(yt(i,T)){f[T.name]=i.hasAttribute(T.attr);continue}f[T.name]=P(i,T)}}function m(i,h,f){let g=h.bind,T=f.item||f.state,I=Kt(i);I==="radio"?(g in T||(T[g]=""),i.checked&&(T[g]=i.value)):T[g]=de(i,I),h.transient&&(i.removeAttribute("value"),i.removeAttribute("checked"))}function d(i,h,f){if(h.calcs){let g=f.item||f.state;for(let T of h.calcs)o.push({owner:g,ownerEl:f.ownerEl,name:T.name,entry:T.entry,def:T,el:i,ctx:f})}if(h.paints)for(let g of h.paints)g.kind==="when"&&w.add(g.field),s.push({def:g,el:i,ctx:f});if(h.effects)for(let g of h.effects)a.push({def:g,el:i,ctx:f});if(h.invalids)for(let g of h.invalids)k.push({def:g,el:i,ctx:f});if(h.bind!=null&&(f.view||f.projection)&&!qt(i)){let g=h.bind;f.view?wt(ke(f.item),g)?(i._sapViewBind="item",s.push({def:{kind:"projection",field:g,from:"item"},el:i,ctx:f})):g in f.state||g in f.root?(i._sapViewBind="drawn",s.push({def:{kind:"projection",field:g,from:"drawn"},el:i,ctx:f})):(i._sapViewBind=null,t.diag.error("E43",i,{attr:"bind",expr:g,problem:`bind="${g}" inside an each row matches no field of the row's record or of the scope the row is drawn in`,fix:"bind a field the record owns (bind, state= or items= on the [item]), or declare it with state= where the list is drawn"})):s.push({def:{kind:"projection",field:g,from:null},el:i,ctx:f})}}function p(i,h,f){Object.defineProperty(i,"$key",{value:Bt(h,"row"),enumerable:!1}),Object.defineProperty(i,"$index",{value:f,enumerable:!1}),Object.defineProperty(i,"$el",{value:h,enumerable:!1})}function y(i,h,f){let g=vt(i);z(i,g,h),i._sapScope=h,!f.projection&&g.bind!=null&&m(i,g,f),d(i,g,f),g.items?M(i,h,f):E(i,h,f)}function E(i,h,f){for(let g=i.firstElementChild;g;g=g.nextElementSibling)S(g,h,f)}function S(i,h,f){let g=vt(i);if(!g.inert){if(g.boundary){g.boundary==="scope"?_(i,h,f):g.boundary==="items"?(d(i,g,f),M(i,h,f)):g.boundary==="detail"?c(i,h,f):(d(i,g,f),l.push({el:i,ctx:f}));return}!f.projection&&!f.view&&g.bind!=null&&m(i,g,f),d(i,g,f);for(let T=i.firstElementChild;T;T=T.nextElementSibling)S(T,h,f)}}function _(i,h,f){let g=i.getAttribute("scope"),T={};h[g]=T;let I={root:f.root,state:T,item:null,ownerEl:i,projection:f.projection};y(i,T,I)}function M(i,h,f){let g=i.getAttribute("items"),T=[];h[g]=T,i._sapList=T;let I=0;for(let W=i.firstElementChild;W;W=W.nextElementSibling){let Y=vt(W);if(!Y.item||Y.template||W.hasAttribute("cms-template"))continue;let K={};p(K,W,I);let U={root:f.root,state:f.state,item:K,ownerEl:W,projection:f.projection};y(W,K,U),T.push(K),I++}}function H(i,h){let f=String(i).split("."),g=I=>{for(let W of f){if(I==null)return;I=Array.isArray(I)?I.flatMap(Y=>Y&&Y[W]!=null?Y[W]:[]):I[W]}return I},T=g(h.state);return T===void 0?g(h.root):T}function c(i,h,f){for(let g of V(i.getAttribute("state")||""))g.name in h||(h[g.name]=yt(i,g)?i.hasAttribute(g.attr):P(i,g));A.push({el:i,parentObj:h,ctx:f})}function u(i,h,f){i._sapScope=h;let g=i.getAttribute("detail")||"",T=/^([\w.]+)\s+by\s+(.+)$/.exec(g);if(!T){i.hidden=!0,i._sapDetailRow=null;return}let I=T[1],W=T[2].trim(),Y=H(I,f),K;try{K=Et(q(W),{state:h,item:f.item,el:i,root:f.root})}catch{K=void 0}let U=Array.isArray(Y)&&K!=null?Y.find(j=>j&&typeof j=="object"&&j.$el&&String(j.$key)===String(K)):null;if(i._sapDetailRow=U?U.$el:null,i.tagName==="DIALOG"){let j=U?String(U.$key):null;if(j!==i._sapDetailKey&&(i._sapDetailKey=j,i._sapDismissed=!1),!U){i._sapOpenedFor=null,i.open&&typeof i.close=="function"&&(i._sapEngineClose=!0,i.close());return}i.open?i._sapOpenedFor=j:(i._sapOpenedFor===j&&(i._sapDismissed=!0),i._sapOpenedFor=null,!i._sapDismissed&&i.isConnected&&typeof i.showModal=="function"&&(i.hidden&&(i.hidden=!1),i.showModal(),i._sapOpenedFor=j))}else{if(!U){i.hidden||(i.hidden=!0);return}i.hidden&&(i.hidden=!1)}ue();let at={root:f.root,state:h,item:U,ownerEl:U.$el,projection:!0};d(i,vt(i),at),E(i,U,at)}function b(i,h){for(let f=i.parentElement;f;f=f.parentElement)if(f._sapScope===h&&!f.hasAttribute("detail")||f.hasAttribute("sap"))return f;return r}function v(i,h){i._sapDrawnEl=b(i,h.state);let f=null;for(let B=i.firstElementChild;B;B=B.nextElementSibling)if(B.tagName==="TEMPLATE"){f=B;break}let g=f&&f.content.children.length===1?f.content.firstElementChild:null;if(!g)return t.diag.error("E42",i,{attr:"each",problem:"each needs one <template> child with exactly one element root"}),0;let T=i.getAttribute("each"),I;try{I=Et(q(T),{state:h.state,item:h.item,el:i,root:h.root})}catch(B){return t.diag.error("E24",i,{attr:"each",expr:T,problem:String(B.message)}),0}if(!Array.isArray(I))return t.diag.error("E40",i,{attr:"each",expr:T,problem:"each must evaluate to an array; the list keeps its last good rows"}),0;let W=q(i.getAttribute("key")||"item.$key"),Y=[],K=new Set;for(let B of I){let J;try{J=dt(W,h.state,B,i,h.root)}catch{J=void 0}let D=J==null?"":String(J);if(D===""||K.has(D))return t.diag.error("E41",i,{attr:"key",expr:W.src,problem:D===""?"an item has no key; the list keeps its last good rows":`duplicate key "${D}"; the list keeps its last good rows`}),0;K.add(D),Y.push(D)}let U=i._sapEach||new Map,at=new Map,j=0,ee=f;Y.forEach((B,J)=>{let D=U.get(B);if(!D||D.parentElement!==i){D=i.ownerDocument.importNode(g,!0);let _t=(D.getAttribute("clay")||"").split(/\s+/).filter(Boolean);_t.includes("editor-ui")||D.setAttribute("clay",[..._t,"editor-ui"].join(" ")),D._sapEachRow=!0,j++}D.getAttribute("data-key")!==B&&D.setAttribute("data-key",B),ee.nextElementSibling!==D&&(nr(i,D,ee),j++),D._sapEachItem=I[J],at.set(B,D),ee=D});for(let[B,J]of U)at.get(B)!==J&&J.parentElement===i&&(J.remove(),j++);return i._sapEach=at,ue(),Y.forEach((B,J)=>{let D=at.get(B),_t={root:h.root,state:h.state,item:I[J],ownerEl:D,projection:!1,view:!0};d(D,vt(D),_t),E(D,{},_t)}),j}y(r,n,N);for(let i=0;i<A.length;i++){let{el:h,parentObj:f,ctx:g}=A[i];u(h,f,g)}if($.length&&w.size)for(let i of $)w.has(i.attr)&&i.el.getAttribute(i.attr)==null&&i.el.setAttribute(i.attr,i.value);let x=new Map;for(let i of o){let h=x.get(i.owner);h||(h={ownerEl:i.ownerEl,list:[]},x.set(i.owner,h)),h.list.push(i)}let L=[...x.values()].sort((i,h)=>sn(h.ownerEl)-sn(i.ownerEl));for(let i of L){let h;try{h=Oe(i.list)}catch(f){t.diag.error("E07",i.list[0].el,{problem:f.message}),h=i.list}for(let f of h)try{f.owner[f.name]=dt(f.entry,f.ctx.state,f.ctx.item,f.el,f.ctx.root),Ft(f.el)}catch(g){f.owner[f.name]=void 0,t.diag.error("E24",f.el,{attr:"calc:"+f.name,expr:f.entry.src,problem:String(g.message)}),ut(f.el,g.sapCode||"E24")}}let C=0;for(let i=0;i<l.length;i++)C+=v(l[i].el,l[i].ctx);let R=0,F=C;for(let i of s){let h=Zn(i,t);i.ctx.view?F+=h:R+=h}for(let i of a)tr(i,t);for(let i of k)er(i);t._state=n,t._stats={fields:Object.keys(n).filter(i=>typeof n[i]!="function").length,calcs:o.length,paints:s.length,lists:x.size,writes:R,viewWrites:F},t._viewsChanged=F>0,t._lastPass={trigger:e.trigger||"refresh",writes:R},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${R}/${s.length}`)}function Qn(t){return t.kind==="text"?t.fmt?"text:"+t.fmt:"text":t.kind==="attr"?"attr:"+t.arg:t.kind==="class"?"class:"+t.arg:t.kind==="css"?"css:"+t.arg:t.kind==="when"?(t.match==="hide"?"hide-when:":t.match==="show-not"?"option-not:":"show-when:")+t.field:t.kind}function he(t,e,r,n){let o=t;for(;o&&o.nodeType===1;){if(o.hasAttribute&&o.hasAttribute(e)){let s=r.includes(o.getAttribute(e));if(n?!s:s)return!0}o=o.parentElement}return!1}function rn(t,e){if(t===t.ownerDocument.activeElement)return 0;if(t.type==="radio"){let s=e!=null&&String(t.value)===String(e);return t.checked===s?0:(t.checked=s,1)}let r=Kt(t),n=de(t,r),o=e??"";return String(n)!==String(o)?(Ze(t,r,o),1):0}function Zn(t,e){let r=t.def,n=t.el;if(r.kind==="projection"){if(r.from==="drawn"){let o=r.field in t.ctx.state?t.ctx.state:t.ctx.root;return rn(n,o[r.field])}return rn(n,t.ctx.item?t.ctx.item[r.field]:"")}if(r.kind==="when")return on(r,n,null);try{let o=dt(r.entry,t.ctx.state,t.ctx.item,n,t.ctx.root),s=on(r,n,o);return Ft(n),s}catch(o){return e.diag.error(o.sapCode==="E22"?"E22":"E24",n,{attr:Qn(r),expr:r.entry&&r.entry.src,problem:String(o.message)}),ut(n,o.sapCode||"E24"),0}}function on(t,e,r){switch(t.kind){case"text":{let n=t.fmt!=null?Me(t.fmt,r):r==null?"":String(r);return e.textContent!==n?(e.textContent=n,1):0}case"show":{let n=!r;return e.hidden!==n?(e.hidden=n,1):0}case"when":{let n=X("optionVisibility");if(n&&n._started)return e._sapWhen&&e.hidden?(e.hidden=!1,e._sapWhen=!1,1):0;let o;t.match==="hide"?o=!he(e,t.field,t.values,!1):t.match==="show-not"?o=he(e,t.field,t.values,!0):o=he(e,t.field,t.values,!1),e._sapWhen=!0;let s=!o;return e.hidden!==s?(e.hidden=s,1):0}case"attr":{let n=t.arg;if((n==="checked"||n==="selected")&&typeof e[n]=="boolean"&&!e.hasAttribute("bind")&&!e.closest("select[bind]")){let s=0;return e[n]!==!!r&&(e[n]=!!r,s=1),!!r!==e.hasAttribute(n)&&(r?e.setAttribute(n,""):e.removeAttribute(n),s=1),s}if(Kn.has(n)){let s=e.hasAttribute(n);return r&&!s?(e.setAttribute(n,""),1):!r&&s?(e.removeAttribute(n),1):0}let o=typeof r=="boolean"?String(r):r==null?"":String(r);return e.getAttribute(n)!==o?(e.setAttribute(n,o),1):0}case"class":{let n=!!r;return e.classList.contains(t.arg)!==n?(e.classList.toggle(t.arg,n),1):0}case"css":{let n=r==null?"":String(r);return e.style.getPropertyValue("--"+t.arg)!==n?(e.style.setProperty("--"+t.arg,n),1):0}default:return 0}}function tr(t,e){try{dt(t.def.entry,t.ctx.state,t.ctx.item,t.el,t.ctx.root),Ft(t.el)}catch(r){e.diag.error("E24",t.el,{attr:"effect",expr:t.def.entry&&t.def.entry.src,problem:String(r.message)}),ut(t.el,"E24")}}function er(t){let e="";try{let r=dt(t.def.entry,t.ctx.state,t.ctx.item,t.el,t.ctx.root);e=typeof r=="string"?r:""}catch{e=""}typeof t.el.setCustomValidity=="function"&&t.el.setCustomValidity(e)}function sn(t){let e=0,r=t;for(;r&&!(r.hasAttribute&&r.hasAttribute("sap"));)r=r.parentElement,e++;return e}function nr(t,e,r){let n=r.nextSibling;if(e.isConnected&&t.moveBefore)try{t.moveBefore(e,n);return}catch{}t.insertBefore(e,n)}var rr=new Set(bt),an=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode"]),or=new Set(["show-when","hide-when","option","option-not"]),ir=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,un=new Set(["sap","scope","items","item","template","bind","show","effect","invalid","detail","state","transient","confirm","default","persist","sortable","trigger-add","trigger-remove","trigger-reset","sap-ignore","sap-error","no-save","no-watch","no-undo","no-trigger-autosave","freeze","mutations-ignore","save-remove","save-ignore","save-freeze"]);function sr(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function be(t){return t.hasAttribute("bind")}function ar(t,e){e(t);for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(!n.hasAttribute("sap-ignore")){if(n.tagName==="TEMPLATE"){if(n.hasAttribute("items"))for(let o=n.content.firstElementChild;o;o=o.nextElementSibling)r(o);return}e(n);for(let o=n.firstElementChild;o;o=o.nextElementSibling)r(o)}}}function Zt(t,e){let r=!1,n=(a,k,$)=>{e.error(a,k,$),r=!0},o=t.ownerDocument.createTreeWalker(t,4),s;for(;s=o.nextNode();)if(/\{\{.*\}\}/.test(s.nodeValue||"")){n("E02",s.parentElement||t,{problem:"moustaches in text content are not a Sap feature",fix:'move the expression onto the element: text="state.x"'});break}return ar(t,a=>{let k=a.closest&&a.closest("[detail]");for(let $ of[...a.attributes]){let A=$.name,l=ve(A);if(l){n("E01",a,{attr:A,expr:$.value,problem:`"${A}" is a foreign-dialect attribute; Sap has no ${A.split(/[:=]/)[0]} directive`,fix:l+" \u2014 or wrap the subtree in sap-ignore if intentional"});continue}if(A.includes(":")){let N=A.slice(0,A.indexOf(":"));if(an.has(N)){if(or.has(N)&&ir.test($.value)){let P=A.slice(A.indexOf(":")+1);e.warn("W04",a,{attr:A,expr:$.value,problem:`${N}: compares the "${P}" attribute against a literal value, not a JS expression`,fix:`use show="${$.value}" for an expression, or a literal like ${N}:${P}="overview"`})}}else{let P=Nt(N,[...an]);e.warn("W03",a,{attr:A,problem:`unknown "${N}:" attribute`,didYouMean:P?`${P}:`:null})}}else if(!un.has(A)&&!Tt.has(A)&&!rr.has(A)&&!/^(data-|aria-|on)/.test(A)&&!(A in a)){let N=Nt(A,[...un]);N&&e.warn("W03",a,{attr:A,problem:`unknown "${A}" attribute`,didYouMean:N})}A==="attr:hidden"&&e.warn("W03",a,{attr:A,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'});let w=be(a)||A==="attr:selected"&&a.tagName==="OPTION"&&!!a.closest("select[bind]");(A==="attr:value"||A==="attr:checked"||A==="attr:selected")&&w&&n("E30",a,{attr:A,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),A==="effect"&&be(a)&&/\b(value|checked)\s*=[^=]/.test($.value)&&n("E30",a,{attr:A,expr:$.value,problem:"effect writes value/checked on a bound control (writes a stale value with no synthetic event)",fix:"write through onclick + Sap(this) instead"}),(A==="text"||A.startsWith("text:")||A==="show")&&sr(a)&&(A==="show"||n("E18",a,{attr:A,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(a.hasAttribute("state")){let $=V(a.getAttribute("state")),A=new Set;for(let l of $){l.name.includes("-")&&n("E08",a,{attr:"state",problem:`field "${l.name}" is not a valid identifier (the hyphen parses as subtraction)`,fix:`rename to ${l.name.replace(/-/g,"")}`}),A.has(l.name)&&n("E04",a,{attr:"state",problem:`field "${l.name}" is declared twice in one scope`}),A.add(l.name),It.has(l.attr)&&n("E05",a,{attr:"state",problem:`"${l.name}" is a reserved Sap word`}),Tt.has(l.attr)&&n("E06",a,{attr:"state",problem:`"${l.name}" is a global HTML attribute name; pick another field name`}),l.name==="open"&&a.tagName==="DIALOG"&&n("E33",a,{attr:"state",problem:"dialog open is transient",fix:"use showModal() \u2014 declare state= only on <details> or popovers"});let w=se(a,l.attr);w&&(l.attr==="checked"||l.attr==="selected")&&n("E35",a,{attr:"state",problem:`"${l.attr}" on a form control is the control's own state, not a declared field`,fix:'bind the control instead, e.g. <input type="checkbox" bind="done">'}),w&&l.type==="num"&&n("E35",a,{attr:"state",problem:`"${l.attr}" is an HTML boolean attribute; it cannot hold a number`,fix:`declare it bare: state="${l.attr}"`}),l.transient&&(w||l.type==="presence")&&n("E35",a,{attr:"state",problem:`"${l.name}" is carried by attribute presence, which transient would strip`,fix:"declare a separate name:bool:transient field and paint the attribute from it"})}}if(be(a)){if(a.hasAttribute("-"),a.tagName==="INPUT"){let $=(a.getAttribute("type")||"text").toLowerCase();$==="file"&&n("E32",a,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),$==="password"&&!a.hasAttribute("transient")&&n("E31",a,{attr:"bind",problem:"a password must never serialize into a world-readable file",fix:"add transient to the password input"})}else if(a.tagName!=="SELECT"&&a.tagName!=="TEXTAREA"){let $=a.getAttribute("contenteditable");!($!=null&&$!=="false")&&a.children.length>0&&n("E20",a,{attr:"bind",problem:"bind on a container element is not a control; a write would overwrite its children",fix:"bind a control (input/select/textarea), a contenteditable, or an empty text leaf"})}}if(a.hasAttribute("transient")&&a.hasAttribute("persist")&&n("E34",a,{problem:"transient and persist are opposite: persist forces the live value into the saved bytes, leaking exactly what transient drops",fix:"remove one \u2014 transient to keep it out of the file, or persist to save it"}),a.tagName==="DIALOG"&&a.hasAttribute("detail")&&!(a.parentElement&&a.parentElement.closest('[clay~="freeze"], [freeze], [save-freeze]'))&&e.warn("W31",a,{attr:"detail",problem:"a detail dialog writes open when it opens, and that attribute would be saved into the file",fix:'wrap the dialog in an element with clay="freeze" (not editor-ui, which removes it from the file), and make its key field transient'}),a.hasAttribute("item")&&!a.hasAttribute("template")&&a.parentNode&&a.parentNode.nodeType===1){let $=a.parentElement;(!$||!$.hasAttribute("items"))&&n("E10",a,{problem:"an [item] must be a direct child of an [items] list",fix:'wrap it in a container with items="name"'})}if(a.hasAttribute("items")&&k&&n("E17",a,{attr:"items",problem:"nested items inside a detail panel is a v1 mount error (nested collections ship in v1.1)"}),a.hasAttribute("items")){let $=t.querySelector(`[trigger-add="${a.getAttribute("items")}"]`);!Vt(a)&&!oe(t,a.getAttribute("items"))&&rt(a).length===0&&$&&n("E17",a,{attr:"items",problem:`trigger-add targets items="${a.getAttribute("items")}" but it has no [item template] to clone`})}}),r&&(e.halted=!0,e.haltReason=e.errors[0]?e.errors[0].code:"halt",ut(t,e.haltReason)),!r}var cn="sap-styles",ln="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",ge=new WeakSet;function ur(t){if(ge.has(t))return;let e=t.defaultView,r=e&&e.CSSStyleSheet;if(r&&"adoptedStyleSheets"in t)try{let n=new r;n.replaceSync(ln),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],ge.add(t);return}catch{}if(!t.getElementById(cn)){let n=t.createElement("style");n.id=cn,n.textContent=ln,(t.head||t.documentElement).appendChild(n)}ge.add(t)}var cr=0;function fn(){return typeof performance<"u"&&performance.now?performance.now():0}function we(t){let e=t.id||t.getAttribute("sap")||`app-${cr++}`,r=new ht(e),n={root:t,name:e,diag:r,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Zt(t,r))return n.halted=!0,n;ur(t.ownerDocument);for(let a of t.querySelectorAll("textarea[data-value]"))Yt(a);let s=fn();return $t(n,{trigger:"mount",full:!0}),n._mountMs=fn()-s,n._mountWrites=n._stats?n._stats.writes:0,n._mountWrites>0&&!Ue()&&r.warn("W30",t,{problem:`${n._mountWrites} paint(s) ran at mount; the saved file was out of sync with its declared state`,fix:"re-save once so the file mounts clean (a settled file writes nothing)"}),n}var lr=["for","form","list","headers","popovertarget","commandfor","anchor","aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"];function fr(t,e){let r=null;return et(t,n=>{!r&&n.getAttribute("scope")===e&&(r=n)}),r}function dn(t,e,r){let n=Q(t)||e;for(;n;){for(let o of V(n.getAttribute("state")||""))if(o.name===r)return{el:n,decl:o};if(n.hasAttribute("sap"))break;n=Q(n.parentElement)}return null}function dr(t){return typeof t=="number"?"num":typeof t=="boolean"?"bool":"string"}function pn(t){function e(m){let d=t.appFor(m);if(!d)return null;let p=lt(m),y=p&&p._sapEachItem&&p._sapEachItem.$el;if(y&&y.isConnected)return{ctxEl:y,appRec:d,isRow:!0};let E=Lt(m);if(E)return E._sapDetailRow?{ctxEl:E._sapDetailRow,appRec:d,isRow:!0}:{ctxEl:Q(E.parentElement)||d.root,appRec:d,isRow:!1};let S=Wt(m);if(S&&S.hasAttribute("item"))return{ctxEl:S,appRec:d,isRow:!0};let _=Q(m)||d.root;return{ctxEl:_,appRec:d,isRow:_.hasAttribute("item")}}function r(m){let d=typeof m=="string"?document.querySelector(m):m;if(!d||d.nodeType!==1)return null;let p=e(d);return p?z(p.ctxEl,p.appRec,p.isRow):null}function n(m,d){let p=lt(m);if(!p)return r(m);let y=t.appFor(m),E=p._sapEachItem&&p._sapEachItem.$el;if(E&&E.nodeType===1&&E.hasAttribute("item")&&wt(E,d))return E.isConnected?z(E,y,!0):null;let S=p.parentElement&&p.parentElement._sapDrawnEl;return!S||!S.isConnected?null:z(S,y,S.hasAttribute("item"))}function o(m,d,p){let y=ft(m,p);if(y)return G(y).read();let E=gt(m,p);if(E)return rt(E).map(H=>z(H,d,!0));let S=fr(m,p);if(S)return z(S,d,!1);let _=dn(m,d.root,p);if(_)return _.decl.transient?zt(_.el,_.decl):$e(_.el,_.decl);let M=m._sapScope;return M?M[p]:void 0}function s(m,d,p,y,E){y.transient?Dt(m,y,p):Rt(m,y,p),t.schedule(E,"set:"+d)}function a(m,d){let p=new Set,y=Q(m)||d;for(;y;){for(let E of V(y.getAttribute("state")||""))p.add(E.name);if(y.hasAttribute("sap"))break;y=Q(y.parentElement)}return et(m,E=>{let S=E.getAttribute("bind");S&&p.add(S)}),p}function k(m,d,p,y){let E=ft(m,p);if(E){G(E).write(y);return}let S=m;for(;S;){for(let x of S.attributes)if(x.name==="calc:"+p){d.diag.error("E16",S,{attr:"calc:"+p,problem:`"${p}" is a computed field; computed fields are read-only`});return}if(S.hasAttribute("sap"))break;S=S.parentElement}let _=dn(m,d.root,p);if(_){s(_.el,p,y,_.decl,d);return}let M=a(m,d.root);M.delete(p);let H=p.length>=4?Nt(p,[...M]):null;if(H){d.diag.error("E12",m,{key:p,problem:`unknown state key "${p}"`,didYouMean:H});return}if(It.has(p)||Tt.has(p)){d.diag.error("E15",m,{key:p,problem:`cannot write undeclared field "${p}" \u2014 it is a reserved/global name and cannot become state`,fix:"pick a different field name, or declare it explicitly in a state= attribute"});return}let c=d.root,u=dr(y),b=c.getAttribute("state")||"",v=u==="string"?p:`${p}:${u}`;c.setAttribute("state",b?`${b} ${v}`:v),s(c,p,y,{name:p,attr:p,type:u,transient:!1},d)}function $(m){let d=m.ownerDocument,p=new Map,y=(E,S)=>{let _=Se(d),M=E.getAttribute(S);M&&S==="id"&&p.set(M,_),E.setAttribute(S,_)};m.querySelectorAll("[id]").forEach(E=>y(E,"id")),m.querySelectorAll("[data-id]").forEach(E=>y(E,"data-id")),m.querySelectorAll("[sap-error]").forEach(E=>E.removeAttribute("sap-error")),m.removeAttribute("sap-error"),m.hasAttribute("data-id")?(m.removeAttribute("id"),y(m,"data-id")):y(m,"id");for(let E of[m,...m.querySelectorAll("*")])for(let S of lr){let _=E.getAttribute(S);if(_==null)continue;let M=_.split(/\s+/).map(H=>p.get(H)||H).join(" ");M!==_&&E.setAttribute(S,M)}}function A(m,d,p){let y=Mt(d.root,m,p);if(!y)return d.diag.error("E17",m,{problem:`cannot resolve a list named "${p}" from here`}),null;let E=Vt(y);if(!E)return d.diag.error("E17",y,{problem:`items="${p}" has no [item template] to clone`}),null;let S=y.ownerDocument.importNode(E,!0);return S.removeAttribute("template"),$(S),y.appendChild(S),t.schedule(d,"trigger-add:"+p),z(S,d,!0)}function l(m,d){et(m,p=>{if(p.hasAttribute("bind")){let y=G(p),E=p.getAttribute("default");y.kind==="checkbox"||y.kind==="radio"?y.write(E!=null?E===""||E==="true"||p.value===E:p.hasAttribute("checked")):y.write(E??(p.getAttribute("value")||""))}});for(let p of V(m.getAttribute("state")||"")){let y=_e(m,p);p.transient?Dt(m,p,y):Rt(m,p,y)}t.schedule(d,"trigger-reset")}function w(m,d){if(!m.isConnected)throw new Error("stale row handle: $remove() on a removed row");m.remove(),t.schedule(d,"trigger-remove")}function N(m,d,p){if(!m.isConnected)throw new Error("stale row handle: $move() on a removed row");let y=null;if(p&&p.nodeType===1?y=p:typeof p=="string"&&(y=Mt(d.root,m,p)),!y){d.diag.error("E17",m,{problem:`$move() cannot resolve target "${p}"`});return}t.moveInto(y,m),t.schedule(d,"trigger-move")}function P(m){let d=m.parentElement;return d?rt(d).indexOf(m):-1}function z(m,d,p){let y={get $el(){return m},get $key(){return Bt(m,p?"row":"scope")},get $index(){return P(m)},$add(S){return A(m,d,S)},$reset(){return l(m,d),E},$remove(){w(m,d)},$move(S){N(m,d,S)},get $appRec(){return d}},E=new Proxy(y,{get(S,_){return typeof _=="symbol"||_[0]==="$"?S[_]:o(m,d,_)},set(S,_,M){return typeof _=="string"&&_[0]==="$"?(S[_]=M,!0):(k(m,d,_,M),!0)},has(S,_){return typeof _=="string"&&_[0]==="$"?_ in S:o(m,d,_)!==void 0}});return E}return{Sap:r,contextElFor:e,readField:o,writeField:k,makeProxy:z,writeTargetFor:n}}var pr=["trigger-add","trigger-remove","trigger-reset"];function mr(t){if(t.nodeType!==1)return!1;for(let e of t.attributes){let r=e.name;if(r.startsWith("set:")||r.startsWith("move:")||r.startsWith("sort:")||pr.includes(r))return!0}return!1}function hr(t,e){let r=t,n=e.parentElement;for(;r&&r!==n;){if(r.nodeType===1&&mr(r)&&!(r.tagName==="FORM"&&r.hasAttribute("trigger-add")))return r;r=r.parentElement}return null}function mn(t,e){let{Sap:r}=e;function n(c,u){let b=null,v=lt(c),x=Lt(c);if(v)b=v._sapEachItem??null;else if(x&&x._sapDetailRow)b=x._sapDetailRow._sapScope||null;else{let R=Wt(c);R&&R.hasAttribute("item")&&(b=R._sapScope||null)}return{state:(Q(c)||u.root)._sapScope||u._state||{},item:b,el:c,root:u._state||{}}}function o(c,u,b){if(!c.hasAttribute("confirm")){b();return}let v=c.getAttribute("confirm"),x=v,L=q(v);if(!L.error)try{let F=Et(L,n(c,u));(typeof F=="string"||typeof F=="number")&&(x=String(F))}catch{}let C=Ye();if(!C){window.confirm(x)&&b();return}if(c._sapGatePending)return;c._sapGatePending=!0;let R=()=>{c._sapGatePending=!1};C(x,()=>{R(),b()}).catch(R)}function s(c,u){for(let b of c.attributes){if(!b.name.startsWith("set:"))continue;let v=b.name.slice(4),x=q(b.value);if(x.error){u.diag.error("E08",c,{attr:b.name,expr:b.value,problem:String(x.error.message)});continue}let L;try{L=Et(x,n(c,u))}catch(R){u.diag.error("E24",c,{attr:b.name,expr:b.value,problem:String(R.message)});continue}let C=e.writeTargetFor(c,v);C&&(C[v]=L)}}function a(c){let u=lt(c);if(!u)return c.closest("[item]");let b=u._sapEachItem&&u._sapEachItem.$el;return b&&b.nodeType===1&&b.hasAttribute("item")?b:null}function k(c,u){let b=a(c);if(!b)return;let v=rt(b.parentElement),x=v.indexOf(b);u==="up"&&x>0?t.placeBefore(b,v[x-1]):u==="down"&&x<v.length-1&&t.placeBefore(v[x+1],b)}function $(c,u,b){if(u)return Mt(b.root,c,u);let v=c;for(;v;){if(v.hasAttribute&&v.hasAttribute("items"))return v;v=v.parentElement}let x=Q(c)||b.root,L=[];return et(x,C=>{C.hasAttribute("items")&&L.push(C)}),L[0]||null}function A(c,u){let b=c==null||c==="",v=u==null||u==="";if(b&&v)return 0;if(b)return 1;if(v)return-1;let x=Number(c),L=Number(u);return!Number.isNaN(x)&&!Number.isNaN(L)?x-L:String(c)<String(u)?-1:String(c)>String(u)?1:0}function l(c,u,b,v){let x=$(c,b,v);if(!x){v.diag.error("E17",c,{attr:"sort:"+u,problem:`no items list resolvable for sort:${u}`});return}let L=rt(x),C=h=>h._sapScope?h._sapScope[u]:void 0,R=[...L].sort((h,f)=>A(C(h),C(f))),i=R.every((h,f)=>h===L[f])?[...R].reverse():R;for(let h of i)t.moveInto(x,h);t.schedule(v,"sort:"+u)}function w(c){if(!c||c.hidden)return;let u=c.querySelector("[bind]:not([type=hidden]), [contenteditable]");u&&typeof u.focus=="function"&&u.focus()}function N(c,u){o(c,u,()=>{let b=r(c);for(let v of[...c.attributes]){let x=v.name;if(x==="trigger-remove")b&&b.$remove();else if(x==="trigger-reset")b&&b.$reset();else if(x==="trigger-add"){let L=b&&b.$add(v.value);L&&w(L.$el)}else x==="move:up"?(k(c,"up"),t.schedule(u,"move:up")):x==="move:down"?(k(c,"down"),t.schedule(u,"move:down")):x.startsWith("move:to")?b&&b.$move(v.value):x.startsWith("sort:")&&l(c,x.slice(5),v.value,u)}[...c.attributes].some(v=>v.name.startsWith("set:"))&&s(c,u)})}function P(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;let v=hr(u,b.root);v&&N(v,b)}function z(c){let u=G(c),b=c.getAttribute("default");u.kind==="checkbox"?u.write(b===""||b==="true"):u.write(b??"")}function m(c,u,b){let v=r(c);if(!v)return;let x=v.$add(b);if(!x)return;let L=[];et(c,C=>{C.hasAttribute("bind")&&L.push(C)});for(let C of L){if(C.type==="radio"&&!C.checked)continue;let R=C.getAttribute("bind"),F=ft(x.$el,R);F?G(F).write(G(C).read()):wt(x.$el,R)&&(x[R]=G(C).read())}L.forEach(z),L.length?typeof L[0].focus=="function"&&L[0].focus():w(x.$el)}function d(c){let u=c.target;if(!u||!u.hasAttribute||!u.hasAttribute("trigger-add"))return;let b=t.appFor(u);b&&(c.preventDefault(),o(u,b,()=>m(u,b,u.getAttribute("trigger-add"))))}function p(c){let u=c.target,b=t.appFor(u);b&&setTimeout(()=>{u.querySelectorAll("[bind]").forEach(v=>{v.dispatchEvent(new Event("input",{bubbles:!0})),v.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(b,"reset")},0)}function y(c){let u=t.appFor(c.target);u&&t.schedule(u,"toggle")}function E(c){let u=c.target;if(!u||u.tagName!=="DIALOG"||!u.hasAttribute("detail"))return;if(u._sapEngineClose){u._sapEngineClose=!1;return}if(u.open)return;let b=/^[\w.]+\s+by\s+state\.(\w+)\s*$/.exec(u.getAttribute("detail")||""),v=t.appFor(u);if(!b||!v)return;let x=V(u.getAttribute("state")||"").find(C=>C.name===b[1]);if(x){x.transient?Dt(u,x,""):Rt(u,x,""),t.schedule(v,"close");return}let L=r(u.parentElement);L&&L[b[1]]!==""&&(L[b[1]]="")}function S(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;u.hasAttribute("persist")&&!Xt(u)&&xt(u);let v=u.hasAttribute("bind")&&qt(u);if(!v&&u.hasAttribute("bind")&<(u)){let L=u.getAttribute("bind"),C=u._sapViewBind?e.writeTargetFor(u,L):null;C&&(C[L]=G(u).read());return}let x=Lt(u);if(x&&x._sapDetailRow&&u.hasAttribute("bind")&&!v){let L=x._sapDetailRow,C=u.getAttribute("bind"),R=ft(L,C);if(R&&R!==u){G(R).write(G(u).read());return}if(!R&&V(L.getAttribute("state")||"").some(F=>F.name===C)){e.writeField(L,b,C,G(u).read());return}}t.schedule(b,c.type+" "+(u.id||u.tagName.toLowerCase()))}function _(c){let u=c.detail||{};for(let b of[u.from,u.to,c.target]){if(!b||b.nodeType!==1)continue;let v=t.appFor(b);v&&t.schedule(v,"sorted")}}function M(c){if(c.key!=="ArrowUp"&&c.key!=="ArrowDown")return;let u=c.target;if(!u||u.nodeType!==1||u.tagName!=="INPUT"||!u.hasAttribute("bind")||!u.hasAttribute("step"))return;let b=(u.getAttribute("type")||"text").toLowerCase();if(b!=="text"&&b!=="tel"&&b!=="search"||!t.appFor(u))return;c.preventDefault();let x=Z(u.getAttribute("step"))||1,L=c.key==="ArrowUp"?1:-1,C=Z(u.value)+x*(c.shiftKey?10:1)*L,R=u.getAttribute("min"),F=u.getAttribute("max");R!==null&&R!==""&&C<Z(R)&&(C=Z(R)),F!==null&&F!==""&&C>Z(F)&&(C=Z(F)),G(u).write(String(Number(C.toFixed(2))))}function H(c=document){c.addEventListener("click",P),c.addEventListener("submit",d),c.addEventListener("reset",p),c.addEventListener("toggle",y,!0),c.addEventListener("close",E,!0),c.addEventListener("input",S),c.addEventListener("change",S),c.addEventListener("clay:sorted",_),c.addEventListener("keydown",M)}return{install:H}}var hn=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function ye(t){return`${t.tagName.toLowerCase()}[sap]`}function br(t){let e=0;for(let r of t.querySelectorAll("*"))for(let n of r.attributes)if(hn.test(n.name)){e++;break}for(let r of t.attributes)if(hn.test(r.name)){e++;break}return e}function bn(t){let e=[],r=n=>{for(let o of n.attributes){let s=o.name;(s.startsWith("calc:")||s==="text"||s.startsWith("text:")||s==="show"||s.startsWith("attr:")||s.startsWith("class:")||s.startsWith("css:")||s==="effect"||s==="invalid"||s.startsWith("set:")||s==="detail")&&e.push({el:n,attr:s,src:o.value})}};r(t);for(let n of t.querySelectorAll("*"))r(n);return e}function gn(t){function e(l){let w=l._stats||{},N=l.root;return{root:ye(N),fields:w.fields||0,calcs:w.calcs||0,paints:w.paints||0,actions:br(N),lists:(N.hasAttribute("items")?1:0)+N.querySelectorAll("[items]").length,rows:N.querySelectorAll("[item]:not([template])").length,warnings:l.diag.warnings.length,errors:l.diag.errors.length,mountWrites:l._mountWrites||0,ms:Math.round((l._mountMs||0)*10)/10,passes:l._passes||0,lastPass:l._lastPass||null,ok:l.diag.errors.length===0&&!l.halted}}function r(){let l=t.apps().map(e);return{ok:l.every(w=>w.ok),apps:l}}function n(l){let w=e(l);return w.ok?`sap \u2713 ${w.root} \xB7 fields ${w.fields} \xB7 calcs ${w.calcs} \xB7 paints ${w.paints} \xB7 actions ${w.actions} \xB7 lists ${w.lists} \xB7 rows ${w.rows} \xB7 warnings ${w.warnings} \xB7 mount writes ${w.mountWrites} \xB7 ${w.ms}ms`:`sap \u2717 ${w.root} \xB7 errors ${w.errors} \xB7 warnings ${w.warnings} \xB7 ${w.ms}ms`}function o(){for(let l of t.apps()){let w=n(l);l.diag.errors.length||l.halted?console.error(w):console.log(w)}}function s(){let l=[],w=[];for(let N of t.apps())l.push(...N.diag.errors),w.push(...N.diag.warnings);return{ok:l.length===0,errors:l,warnings:w,counts:{errors:l.length,warnings:w.length}}}function a(l){return l?typeof l=="string"?document.querySelector(l):l.nodeType===1?l:null:null}function k(l,w){let N=a(l);if(!N)return console.warn("sap why: element not found"),null;let P=[`sap why <${N.tagName.toLowerCase()}> \u2014 ${Ot(N)}`],z=[...N.attributes].filter(d=>/^(bind|text|show|effect|invalid|detail|calc:|text:|attr:|class:|css:|set:|state|items|scope)/.test(d.name));for(let d of z)P.push(` ${d.name}="${d.value}"`);let m=N;for(;m&&!m._sapScope;)m=m.parentElement;if(m&&m._sapScope){let d=m._sapScope,p=w?[w]:Object.keys(d);P.push(" reads:");for(let y of p){let E=d[y];typeof E!="function"&&P.push(` ${y} = ${JSON.stringify(Array.isArray(E)?`[${E.length} rows]`:E)}`)}}return P.push(" serialization: textContent and value/checked attributes save with the file; reads live from properties"),console.log(P.join(`
|
|
10
|
+
`)),null}function $(l){let w=l===void 0?!0:!!l;for(let N of t.apps())N._debug=w;return console.log(`sap debug ${w?"on":"off"} \u2014 per-pass headers will ${w?"":"no longer "}log`),w}function A(){let l=[],w=0;for(let d of t.apps()){let p=d.root,y=ye(p);w++;let E=new ht(d.name);Zt(p,E);for(let c of E.errors)l.push({code:c.code,severity:"error",message:`${y}: ${c.code} ${c.slug} at ${c.el}`});for(let c of E.warnings)l.push({code:c.code,severity:"warn",message:`${y}: ${c.code} ${c.slug} at ${c.el}`});w++,$t(d,{trigger:"doctor-dryrun"});let S=d._stats?d._stats.writes:0;S>0&&l.push({code:"W30",severity:"warn",message:`${y}: dry recompute wrote ${S} cells on a quiet page; an element is stale or non-idempotent`}),w++;let _=bn(p).map(c=>c.src).join(" \0 "),M=[];for(let c of[p,...p.querySelectorAll("[state]")])for(let u of V(c.getAttribute("state")||""))M.push(u.name);for(let c of M)new RegExp(`(state|item)\\.${c}\\b`).test(_)||l.push({code:"I33",severity:"info",message:`${y}: field "${c}" is declared but read nowhere (dead state)`});w++;let H=new Map;for(let c of p.querySelectorAll("[id]"))H.set(c.id,(H.get(c.id)||0)+1);for(let[c,u]of H)u>1&&l.push({code:"W32",severity:"warn",message:`${y}: duplicate id "${c}" (${u} elements) \u2014 clone/edit collision`});w++;for(let c of bn(p))c.src.length>120&&l.push({code:"I33",severity:"info",message:`${y}: ${c.attr} expression is ${c.src.length} chars; consider a calc: field`});w++;for(let c of p.querySelectorAll("[text], [text\\:num]")){let u=c.textContent||"";/\.\d{5,}/.test(u)&&l.push({code:"I33",severity:"info",message:`${y}: ${Ot(c)} paints >4 decimals; consider text:FMT`})}}let N=l.filter(d=>d.severity==="error").length,P=l.filter(d=>d.severity==="warn").length,z=l.filter(d=>d.severity==="info").length;console.log(`sap doctor \xB7 ${t.apps().map(d=>ye(d.root)).join(", ")} \xB7 errors ${N} \xB7 warnings ${P} \xB7 info ${z} \xB7 ${w} checks \xB7 0ms`);for(let d of l)(d.severity==="error"?console.error:d.severity==="warn"?console.warn:console.info)(` ${d.severity==="error"?"\u2717":d.severity==="warn"?"\u26A0":"\xB7"} ${d.message}`);return l}return{status:r,report:s,why:k,debug:$,doctor:A,greenLine:n,printGreenLines:o,REGISTRY:re}}var wn="0.5.2";var tt=new Map,it=[],Ae=Ee($t);function gr(t){let e=t;for(;e;){if(e.nodeType===1&&e.hasAttribute&&e.hasAttribute("sap"))return tt.get(e)||null;e=e.parentNode&&e.parentNode.host?e.parentNode.host:e.parentElement}return null}function wr(){for(let t=it.length-1;t>=0;t--){let e=it[t];e.root.isConnected||(tt.delete(e.root),it.splice(t,1))}}function yr(t,e){if(t.moveBefore)try{t.moveBefore(e,null);return}catch{}t.appendChild(e)}function Ar(t,e){let r=e.parentElement;if(r){if(r.moveBefore)try{r.moveBefore(t,e);return}catch{}r.insertBefore(t,e)}}var mt={apps:()=>it.slice(),appFor:gr,isRegistered:t=>tt.has(t),pruneDisconnected:wr,schedule:(t,e)=>Ae.schedule(t,e),runNow:(t,e)=>Ae.runNow(t,e),moveInto:yr,placeBefore:Ar,remountIfPresent:()=>te()},An=pn(mt),Er=mn(mt,An),st=gn(mt),yn=!1;function En(){yn||(yn=!0,Er.install(document),Ke(mt))}function te(t=document){En(),me(mt);let e=t.querySelectorAll("[sap]"),r=[];for(let n of e){if(tt.has(n))continue;let o=we(n);tt.set(n,o),it.push(o),r.push(o)}for(let n of r){let o=st.greenLine(n);n.diag.errors.length||n.halted?console.error(o):console.log(o)}return r}function vn(t){if(En(),me(mt),!t)return te();let e=typeof t=="string"?document.querySelector(t):t;if(!e)return null;if(tt.has(e))return tt.get(e);let r=we(e);tt.set(e,r),it.push(r);let n=st.greenLine(r);return r.diag.errors.length||r.halted?console.error(n):console.log(n),r}var O=An.Sap;O.version=wn;O.refresh=function(){for(let e of it)e.root.isConnected&&Ae.runNow(e,"refresh")};O.batch=Xe;O.status=st.status;O.report=st.report;O.why=st.why;O.debug=st.debug;O.doctor=st.doctor;O.greenLine=st.greenLine;O.formats=At;O.serializeControlToAttributes=xt;O.finalizeControlForSave=je;O.rehydrateControlFromAttributes=Yt;O.mount=vn;O.config=function(e={}){return e.formats&&Object.assign(At,e.formats),O};O._registry=tt;O._reset=function(){tt.clear(),it.length=0,nn()};function vr(){if(typeof document>"u")return;let t=()=>Ge(()=>te());document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}vr();typeof window<"u"&&(window.Sap=O);var xr=O;return Tn(Sr);})();
|
|
11
11
|
if (typeof window !== 'undefined' && Sap && Sap.default) window.Sap = Sap.default;
|
|
12
12
|
var sapDefault = Sap.default;
|
|
13
13
|
window.clay = window.clay || {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panphora/clayjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "clayjs: malleable documents. Save lifecycle for self-saving HTML.",
|
|
6
6
|
"license": "MIT-0",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"exports": {
|
|
30
30
|
"./package.json": "./package.json",
|
|
31
31
|
"./THIRD-PARTY-NOTICES.md": "./THIRD-PARTY-NOTICES.md",
|
|
32
|
+
"./guide.md": "./docs/guide.md",
|
|
32
33
|
"./src/*": "./src/*",
|
|
33
34
|
"./entries/*": "./entries/*",
|
|
34
35
|
"./clay.standalone.js": "./dist/clay.standalone.js",
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"entries/",
|
|
42
43
|
"dist/",
|
|
43
44
|
"THIRD-PARTY-NOTICES.md",
|
|
45
|
+
"docs/guide.md",
|
|
44
46
|
"src/"
|
|
45
47
|
],
|
|
46
48
|
"publishConfig": {
|
package/packed-contract.json
CHANGED
package/src/lib/unsaved-state.js
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
const sources = new Map();
|
|
12
12
|
let nextKey = 0;
|
|
13
13
|
|
|
14
|
-
export function registerUnsavedState({ id = '', isPending }) {
|
|
14
|
+
export function registerUnsavedState({ id = '', isPending, flush = null }) {
|
|
15
15
|
const key = ++nextKey;
|
|
16
|
-
sources.set(key, { id, isPending });
|
|
16
|
+
sources.set(key, { id, isPending, flush });
|
|
17
17
|
let disposed = false;
|
|
18
18
|
return {
|
|
19
19
|
changed() {
|
|
@@ -49,6 +49,15 @@ export function hasUnsavedState() {
|
|
|
49
49
|
return false;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
// Ask every pending source that can finish on its own (a checkpoint, a queued
|
|
53
|
+
// upload) to do so, and wait. Sources without a flush (an open composition)
|
|
54
|
+
// stay pending; they are listed in the answer, never waited on.
|
|
55
|
+
export async function flushUnsaved() {
|
|
56
|
+
const flushes = [...sources.values()].filter((s) => typeof s.flush === 'function' && isPending(s));
|
|
57
|
+
const results = await Promise.all(flushes.map((s) => Promise.resolve().then(s.flush).catch(() => ({ ok: false }))));
|
|
58
|
+
return { ok: results.every((r) => r?.ok !== false), pending: pendingIds() };
|
|
59
|
+
}
|
|
60
|
+
|
|
52
61
|
if (typeof window !== 'undefined') {
|
|
53
62
|
window.clay = window.clay || {};
|
|
54
63
|
window.clay.registerUnsavedState = registerUnsavedState;
|
package/src/live/checkpoint.js
CHANGED
|
@@ -95,6 +95,13 @@ export function createCheckpoints({ needsSave, blocked, save, saveNow, now = ()
|
|
|
95
95
|
const at = Math.max(now(), retryAt);
|
|
96
96
|
if (deadline === null || at < deadline) arm(at);
|
|
97
97
|
},
|
|
98
|
+
// Save no later than ms from now (the page editor's pause save). Never
|
|
99
|
+
// later than a deadline already set, never before a failed save's retry time.
|
|
100
|
+
within(ms) {
|
|
101
|
+
if (running) return;
|
|
102
|
+
const at = Math.max(now() + ms, retryAt);
|
|
103
|
+
if (deadline === null || at < deadline) arm(at);
|
|
104
|
+
},
|
|
98
105
|
// True while the hide/close save is being made.
|
|
99
106
|
get flushing() {
|
|
100
107
|
return flushing;
|
package/src/live/fast-lane.js
CHANGED
|
@@ -91,6 +91,8 @@ export function createFastLane({
|
|
|
91
91
|
// newest op id ever put in a frame.
|
|
92
92
|
const lanes = new Map();
|
|
93
93
|
|
|
94
|
+
const tell = (name, event) => entries.get(name)?.store.deliver?.({ code: null, n: null, seq: null, through: null, retryAfter: null, ...event });
|
|
95
|
+
|
|
94
96
|
function laneOf(name) {
|
|
95
97
|
let lane = lanes.get(name);
|
|
96
98
|
if (!lane) lanes.set(name, (lane = { n: 0, unsent: [], awaiting: [], framed: 0 }));
|
|
@@ -115,7 +117,7 @@ export function createFastLane({
|
|
|
115
117
|
const store = entries.get(name)?.store;
|
|
116
118
|
let through = 0;
|
|
117
119
|
for (const frame of lane.awaiting) if (!unapplied(frame)) through = frame.through;
|
|
118
|
-
if (store && through) store.rebase(store.authoritative, { source: "state", through });
|
|
120
|
+
if (store && through) store.rebase(store.authoritative, { source: "state", through, cause: "leave" });
|
|
119
121
|
onLeave(name, { epoch, seq });
|
|
120
122
|
lane.unsent = [];
|
|
121
123
|
lane.awaiting = [];
|
|
@@ -156,7 +158,8 @@ export function createFastLane({
|
|
|
156
158
|
const [entry] = lane.unsent.splice(0, 1);
|
|
157
159
|
console.warn(`clay.live("${name}"): one update was larger than ${FRAME_BYTES} bytes, so it was undone`);
|
|
158
160
|
const store = entries.get(name)?.store;
|
|
159
|
-
store?.rebase(store.authoritative, { source: "state", through: entry.id });
|
|
161
|
+
store?.rebase(store.authoritative, { source: "state", through: entry.id, cause: "undone" });
|
|
162
|
+
tell(name, { phase: "undone", code: "op-too-large", through: entry.id });
|
|
160
163
|
continue;
|
|
161
164
|
}
|
|
162
165
|
const take = lane.unsent.splice(0, count);
|
|
@@ -178,6 +181,7 @@ export function createFastLane({
|
|
|
178
181
|
const sentEpoch = epoch;
|
|
179
182
|
frame.sentOn = connection;
|
|
180
183
|
frame.sent = true;
|
|
184
|
+
tell(name, { phase: "sent", n: frame.n, through: frame.through });
|
|
181
185
|
// Refusal is evidence about earlier attempts only: this one may apply.
|
|
182
186
|
frame.refused = false;
|
|
183
187
|
inFlight = true;
|
|
@@ -212,7 +216,7 @@ export function createFastLane({
|
|
|
212
216
|
}
|
|
213
217
|
lane.awaiting.splice(lane.awaiting.indexOf(frame), 1);
|
|
214
218
|
const store = entries.get(name)?.store;
|
|
215
|
-
store?.rebase(store.authoritative, { source: "state", through: frame.through });
|
|
219
|
+
store?.rebase(store.authoritative, { source: "state", through: frame.through, cause: "decided" });
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
// Every frame the room ordered at or before the applied seq is in the
|
|
@@ -225,7 +229,7 @@ export function createFastLane({
|
|
|
225
229
|
}
|
|
226
230
|
if (through === undefined) continue;
|
|
227
231
|
const store = entries.get(name)?.store;
|
|
228
|
-
store?.rebase(store.authoritative, { source: "state", through });
|
|
232
|
+
store?.rebase(store.authoritative, { source: "state", through, cause: "settled" });
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
|
|
@@ -246,12 +250,14 @@ export function createFastLane({
|
|
|
246
250
|
return;
|
|
247
251
|
}
|
|
248
252
|
frame.seq = Number.isInteger(body?.seq) ? body.seq : null;
|
|
253
|
+
tell(name, { phase: "landed", n: frame.n, seq: frame.seq, through: frame.through });
|
|
249
254
|
// Its event already went by, or came inside a state this tab took: the ops are in.
|
|
250
255
|
settleAwaiting();
|
|
251
256
|
return;
|
|
252
257
|
}
|
|
253
258
|
if (transient(status)) {
|
|
254
259
|
frame.sent = false;
|
|
260
|
+
tell(name, { phase: "retry", code: body?.code ?? (status === 0 ? "offline" : status === 429 ? "rate-limited" : "server"), n: frame.n, through: frame.through, retryAfter: retryAfter ?? null });
|
|
255
261
|
if (unhandled(status)) frame.refused = true;
|
|
256
262
|
else {
|
|
257
263
|
frame.uncertain = true;
|
|
@@ -268,6 +274,7 @@ export function createFastLane({
|
|
|
268
274
|
// The room holds a receipt for every connected sender and has no room for
|
|
269
275
|
// this one: this store goes at save speed until the room takes it back.
|
|
270
276
|
if (status === 503 && body?.code === "busy") {
|
|
277
|
+
tell(name, { phase: "left", code: "busy", n: frame.n, through: frame.through });
|
|
271
278
|
console.warn(`clay.live("${name}"): the room is full, so it stays at save speed for now`);
|
|
272
279
|
roomNames.delete(name);
|
|
273
280
|
leaveRoom(name, lane);
|
|
@@ -285,12 +292,14 @@ export function createFastLane({
|
|
|
285
292
|
return;
|
|
286
293
|
}
|
|
287
294
|
if (REVOKED.has(status)) {
|
|
295
|
+
tell(name, { phase: "refused", code: "revoked", n: frame.n, through: frame.through });
|
|
288
296
|
if (!frame.uncertain) frame.refused = true;
|
|
289
297
|
stop();
|
|
290
298
|
return;
|
|
291
299
|
}
|
|
292
300
|
const reason = body?.error || body?.code || `status ${status}`;
|
|
293
301
|
if (status === 404) {
|
|
302
|
+
tell(name, { phase: "left", code: "no-store", n: frame.n, through: frame.through });
|
|
294
303
|
console.warn(`clay.live("${name}"): the room has no such store, so it stays at save speed (${reason})`);
|
|
295
304
|
frame.refused = true;
|
|
296
305
|
roomNames.delete(name);
|
|
@@ -299,8 +308,9 @@ export function createFastLane({
|
|
|
299
308
|
}
|
|
300
309
|
lane.awaiting.splice(lane.awaiting.indexOf(frame), 1);
|
|
301
310
|
const store = entries.get(name)?.store;
|
|
311
|
+
tell(name, { phase: "refused", code: body?.code ?? "refused", n: frame.n, through: frame.through });
|
|
302
312
|
console.warn(`clay.live("${name}"): the host refused an update, so it was undone (${reason})`);
|
|
303
|
-
store?.rebase(store.authoritative, { source: "state", through: frame.through });
|
|
313
|
+
store?.rebase(store.authoritative, { source: "state", through: frame.through, cause: "refused" });
|
|
304
314
|
}
|
|
305
315
|
|
|
306
316
|
function apply(frame) {
|
|
@@ -321,10 +331,11 @@ export function createFastLane({
|
|
|
321
331
|
const i = lane.awaiting.findIndex((sent) => sent.n === frame.n);
|
|
322
332
|
if (i >= 0) {
|
|
323
333
|
through = lane.awaiting[i].through;
|
|
334
|
+
tell(frame.name, { phase: "echoed", n: frame.n, seq: frame.seq, through });
|
|
324
335
|
lane.awaiting.splice(0, i + 1);
|
|
325
336
|
}
|
|
326
337
|
}
|
|
327
|
-
store.rebase(next, { source: own ? "state" : "remote", through });
|
|
338
|
+
store.rebase(next, { source: own ? "state" : "remote", through, frame: { seq: frame.seq, from: frame.from, n: frame.n, ops: frame.ops } });
|
|
328
339
|
entries.get(frame.name).last = frame.seq;
|
|
329
340
|
onApplied();
|
|
330
341
|
if (frame.checkpoint === true) onCheckpoint();
|
|
@@ -411,7 +422,7 @@ export function createFastLane({
|
|
|
411
422
|
frame.seq = null;
|
|
412
423
|
}
|
|
413
424
|
lane.awaiting = resend;
|
|
414
|
-
entry.store.rebase(room.value, { source: "state", through: through || undefined });
|
|
425
|
+
entry.store.rebase(room.value, { source: "state", through: through || undefined, room: { seq, fresh: true, moves: state.moves?.[name] ?? null, floor: Number.isInteger(room.floor) ? room.floor : null } });
|
|
415
426
|
lane.unsent = unframed(name, lane);
|
|
416
427
|
} else {
|
|
417
428
|
const seen = room.seen ? room.seen[clientId] : undefined;
|
|
@@ -439,7 +450,7 @@ export function createFastLane({
|
|
|
439
450
|
}
|
|
440
451
|
}
|
|
441
452
|
lane.awaiting = next;
|
|
442
|
-
entry.store.rebase(room.value, { source: "state", through });
|
|
453
|
+
entry.store.rebase(room.value, { source: "state", through, room: { seq, fresh: false, moves: state.moves?.[name] ?? null, floor: Number.isInteger(room.floor) ? room.floor : null } });
|
|
443
454
|
// Back in the room after a spell at save speed: frame what was made meanwhile.
|
|
444
455
|
if (rejoined) {
|
|
445
456
|
lane.unsent = unframed(name, lane);
|
|
@@ -476,7 +487,7 @@ export function createFastLane({
|
|
|
476
487
|
const asked = { connection, stateCount };
|
|
477
488
|
let state = null;
|
|
478
489
|
try {
|
|
479
|
-
state = await transport.fetchState(clientId);
|
|
490
|
+
state = await transport.fetchState(clientId, epoch !== null && seq > 0 ? { epoch, seq } : null);
|
|
480
491
|
} catch {}
|
|
481
492
|
fetching = false;
|
|
482
493
|
if (stopped) return;
|
|
@@ -544,7 +555,10 @@ export function createFastLane({
|
|
|
544
555
|
stateCount++;
|
|
545
556
|
for (const [name, landed] of Object.entries(data.landed)) {
|
|
546
557
|
const entry = entries.get(name);
|
|
547
|
-
if (entry && Number.isInteger(landed))
|
|
558
|
+
if (entry && Number.isInteger(landed)) {
|
|
559
|
+
entry.landed = landed;
|
|
560
|
+
tell(name, { phase: "checkpointed", seq: landed });
|
|
561
|
+
}
|
|
548
562
|
}
|
|
549
563
|
onLanded();
|
|
550
564
|
}
|