@panphora/clayjs 1.13.1 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +19 -0
- package/dist/clay.standalone.js +69385 -40992
- package/dist/server/checkpoint.cjs +1 -0
- package/dist/server/checkpoint.mjs +8 -0
- package/dist/server/core.cjs +72210 -0
- package/dist/server/rooms.cjs +1 -0
- package/dist/server/rooms.mjs +66 -0
- package/docs/guide.md +127 -99
- package/entries/clay.js +22 -0
- package/entries/sap.js +5 -5
- package/package.json +16 -2
- package/packed-contract.json +18 -3
- package/src/core/boot-phase.js +6 -0
- package/src/core/conflict-download.js +12 -3
- package/src/core/host-meta.js +75 -0
- package/src/core/persist.js +11 -0
- package/src/core/save-core.js +266 -31
- package/src/core/save.js +154 -36
- package/src/core/snapshot.js +51 -13
- package/src/core/style-comparisons.js +37 -0
- package/src/dom/insert-style-tag.js +11 -12
- package/src/lib/derived.js +116 -0
- package/src/lib/effect.js +130 -0
- package/src/lib/mutation.js +3 -1
- package/src/lib/style-adoption.js +9 -0
- package/src/lib/style.js +47 -0
- package/src/live/fast-lane.js +347 -60
- package/src/live/local-lane.js +32 -6
- package/src/live/ops.js +77 -0
- package/src/live/provenance.js +129 -0
- package/src/live/save-history.js +188 -0
- package/src/live/server-lane.js +9 -2
- package/src/live/store.js +194 -16
- package/src/loader-logic.js +16 -4
- package/src/loader.js +37 -1
- package/src/page/address.js +20 -0
- package/src/page/adopt-boot.js +189 -0
- package/src/page/adopt.js +240 -0
- package/src/page/ai-tool.js +188 -0
- package/src/page/announce.js +21 -0
- package/src/page/blocks.js +1170 -0
- package/src/page/blocksel.js +269 -0
- package/src/page/board-drag.js +226 -0
- package/src/page/board-panel.js +353 -0
- package/src/page/board-style.js +146 -0
- package/src/page/board-view.js +447 -0
- package/src/page/board.js +41 -0
- package/src/page/chart.js +220 -0
- package/src/page/checklist.js +143 -0
- package/src/page/chrome.js +587 -0
- package/src/page/csv-import.js +169 -0
- package/src/page/drag.js +202 -0
- package/src/page/drop.js +112 -0
- package/src/page/editor.js +386 -0
- package/src/page/highlight.js +268 -0
- package/src/page/inline.js +60 -1
- package/src/page/items.js +159 -0
- package/src/page/link.js +247 -0
- package/src/page/markdown.js +71 -0
- package/src/page/media.js +570 -0
- package/src/page/merge.js +130 -0
- package/src/page/model.js +71 -9
- package/src/page/placeholder.js +23 -0
- package/src/page/projection.js +647 -0
- package/src/page/recover.js +193 -0
- package/src/page/rich/cell.js +16 -0
- package/src/page/rich/chart.js +104 -0
- package/src/page/rich/csv.js +118 -0
- package/src/page/rich/page-tool.js +86 -0
- package/src/page/rich/tool-runtime.js +195 -0
- package/src/page/save-projection.js +53 -0
- package/src/page/save-states.js +85 -0
- package/src/page/schema.js +12 -5
- package/src/page/table-kinds.js +20 -0
- package/src/page/table-paste.js +57 -0
- package/src/page/table-select.js +244 -0
- package/src/page/table-style.js +25 -0
- package/src/page/table.js +650 -0
- package/src/page/themes/content.css +46 -0
- package/src/page/themes/light-1.css +269 -0
- package/src/page/themes/light-2.css +211 -0
- package/src/page/themes/light-3.css +130 -0
- package/src/page/themes/light-4.css +299 -0
- package/src/page/tool-data.js +25 -0
- package/src/page/tool-view.js +68 -0
- package/src/page/tools.js +133 -0
- package/src/page/view.js +136 -0
- package/src/page/ybind/author.js +25 -0
- package/src/page/ybind/binding.js +92 -0
- package/src/page/ybind/board-commands.js +170 -0
- package/src/page/ybind/board.js +89 -0
- package/src/page/ybind/bridge.js +382 -0
- package/src/page/ybind/conversion.js +26 -0
- package/src/page/ybind/core.js +7 -0
- package/src/page/ybind/decode.js +208 -0
- package/src/page/ybind/doc.js +58 -0
- package/src/page/ybind/external.js +190 -0
- package/src/page/ybind/group.js +124 -0
- package/src/page/ybind/index.js +12 -0
- package/src/page/ybind/layout.js +27 -0
- package/src/page/ybind/marks.js +18 -0
- package/src/page/ybind/migrate.js +152 -0
- package/src/page/ybind/moves.js +288 -0
- package/src/page/ybind/origins.js +257 -0
- package/src/page/ybind/parts.js +44 -0
- package/src/page/ybind/projection-map.js +92 -0
- package/src/page/ybind/provider.js +285 -0
- package/src/page/ybind/recovery.js +411 -0
- package/src/page/ybind/seed.js +27 -0
- package/src/page/ybind/table.js +166 -0
- package/src/page/ybind/tokens.js +93 -0
- package/src/page/ybind/walk.js +333 -0
- package/src/page/ybind/writer.js +307 -0
- package/src/plugins/derive.js +12 -0
- package/src/plugins/indicator.js +16 -6
- package/src/plugins/live.js +742 -65
- package/src/plugins/page.js +547 -0
- package/src/plugins/undo.js +62 -4
- package/src/server/checkpoint/index.js +218 -0
- package/src/server/rooms/index.js +59 -0
- package/src/server/rooms/live-data-ops.js +369 -0
- package/src/server/rooms/live-data-rooms.js +965 -0
- package/src/server/rooms/live-data-tags.js +49 -0
- package/src/server/rooms/live-page-history.js +41 -0
- package/src/server/rooms/live-provenance.js +142 -0
- package/src/server/rooms/page-admission.js +79 -0
- package/src/server/rooms/page-conversion.js +62 -0
- package/src/server/rooms/page-rebase.js +108 -0
- package/src/server/rooms/page-state.js +91 -0
- package/src/server/rooms/page-write-admission.js +63 -0
- package/src/server/rooms/page-write-guard.js +23 -0
- package/src/server/rooms/recent.js +18 -0
- package/src/server/rooms/spec-wire.js +17 -0
- package/src/standalone.js +22 -0
- package/src/sync/conflict-revert.js +2 -0
- package/src/sync/conflicts.js +2 -2
- package/src/sync/live-sync.js +36 -8
- package/src/sync/stream.js +62 -16
- package/src/ui/index.js +4 -0
- package/src/ui/toast.js +21 -5
- package/src/vendor/pierre/pierre.vendor.js +3 -0
- package/src/vendor/sap-core.vendor.js +9 -0
- package/src/vendor/sap-ownership.vendor.js +111 -0
- package/src/vendor/yjs.vendor.js +7 -0
- package/src/page/binding.js +0 -647
- package/src/page/replay.js +0 -578
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
|
|
4
|
+
var Sap=(()=>{var Ot=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var hn=Object.getOwnPropertyNames;var bn=Object.prototype.hasOwnProperty;var gn=(t,e)=>{for(var r in e)Ot(t,r,{get:e[r],enumerable:!0})},wn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of hn(e))!bn.call(t,o)&&o!==r&&Ot(t,o,{get:()=>e[o],enumerable:!(n=mn(e,o))||n.enumerable});return t};var yn=t=>wn(Ot({},"__esModule",{value:!0}),t);var hr={};gn(hr,{Sap:()=>Mt,default:()=>mr,mount:()=>dr,mountAll:()=>pn,runtime:()=>pr});function ee(t){let e=!1,r=new Set,n=[];function o(u){u&&(n.push(u),n.length>8&&n.shift())}function s(u,E){o(E),!u._broken&&(r.add(u),!e&&(e=!0,queueMicrotask(a)))}function a(){e=!1;let u=[...r];r.clear();for(let E of u)g(E)}function g(u,E=!1){if(!(u._broken||u.halted)){if(u._passes=(u._passes||0)+1,u._passes>50){u._broken=!0,u._breakerRing=n.slice(),t(u,{breaker:!0});return}u._resetArmed||(u._resetArmed=!0,setTimeout(()=>{u._passes=0,u._resetArmed=!1},0)),t(u,E?{full:!0}:{})}}function b(u,E){o(E),g(u,!0)}function d(u){u._broken=!1,u._passes=0}return{schedule:s,runNow:b,rearm:d,ring:n}}var Bt={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"},E50:{slug:"needs-full-sapjs",behavior:"HALT"},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"}},J=["disabled","readonly","required","checked","selected","multiple","open","inert","autofocus","novalidate","hidden"],at=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"]),wt=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 yt(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 g=r.parentElement.firstElementChild;g;g=g.nextElementSibling)g.tagName===r.tagName&&(s++,g===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(" > ")}var K=class{constructor(e){this.appName=e,this.errors=[],this.warnings=[],this.halted=!1,this.haltReason=null}block(e,r,n={}){let o=(Bt[e]||{}).slug||"error",s={code:e,slug:o,el:yt(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
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
|
|
7
|
-
${t}`:`"use strict"; return (${t});`;n={fn:new Function(...
|
|
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 M(t,e){t&&t.getAttribute("sap-error")!==e&&t.setAttribute("sap-error",e)}function Q(t){t&&t.hasAttribute("sap-error")&&t.removeAttribute("sap-error")}function ut(t,e){let r=null,n=3;for(let o of e){let s=An(t,o);s<n&&(n=s,r=o)}return r}function An(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 En=new Set(J),vn={readonly:"readOnly",novalidate:"noValidate"},xn=0,ne=new WeakMap;function At(t,e="sap"){let r=t.getAttribute("data-id");if(r)return r;if(t.id)return t.id;let n=ne.get(t);return n||(n=`${e}-${(xn++).toString(36)}`,ne.set(t,n)),n}function re(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 Sn(t){return t.hasAttribute("scope")||t.hasAttribute("items")||t.hasAttribute("detail")||t.hasAttribute("each")}function kn(t){return t.tagName==="TEMPLATE"||t.hasAttribute("sap-ignore")||t.hasAttribute("template")||t.hasAttribute("cms-template")}function O(t,e){for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(kn(n))return;let o=Sn(n);if(e(n,o),!o)for(let s=n.firstElementChild;s;s=s.nextElementSibling)r(s)}}function F(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 H(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 Et(t){let e=t;for(;e;){if(e.hasAttribute("detail")||e.hasAttribute("item"))return e;e=e.parentElement}return null}function ct(t){let e=t;for(;e;){if(e.hasAttribute("detail"))return e;e=e.parentElement}return null}function U(t,e){if(t.hasAttribute("item")&&t.getAttribute("bind")===e)return t;let r=null;return O(t,n=>{!r&&n.getAttribute("bind")===e&&(r=n)}),r}function Z(t,e){let r=null;return O(t,n=>{!r&&n.getAttribute("items")===e&&(r=n)}),r}function tt(t,e){return!t||t.nodeType!==1||!t.hasAttribute("item")?!1:U(t,e)||Z(t,e)?!0:C(t.getAttribute("state")||"").some(r=>r.name===e)}function oe(t){let e=t&&t.$el;return e&&e.nodeType===1&&e.isConnected&&e.hasAttribute("item")?e:null}function vt(t){return!!t.closest("form[trigger-add]")}function W(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 Wt(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 xt(t){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(e.hasAttribute("item")&&e.hasAttribute("template"))return e;return Wt(t.closest("[sap]"),t.getAttribute("items"))}function C(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(":"),g=a[0],b="string",d=!1;for(let S of a.slice(1))S==="num"?b="num":S==="bool"?b="bool":S==="presence"?b="presence":S==="transient"&&(d=!0);let u=g,E=u.startsWith("data-")&&u.length>5?u.slice(5).replace(/-([a-z])/g,(S,k)=>k.toUpperCase()):u;e.push({name:E,attr:u,type:b,default:o,transient:d})}return e}function z(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 qt(t,e){return e==="bool"?t?"true":"false":t==null?"":String(t)}function jt(t,e){return En.has(e)&&typeof t[vn[e]||e]=="boolean"}function G(t,e){return e.type==="presence"||e.type!=="num"&&jt(t,e.attr||e.name)}function ft(t){return t.default!=null?t.default:t.type==="num"?"0":t.type==="bool"?"false":""}function ie(t,e){let r=e.attr||e.name;if(G(t,e))return t.hasAttribute(r);let n=t.getAttribute(r);return z(n??ft(e),e.type)}function se(t,e){return G(t,e)?e.default!=null?z(e.default,"bool"):!1:z(ft(e),e.type)}function lt(t,e,r){let n=e.attr||e.name;if(G(t,e)){r?t.hasAttribute(n)||t.setAttribute(n,""):t.hasAttribute(n)&&t.removeAttribute(n);return}t.setAttribute(n,qt(r,e.type))}function St(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=ft(e)),n[e.name]=z(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 pt(t,e,r){let n=String(r).split("."),o=n[n.length-1];if(n.length===1){let g=$n(e,o);return g||(t.getAttribute("items")===o?t:t.querySelector(`[items="${o}"]:not(template)`))}let s=n[n.length-2],a=[...t.querySelectorAll(`[scope="${s}"]`)].find(g=>Z(g,o));return a?Z(a,o):null}function $n(t,e){let r=F(t);for(;r;){if(r.getAttribute("items")===e)return r;let n=Z(r,e);if(n)return n;r=F(r.parentElement)}return null}function P(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 kt(t,e){return Array.isArray(t)?e==null?t:t.map(r=>typeof e=="function"?e(r):r?.[e]):[]}function Vt(t,e){return kt(t,e).reduce((r,n)=>r+P(n),0)}function ae(t,e){return Array.isArray(t)?e==null?t.length:t.reduce((r,n)=>r+(e(n)?1:0),0):0}function ue(t,e){let r=kt(t,e);return r.length?Vt(t,e)/r.length:0}function ce(t,e){let r=kt(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 fe(t,e){let r=kt(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 le(t,e,r){let n=P(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 B(t){return typeof t=="number"?t:Number(t)}var et={usd:t=>"$"+B(t).toLocaleString("en-US",{maximumFractionDigits:0}),usd2:t=>"$"+B(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),pct:t=>Math.round(B(t))+"%",pct1:t=>B(t).toFixed(1)+"%",int:t=>Math.round(B(t)).toLocaleString("en-US"),num:t=>B(t).toLocaleString("en-US"),num2:t=>B(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),compact:t=>B(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=B(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}`}},_n=new Set(["usd","usd2","pct","pct1","int","num","num2","compact","clock"]);function pe(t,e){if(!t)return e==null?"":String(e);let r=et[t];if(typeof r!="function"){let n=new Error(`unknown format "${t}"`);throw n.sapCode="E22",n}if(_n.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 Tn=["state","item","el","root","fmt","num","sum","count","avg","min","max","plural","days"],$t=new Map,me=/\bstate\.([a-z][a-z0-9_]*)/g,he=/\bitem\.([a-z][a-z0-9_]*)/g;function Nn(t){let e=new Set,r=new Set,n;for(me.lastIndex=0;n=me.exec(t);)e.add(n[1]);for(he.lastIndex=0;n=he.exec(t);)r.add(n[1]);return{state:e,item:r}}function N(t,e=!1){let r=(e?"!":"")+t,n=$t.get(r);if(n)return n;$t.size>512&&$t.clear();try{let o=e?`"use strict";
|
|
7
|
+
${t}`:`"use strict"; return (${t});`;n={fn:new Function(...Tn,o),src:t,statement:e,deps:Nn(t),error:null}}catch(o){n={fn:null,src:t,statement:e,deps:{state:new Set,item:new Set},error:o}}return $t.set(r,n),n}function Y(t,e){return I(t,e.state,e.item,e.el??null,e.root)}function I(t,e,r,n,o){if(t.error)throw t.error;return t.fn(e,r,n,o,et,P,Vt,ae,ue,ce,fe,le,de)}function be(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 g=n.get(a.name);if(g!==1){if(g===0){let b=[...o.slice(o.indexOf(a.name)),a.name].join(" -> "),d=new Error(`calc: cycle: ${b}`);throw d.sapCode="E07",d.cycle=b,d}n.set(a.name,0),o.push(a.name);for(let b of a.entry.deps.state){let d=e.get(b);d&&d!==a&&s(d)}for(let b of a.entry.deps.item){let d=e.get(b);d&&d!==a&&s(d)}o.pop(),n.set(a.name,1),r.push(a)}}for(let a of t)s(a);return r}var mt={},X=null,we=!0,Tt=!1;function ye(){mt={}}function Ae(t){let e=Tt;return X?zt(X.takeRecords()):we&&Ln(),Tt=!!X&&t.getRootNode()===document,e}function Ee(t){Tt=t}function Nt(){X&&zt(X.takeRecords())}function Ln(){if(typeof document>"u"||typeof MutationObserver!="function"){we=!1;return}X=new MutationObserver(zt),X.observe(document,{attributes:!0,childList:!0,subtree:!0})}function zt(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&&ve(r)}function ve(t){t._sapPlan&&(t._sapPlan=null);for(let e=t.firstElementChild;e;e=e.nextElementSibling)ve(e)}function q(t){if(!Tt)return ge(t);let e=t._sapPlan;return e&&e.gen===mt?e:t._sapPlan=ge(t)}function ge(t){let e={gen:mt,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=C(o);break;case"text":(e.paints||(e.paints=[])).push({kind:"text",fmt:null,entry:N(o)});break;case"show":(e.paints||(e.paints=[])).push({kind:"show",entry:N(o)});break;case"effect":(e.effects||(e.effects=[])).push({entry:N(o,!0)});break;case"invalid":(e.invalids||(e.invalids=[])).push({entry:N(o)});break}continue}let a=n.slice(0,s),g=n.slice(s+1);switch(a){case"calc":(e.calcs||(e.calcs=[])).push({name:g,entry:N(o)});break;case"text":(e.paints||(e.paints=[])).push({kind:"text",fmt:g,entry:N(o)});break;case"attr":(e.paints||(e.paints=[])).push({kind:"attr",arg:g,entry:N(o)});break;case"class":(e.paints||(e.paints=[])).push({kind:"class",arg:g,entry:N(o)});break;case"css":(e.paints||(e.paints=[])).push({kind:"css",arg:g,entry:N(o)});break;case"show-when":case"option":(e.paints||(e.paints=[])).push({kind:"when",match:"show",field:g,values:o.split("|")});break;case"hide-when":(e.paints||(e.paints=[])).push({kind:"when",match:"hide",field:g,values:o.split("|")});break;case"option-not":(e.paints||(e.paints=[])).push({kind:"when",match:"show-not",field:g,values:o.split("|")});break}}return e.boundary=e.scope?"scope":e.items?"items":e.detail?"detail":e.each?"each":null,Rn(e)?Cn():e}var _t=null;function Cn(){return(!_t||_t.gen!==mt)&&(_t=Object.freeze({gen:mt,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})),_t}function Rn(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 xe(t){return(t.getAttribute("type")||"text").toLowerCase()}function nt(t){let e=t.tagName;if(e==="INPUT"){let r=xe(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 Se(t,e=t){let r=t.tagName;if(r==="INPUT"){let n=xe(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 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
|
|
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 Lt(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function L(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 ke(){let t=L("visitorDrafts");return!!(t&&typeof t.restored=="function"&&t.restored()?.restored)}var Ht=["clay:mutation-ready","hyperclay:mutation-ready"],Dn=["clay:sync-applied","hyperclay:livesync-applied"],Fn=["clay:ready","hyperclay:ready"],Pn=["clay:route"];function rt(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 $e(t){let e=typeof window<"u"&&window.clay&&window.clay.ready;e&&typeof e.then=="function"?e.then(()=>t(),()=>t()):t()}function Ct(t){let e=L("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function _e(){let t=L("consent");return typeof t=="function"?t:null}function Te(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let r=L("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 Ne(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let d=!1;for(let u of t.apps())u.root.isConnected?t.runNow(u,"platform"):d=!0;d&&t.pruneDisconnected(),t.remountIfPresent()},r=L("derived"),n=r&&typeof r.register=="function"?r.register(e):null,o=typeof n=="function"?null:rt(document,Dn,e),s=rt(document,Pn,e),a=!1,g=()=>{},b=()=>{if(a)return!0;let d=L("undo");if(!d||typeof d.on!="function")return!1;let u=d.on("undo",e);return typeof u!="function"?!1:typeof d.on("redo",e)!="function"?(u(),!1):(a=!0,g(),!0)};if(!b()){let d=rt(document,Ht,b),u=rt(document,Fn,b);g=()=>{d(),u()};let E=L("ready");E&&typeof E.then=="function"&&E.then(b,()=>{})}return()=>{typeof n=="function"&&n(),o&&o(),s(),g()}}function ht(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 In(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 Le(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return In(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 Ce(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 Ut(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}Ct(t)||nt(t)}function Mn(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function Rt(t,e){return Le(t,e)}function Re(t,e,r){Ce(t,e,r),Ut(t)}function R(t){let e=ht(t);return{el:t,kind:e,read(){return Le(t,e)},write(r,n={}){Ce(t,e,r),n.noMirror||Ut(t),n.silent||Mn(t)},mirror(){Ut(t)}}}var j=null,Ft=!1,ot=null;function De(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 On(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(n=>e(Bn(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=L("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 Bn(t){let e=[];for(let r of t)if(r.type==="attributes"){let n=r.target;n&&n.nodeType===1&&!Dt(n)&&e.push({type:"attribute",element:n})}else if(r.type==="characterData"){let n=r.target&&r.target.parentElement;n&&!Dt(n)&&e.push({type:"characterData",element:n})}else if(r.type==="childList"){for(let n of r.addedNodes)if(!(n.nodeType!==1||Dt(n))&&(e.push({type:"add",element:n}),n.querySelectorAll))for(let o of n.querySelectorAll("*"))Dt(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 Dt(t){return!!(t.closest&&t.closest("[sap-ignore],[template],[cms-template]"))}function Wn(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 Fe(t){if(j)return j.suppress(t);let e=L("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function Gt(t,e){Ft=!0,j=t,t.subscribe(r=>Wn(e,r))}function Yt(t){if(Ft||typeof window>"u"||typeof document>"u")return;let e=L("Mutation");if(e&&typeof e.onAnyChange=="function"){Gt(De(e),t);return}typeof MutationObserver=="function"&&(Gt(On(),t),ot=rt(document,Ht,function(){let n=L("Mutation");n&&(ot(),ot=null,j&&j.teardown(),Ft=!1,Gt(De(n),t))}))}function Xt(){if(j)try{j.teardown()}catch{}ot&&typeof document<"u"&&ot(),j=null,Ft=!1,ot=null}var qn=new Set(J),V=[],Ie={},Me={};function Oe(t){V.includes(t)||(V.push(t),t.boundary&&Object.assign(Ie,t.boundary),t.paintKinds&&Object.assign(Me,t.paintKinds))}function it(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),M(t.root,"loop");return}e.full&&ye();let r=Ae(t.root);try{Fe(()=>jn(t,e))}finally{Ee(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=new Set;t.diag.errors=[];let g={root:n,state:n,item:null,ownerEl:r,projection:!1};function b(i,l){let m=l.attr||l.name,y=i.getAttribute(m);return y==null&&(y=ft(l),s.push({el:i,name:l.name,attr:m,value:qt(z(y,l.type),l.type)})),z(y,l.type)}function d(i,l,m){let y=l.decls;if(y)for(let x of y){if(x.transient){m[x.name]=St(i,x);continue}if(G(i,x)){m[x.name]=i.hasAttribute(x.attr);continue}m[x.name]=b(i,x)}}function u(i,l,m){let y=l.bind,x=m.item||m.state,$=ht(i);$==="radio"?(y in x||(x[y]=""),i.checked&&(x[y]=i.value)):x[y]=Rt(i,$),l.transient&&(i.removeAttribute("value"),i.removeAttribute("checked"))}function E(i,l,m){if(l.paints)for(let y of l.paints)y.kind==="when"&&a.add(y.field),o.push({def:y,el:i,ctx:m});for(let y of V)y.collect&&y.collect(w,i,l,m)}function S(i,l,m){Object.defineProperty(i,"$key",{value:At(l,"row"),enumerable:!1}),Object.defineProperty(i,"$index",{value:m,enumerable:!1}),Object.defineProperty(i,"$el",{value:l,enumerable:!1})}function k(i,l,m){let y=q(i);d(i,y,l),i._sapScope=l,!m.projection&&y.bind!=null&&u(i,y,m),E(i,y,m),y.items?p(i,l,m):_(i,l,m)}function _(i,l,m){for(let y=i.firstElementChild;y;y=y.nextElementSibling)h(y,l,m)}function h(i,l,m){let y=q(i);if(!y.inert){if(y.boundary){y.boundary==="scope"?A(i,l,m):y.boundary==="items"?(E(i,y,m),p(i,l,m)):Ie[y.boundary](w,i,y,l,m);return}!m.projection&&!m.view&&y.bind!=null&&u(i,y,m),E(i,y,m);for(let x=i.firstElementChild;x;x=x.nextElementSibling)h(x,l,m)}}function A(i,l,m){let y=i.getAttribute("scope"),x={};l[y]=x;let $={root:m.root,state:x,item:null,ownerEl:i,projection:m.projection};k(i,x,$)}function p(i,l,m){let y=i.getAttribute("items"),x=[];l[y]=x,i._sapList=x;let $=0;for(let T=i.firstElementChild;T;T=T.nextElementSibling){let gt=q(T);if(!gt.item||gt.template||T.hasAttribute("cms-template"))continue;let D={};S(D,T,$);let st={root:m.root,state:m.state,item:D,ownerEl:T,projection:m.projection};k(T,D,st),x.push(D),$++}}let w={app:t,root:r,rootObj:n,paints:o,stats:{calcs:0,lists:0},resolveDefault:b,collectEl:E,walkScope:_};for(let i of V)i.begin&&i.begin(w);if(k(r,n,g),t.halted)return;for(let i of V)i.afterIntake&&i.afterIntake(w);if(s.length&&a.size)for(let i of s)a.has(i.attr)&&i.el.getAttribute(i.attr)==null&&i.el.setAttribute(i.attr,i.value);for(let i of V)i.compute&&i.compute(w);let v=0;for(let i of V)i.reconcile&&(v+=i.reconcile(w));let f=0,c=v;for(let i of o){let l=zn(i,t);i.ctx.view?c+=l:f+=l}for(let i of V)i.afterPaint&&i.afterPaint(w);t._state=n,t._stats={fields:Object.keys(n).filter(i=>typeof n[i]!="function").length,calcs:w.stats.calcs,paints:o.length,lists:w.stats.lists,writes:f,viewWrites:c},t._viewsChanged=c>0,t._lastPass={trigger:e.trigger||"refresh",writes:f},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${f}/${o.length}`)}function Vn(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 Kt(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 zn(t,e){let r=t.def,n=t.el,o=Me[r.kind];if(o)return o(t,e);if(r.kind==="when")return Pe(r,n,null);try{let s=I(r.entry,t.ctx.state,t.ctx.item,n,t.ctx.root),a=Pe(r,n,s);return Q(n),a}catch(s){return e.diag.error(s.sapCode==="E22"?"E22":"E24",n,{attr:Vn(r),expr:r.entry&&r.entry.src,problem:String(s.message)}),M(n,s.sapCode||"E24"),0}}function Pe(t,e,r){switch(t.kind){case"text":{let n=t.fmt!=null?pe(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=L("optionVisibility");if(n&&n._started)return e._sapWhen&&e.hidden?(e.hidden=!1,e._sapWhen=!1,1):0;let o;t.match==="hide"?o=!Kt(e,t.field,t.values,!1):t.match==="show-not"?o=Kt(e,t.field,t.values,!0):o=Kt(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(qn.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}}var Hn=new Set(J),Be=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode"]),Un=new Set(["show-when","hide-when","option","option-not"]),Gn=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,We=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"]),Qt=[];function qe(t){Qt.includes(t)||Qt.push(t)}function Yn(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function Jt(t){return t.hasAttribute("bind")}function Xn(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 Pt(t,e){let r=!1,n=(a,g,b)=>{e.error(a,g,b),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 Xn(t,a=>{let g=new Set;for(let d of Qt)d(a,n,u=>g.add(u));let b=a.closest&&a.closest("[detail]");for(let d of[...a.attributes]){let u=d.name;if(g.has(u))continue;if(u.includes(":")){let S=u.slice(0,u.indexOf(":"));if(Be.has(S)){if(Un.has(S)&&Gn.test(d.value)){let k=u.slice(u.indexOf(":")+1);e.warn("W04",a,{attr:u,expr:d.value,problem:`${S}: compares the "${k}" attribute against a literal value, not a JS expression`,fix:`use show="${d.value}" for an expression, or a literal like ${S}:${k}="overview"`})}}else{let k=ut(S,[...Be]);e.warn("W03",a,{attr:u,problem:`unknown "${S}:" attribute`,didYouMean:k?`${k}:`:null})}}else if(!We.has(u)&&!at.has(u)&&!Hn.has(u)&&!/^(data-|aria-|on)/.test(u)&&!(u in a)){let S=ut(u,[...We]);S&&e.warn("W03",a,{attr:u,problem:`unknown "${u}" attribute`,didYouMean:S})}u==="attr:hidden"&&e.warn("W03",a,{attr:u,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'});let E=Jt(a)||u==="attr:selected"&&a.tagName==="OPTION"&&!!a.closest("select[bind]");(u==="attr:value"||u==="attr:checked"||u==="attr:selected")&&E&&n("E30",a,{attr:u,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),u==="effect"&&Jt(a)&&/\b(value|checked)\s*=[^=]/.test(d.value)&&n("E30",a,{attr:u,expr:d.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"}),(u==="text"||u.startsWith("text:")||u==="show")&&Yn(a)&&(u==="show"||n("E18",a,{attr:u,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(a.hasAttribute("state")){let d=C(a.getAttribute("state")),u=new Set;for(let E of d){E.name.includes("-")&&n("E08",a,{attr:"state",problem:`field "${E.name}" is not a valid identifier (the hyphen parses as subtraction)`,fix:`rename to ${E.name.replace(/-/g,"")}`}),u.has(E.name)&&n("E04",a,{attr:"state",problem:`field "${E.name}" is declared twice in one scope`}),u.add(E.name),wt.has(E.attr)&&n("E05",a,{attr:"state",problem:`"${E.name}" is a reserved Sap word`}),at.has(E.attr)&&n("E06",a,{attr:"state",problem:`"${E.name}" is a global HTML attribute name; pick another field name`}),E.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 S=jt(a,E.attr);S&&(E.attr==="checked"||E.attr==="selected")&&n("E35",a,{attr:"state",problem:`"${E.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">'}),S&&E.type==="num"&&n("E35",a,{attr:"state",problem:`"${E.attr}" is an HTML boolean attribute; it cannot hold a number`,fix:`declare it bare: state="${E.attr}"`}),E.transient&&(S||E.type==="presence")&&n("E35",a,{attr:"state",problem:`"${E.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(Jt(a)){if(a.hasAttribute("-"),a.tagName==="INPUT"){let d=(a.getAttribute("type")||"text").toLowerCase();d==="file"&&n("E32",a,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),d==="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 d=a.getAttribute("contenteditable");!(d!=null&&d!=="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 d=a.parentElement;(!d||!d.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")&&b&&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 d=t.querySelector(`[trigger-add="${a.getAttribute("items")}"]`);!xt(a)&&!Wt(t,a.getAttribute("items"))&&W(a).length===0&&d&&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",M(t,e.haltReason)),!r}var je="sap-styles",Ve="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",Zt=new WeakSet;function Kn(t){if(Zt.has(t))return;let e=t.defaultView,r=e&&e.CSSStyleSheet;if(r&&"adoptedStyleSheets"in t)try{let n=new r;n.replaceSync(Ve),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],Zt.add(t);return}catch{}if(!t.getElementById(je)){let n=t.createElement("style");n.id=je,n.textContent=Ve,(t.head||t.documentElement).appendChild(n)}Zt.add(t)}var Jn=0;function ze(){return typeof performance<"u"&&performance.now?performance.now():0}function te(t){let e=t.id||t.getAttribute("sap")||`app-${Jn++}`,r=new K(e),n={root:t,name:e,diag:r,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Pt(t,r))return n.halted=!0,n;Kn(t.ownerDocument);for(let a of t.querySelectorAll("textarea[data-value]"))Lt(a);let s=ze();return it(n,{trigger:"mount",full:!0}),n._mountMs=ze()-s,n._mountWrites=n._stats?n._stats.writes:0,n._mountWrites>0&&!ke()&&!L("derived")&&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 He=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function It(t){return`${t.tagName.toLowerCase()}[sap]`}function Qn(t){let e=0;for(let r of t.querySelectorAll("*"))for(let n of r.attributes)if(He.test(n.name)){e++;break}for(let r of t.attributes)if(He.test(r.name)){e++;break}return e}function Ue(t){function e(g){let b=g._stats||{},d=g.root;return{root:It(d),fields:b.fields||0,calcs:b.calcs||0,paints:b.paints||0,actions:Qn(d),lists:(d.hasAttribute("items")?1:0)+d.querySelectorAll("[items]").length,rows:d.querySelectorAll("[item]:not([template])").length,warnings:g.diag.warnings.length,errors:g.diag.errors.length,mountWrites:g._mountWrites||0,ms:Math.round((g._mountMs||0)*10)/10,passes:g._passes||0,lastPass:g._lastPass||null,ok:g.diag.errors.length===0&&!g.halted}}function r(){let g=t.apps().map(e);return{ok:g.every(b=>b.ok),apps:g}}function n(g){let b=e(g);return b.ok?`sap \u2713 ${b.root} \xB7 fields ${b.fields} \xB7 calcs ${b.calcs} \xB7 paints ${b.paints} \xB7 actions ${b.actions} \xB7 lists ${b.lists} \xB7 rows ${b.rows} \xB7 warnings ${b.warnings} \xB7 mount writes ${b.mountWrites} \xB7 ${b.ms}ms`:`sap \u2717 ${b.root} \xB7 errors ${b.errors} \xB7 warnings ${b.warnings} \xB7 ${b.ms}ms`}function o(){for(let g of t.apps()){let b=n(g);g.diag.errors.length||g.halted?console.error(b):console.log(b)}}function s(){let g=[],b=[];for(let d of t.apps())g.push(...d.diag.errors),b.push(...d.diag.warnings);return{ok:g.length===0,errors:g,warnings:b,counts:{errors:g.length,warnings:b.length}}}function a(g){let b=g===void 0?!0:!!g;for(let d of t.apps())d._debug=b;return console.log(`sap debug ${b?"on":"off"} \u2014 per-pass headers will ${b?"":"no longer "}log`),b}return{status:r,report:s,debug:a,greenLine:n,printGreenLines:o,REGISTRY:Bt}}var Ge="0.6.0";function Ye({createAccessor:t,installInput:e,debugExtras:r}){let n=new Map,o=[],s=ee(it);function a(i){let l=i;for(;l;){if(l.nodeType===1&&l.hasAttribute&&l.hasAttribute("sap"))return n.get(l)||null;l=l.parentNode&&l.parentNode.host?l.parentNode.host:l.parentElement}return null}function g(){for(let i=o.length-1;i>=0;i--){let l=o[i];l.root.isConnected||(n.delete(l.root),o.splice(i,1))}}function b(i,l){if(i.moveBefore)try{i.moveBefore(l,null);return}catch{}i.appendChild(l)}function d(i,l){let m=l.parentElement;if(m){if(m.moveBefore)try{m.moveBefore(i,l);return}catch{}m.insertBefore(i,l)}}let u={apps:()=>o.slice(),appFor:a,isRegistered:i=>n.has(i),pruneDisconnected:g,schedule:(i,l)=>s.schedule(i,l),runNow:(i,l)=>s.runNow(i,l),moveInto:b,placeBefore:d,remountIfPresent:()=>v()},E=t(u),S=Ue(u),k=r?r(u,S):{},_=!1,h=!1,A=null;function p(){_||(_=!0,e(u,E,document),A=Ne(u))}function w(){let i=L("derived");i&&typeof i.mounted=="function"&&i.mounted()}function v(i=document){if(h)return[];p(),Yt(u);let l=i.querySelectorAll("[sap]"),m=[];for(let y of l){if(n.has(y))continue;let x=te(y);n.set(y,x),o.push(x),m.push(x)}for(let y of m){let x=S.greenLine(y);y.diag.errors.length||y.halted?console.error(x):console.log(x)}return w(),m}function f(i){if(h)return null;if(p(),Yt(u),!i)return v();let l=typeof i=="string"?document.querySelector(i):i;if(!l)return null;if(n.has(l))return n.get(l);let m=te(l);n.set(l,m),o.push(m);let y=S.greenLine(m);return m.diag.errors.length||m.halted?console.error(y):console.log(y),m}let c=E.Sap;return c.version=Ge,c.refresh=function(){for(let l of o)l.root.isConnected&&s.runNow(l,"refresh")},c.batch=Te,c.status=S.status,c.report=S.report,c.why=k.why,c.debug=S.debug,c.doctor=k.doctor,c.greenLine=S.greenLine,c.formats=et,c.serializeControlToAttributes=nt,c.finalizeControlForSave=Se,c.rehydrateControlFromAttributes=Lt,c.mount=f,c.config=function(l={}){return l.formats&&Object.assign(et,l.formats),c},c._registry=n,c._reset=function(){n.clear(),o.length=0,Xt()},c.unmount=function(){h=!0,n.clear(),o.length=0,Xt(),typeof A=="function"&&A()},{Sap:c,mountAll:v,mount:f,runtime:u}}function Xe(t){if(typeof document>"u")return;let e=()=>$e(()=>t());document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}var Zn=["for","form","list","headers","popovertarget","commandfor","anchor","aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"];function tr(t,e){let r=null;return O(t,n=>{!r&&n.getAttribute("scope")===e&&(r=n)}),r}function Ke(t,e,r){let n=F(t)||e;for(;n;){for(let o of C(n.getAttribute("state")||""))if(o.name===r)return{el:n,decl:o};if(n.hasAttribute("sap"))break;n=F(n.parentElement)}return null}function er(t){return typeof t=="number"?"num":typeof t=="boolean"?"bool":"string"}function Je(t){function e(h){let A=t.appFor(h);if(!A)return null;let p=H(h),w=p&&p._sapEachItem&&p._sapEachItem.$el;if(w&&w.isConnected)return{ctxEl:w,appRec:A,isRow:!0};let v=ct(h);if(v)return v._sapDetailRow?{ctxEl:v._sapDetailRow,appRec:A,isRow:!0}:{ctxEl:F(v.parentElement)||A.root,appRec:A,isRow:!1};let f=Et(h);if(f&&f.hasAttribute("item"))return{ctxEl:f,appRec:A,isRow:!0};let c=F(h)||A.root;return{ctxEl:c,appRec:A,isRow:c.hasAttribute("item")}}function r(h){let A=typeof h=="string"?document.querySelector(h):h;if(!A||A.nodeType!==1)return null;let p=e(A);return p?_(p.ctxEl,p.appRec,p.isRow):null}function n(h,A){let p=H(h);if(!p)return r(h);let w=t.appFor(h),v=p._sapEachItem&&p._sapEachItem.$el;if(v&&v.nodeType===1&&v.hasAttribute("item")&&tt(v,A))return v.isConnected?_(v,w,!0):null;let f=p.parentElement&&p.parentElement._sapDrawnEl;return!f||!f.isConnected?null:_(f,w,f.hasAttribute("item"))}function o(h,A,p){let w=U(h,p);if(w)return R(w).read();let v=Z(h,p);if(v)return W(v).map(l=>_(l,A,!0));let f=tr(h,p);if(f)return _(f,A,!1);let c=Ke(h,A.root,p);if(c)return c.decl.transient?St(c.el,c.decl):ie(c.el,c.decl);let i=h._sapScope;return i?i[p]:void 0}function s(h,A,p,w,v){w.transient?dt(h,w,p):lt(h,w,p),t.schedule(v,"set:"+A)}function a(h,A){let p=new Set,w=F(h)||A;for(;w;){for(let v of C(w.getAttribute("state")||""))p.add(v.name);if(w.hasAttribute("sap"))break;w=F(w.parentElement)}return O(h,v=>{let f=v.getAttribute("bind");f&&p.add(f)}),p}function g(h,A,p,w){let v=U(h,p);if(v){R(v).write(w);return}let f=h;for(;f;){for(let T of f.attributes)if(T.name==="calc:"+p){A.diag.error("E16",f,{attr:"calc:"+p,problem:`"${p}" is a computed field; computed fields are read-only`});return}if(f.hasAttribute("sap"))break;f=f.parentElement}let c=Ke(h,A.root,p);if(c){s(c.el,p,w,c.decl,A);return}let i=a(h,A.root);i.delete(p);let l=p.length>=4?ut(p,[...i]):null;if(l){A.diag.error("E12",h,{key:p,problem:`unknown state key "${p}"`,didYouMean:l});return}if(wt.has(p)||at.has(p)){A.diag.error("E15",h,{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 m=A.root,y=er(w),x=m.getAttribute("state")||"",$=y==="string"?p:`${p}:${y}`;m.setAttribute("state",x?`${x} ${$}`:$),s(m,p,w,{name:p,attr:p,type:y,transient:!1},A)}function b(h){let A=h.ownerDocument,p=new Map,w=(v,f)=>{let c=re(A),i=v.getAttribute(f);i&&f==="id"&&p.set(i,c),v.setAttribute(f,c)};h.querySelectorAll("[id]").forEach(v=>w(v,"id")),h.querySelectorAll("[data-id]").forEach(v=>w(v,"data-id")),h.querySelectorAll("[sap-error]").forEach(v=>v.removeAttribute("sap-error")),h.removeAttribute("sap-error"),h.hasAttribute("data-id")?(h.removeAttribute("id"),w(h,"data-id")):w(h,"id");for(let v of[h,...h.querySelectorAll("*")])for(let f of Zn){let c=v.getAttribute(f);if(c==null)continue;let i=c.split(/\s+/).map(l=>p.get(l)||l).join(" ");i!==c&&v.setAttribute(f,i)}}function d(h,A,p){let w=pt(A.root,h,p);if(!w)return A.diag.error("E17",h,{problem:`cannot resolve a list named "${p}" from here`}),null;let v=xt(w);if(!v)return A.diag.error("E17",w,{problem:`items="${p}" has no [item template] to clone`}),null;let f=w.ownerDocument.importNode(v,!0);return f.removeAttribute("template"),b(f),w.appendChild(f),t.schedule(A,"trigger-add:"+p),_(f,A,!0)}function u(h,A){O(h,p=>{if(p.hasAttribute("bind")){let w=R(p),v=p.getAttribute("default");w.kind==="checkbox"||w.kind==="radio"?w.write(v!=null?v===""||v==="true"||p.value===v:p.hasAttribute("checked")):w.write(v??(p.getAttribute("value")||""))}});for(let p of C(h.getAttribute("state")||"")){let w=se(h,p);p.transient?dt(h,p,w):lt(h,p,w)}t.schedule(A,"trigger-reset")}function E(h,A){if(!h.isConnected)throw new Error("stale row handle: $remove() on a removed row");h.remove(),t.schedule(A,"trigger-remove")}function S(h,A,p){if(!h.isConnected)throw new Error("stale row handle: $move() on a removed row");let w=null;if(p&&p.nodeType===1?w=p:typeof p=="string"&&(w=pt(A.root,h,p)),!w){A.diag.error("E17",h,{problem:`$move() cannot resolve target "${p}"`});return}t.moveInto(w,h),t.schedule(A,"trigger-move")}function k(h){let A=h.parentElement;return A?W(A).indexOf(h):-1}function _(h,A,p){let w={get $el(){return h},get $key(){return At(h,p?"row":"scope")},get $index(){return k(h)},$add(f){return d(h,A,f)},$reset(){return u(h,A),v},$remove(){E(h,A)},$move(f){S(h,A,f)},get $appRec(){return A}},v=new Proxy(w,{get(f,c){return typeof c=="symbol"||c[0]==="$"?f[c]:o(h,A,c)},set(f,c,i){return typeof c=="string"&&c[0]==="$"?(f[c]=i,!0):(g(h,A,c,i),!0)},has(f,c){return typeof c=="string"&&c[0]==="$"?c in f:o(h,A,c)!==void 0}});return v}return{Sap:r,contextElFor:e,readField:o,writeField:g,makeProxy:_,writeTargetFor:n}}var nr=["trigger-add","trigger-remove","trigger-reset"];function rr(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:")||nr.includes(r))return!0}return!1}function or(t,e){let r=t,n=e.parentElement;for(;r&&r!==n;){if(r.nodeType===1&&rr(r)&&!(r.tagName==="FORM"&&r.hasAttribute("trigger-add")))return r;r=r.parentElement}return null}function Qe(t,e){let{Sap:r}=e;function n(f,c){let i=null,l=H(f),m=ct(f);if(l)i=l._sapEachItem??null;else if(m&&m._sapDetailRow)i=m._sapDetailRow._sapScope||null;else{let $=Et(f);$&&$.hasAttribute("item")&&(i=$._sapScope||null)}return{state:(F(f)||c.root)._sapScope||c._state||{},item:i,el:f,root:c._state||{}}}function o(f,c,i){if(!f.hasAttribute("confirm")){i();return}let l=f.getAttribute("confirm"),m=l,y=N(l);if(!y.error)try{let T=Y(y,n(f,c));(typeof T=="string"||typeof T=="number")&&(m=String(T))}catch{}let x=_e();if(!x){window.confirm(m)&&i();return}if(f._sapGatePending)return;f._sapGatePending=!0;let $=()=>{f._sapGatePending=!1};x(m,()=>{$(),i()}).catch($)}function s(f,c){for(let i of f.attributes){if(!i.name.startsWith("set:"))continue;let l=i.name.slice(4),m=N(i.value);if(m.error){c.diag.error("E08",f,{attr:i.name,expr:i.value,problem:String(m.error.message)});continue}let y;try{y=Y(m,n(f,c))}catch($){c.diag.error("E24",f,{attr:i.name,expr:i.value,problem:String($.message)});continue}let x=e.writeTargetFor(f,l);x&&(x[l]=y)}}function a(f){let c=H(f);if(!c)return f.closest("[item]");let i=c._sapEachItem&&c._sapEachItem.$el;return i&&i.nodeType===1&&i.hasAttribute("item")?i:null}function g(f,c){let i=a(f);if(!i)return;let l=W(i.parentElement),m=l.indexOf(i);c==="up"&&m>0?t.placeBefore(i,l[m-1]):c==="down"&&m<l.length-1&&t.placeBefore(l[m+1],i)}function b(f,c,i){if(c)return pt(i.root,f,c);let l=f;for(;l;){if(l.hasAttribute&&l.hasAttribute("items"))return l;l=l.parentElement}let m=F(f)||i.root,y=[];return O(m,x=>{x.hasAttribute("items")&&y.push(x)}),y[0]||null}function d(f,c){let i=f==null||f==="",l=c==null||c==="";if(i&&l)return 0;if(i)return 1;if(l)return-1;let m=Number(f),y=Number(c);return!Number.isNaN(m)&&!Number.isNaN(y)?m-y:String(f)<String(c)?-1:String(f)>String(c)?1:0}function u(f,c,i,l){let m=b(f,i,l);if(!m){l.diag.error("E17",f,{attr:"sort:"+c,problem:`no items list resolvable for sort:${c}`});return}let y=W(m),x=D=>D._sapScope?D._sapScope[c]:void 0,$=[...y].sort((D,st)=>d(x(D),x(st))),gt=$.every((D,st)=>D===y[st])?[...$].reverse():$;for(let D of gt)t.moveInto(m,D);t.schedule(l,"sort:"+c)}function E(f){if(!f||f.hidden)return;let c=f.querySelector("[bind]:not([type=hidden]), [contenteditable]");c&&typeof c.focus=="function"&&c.focus()}function S(f,c){o(f,c,()=>{let i=r(f);for(let l of[...f.attributes]){let m=l.name;if(m==="trigger-remove")i&&i.$remove();else if(m==="trigger-reset")i&&i.$reset();else if(m==="trigger-add"){let y=i&&i.$add(l.value);y&&E(y.$el)}else m==="move:up"?(g(f,"up"),t.schedule(c,"move:up")):m==="move:down"?(g(f,"down"),t.schedule(c,"move:down")):m.startsWith("move:to")?i&&i.$move(l.value):m.startsWith("sort:")&&u(f,m.slice(5),l.value,c)}[...f.attributes].some(l=>l.name.startsWith("set:"))&&s(f,c)})}function k(f){let c=f.target;if(!c||c.nodeType!==1)return;let i=t.appFor(c);if(!i)return;let l=or(c,i.root);l&&S(l,i)}function _(f){let c=R(f),i=f.getAttribute("default");c.kind==="checkbox"?c.write(i===""||i==="true"):c.write(i??"")}function h(f,c,i){let l=r(f);if(!l)return;let m=l.$add(i);if(!m)return;let y=[];O(f,x=>{x.hasAttribute("bind")&&y.push(x)});for(let x of y){if(x.type==="radio"&&!x.checked)continue;let $=x.getAttribute("bind"),T=U(m.$el,$);T?R(T).write(R(x).read()):tt(m.$el,$)&&(m[$]=R(x).read())}y.forEach(_),y.length?typeof y[0].focus=="function"&&y[0].focus():E(m.$el)}function A(f){let c=f.target;if(!c||!c.hasAttribute||!c.hasAttribute("trigger-add"))return;let i=t.appFor(c);i&&(f.preventDefault(),o(c,i,()=>h(c,i,c.getAttribute("trigger-add"))))}function p(f){let c=f.target;if(!c||c.tagName!=="DIALOG"||!c.hasAttribute("detail"))return;if(c._sapEngineClose){c._sapEngineClose=!1;return}if(c.open)return;let i=/^[\w.]+\s+by\s+state\.(\w+)\s*$/.exec(c.getAttribute("detail")||""),l=t.appFor(c);if(!i||!l)return;let m=C(c.getAttribute("state")||"").find(x=>x.name===i[1]);if(m){m.transient?dt(c,m,""):lt(c,m,""),t.schedule(l,"close");return}let y=r(c.parentElement);y&&y[i[1]]!==""&&(y[i[1]]="")}function w(f,c){let i=f.hasAttribute("bind")&&vt(f);if(!i&&f.hasAttribute("bind")&&H(f)){let m=f.getAttribute("bind"),y=f._sapViewBind?e.writeTargetFor(f,m):null;return y&&(y[m]=R(f).read()),!0}let l=ct(f);if(l&&l._sapDetailRow&&f.hasAttribute("bind")&&!i){let m=l._sapDetailRow,y=f.getAttribute("bind"),x=U(m,y);if(x&&x!==f)return R(x).write(R(f).read()),!0;if(!x&&C(m.getAttribute("state")||"").some($=>$.name===y))return e.writeField(m,c,y,R(f).read()),!0}return!1}function v(f=document){f.addEventListener("click",k),f.addEventListener("submit",A),f.addEventListener("close",p,!0)}return{install:v,routeInput:w}}function Ze(t){let e=[];function r(b){let d=b.target;if(!d||d.nodeType!==1)return;let u=t.appFor(d);if(u){d.hasAttribute("persist")&&!Ct(d)&&nt(d);for(let E of e)if(E(d,u))return;t.schedule(u,b.type+" "+(d.id||d.tagName.toLowerCase()))}}function n(b){let d=b.target,u=t.appFor(d);u&&setTimeout(()=>{d.querySelectorAll("[bind]").forEach(E=>{E.dispatchEvent(new Event("input",{bubbles:!0})),E.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(u,"reset")},0)}function o(b){let d=t.appFor(b.target);d&&t.schedule(d,"toggle")}function s(b){let d=b.detail||{};for(let u of[d.from,d.to,b.target]){if(!u||u.nodeType!==1)continue;let E=t.appFor(u);E&&t.schedule(E,"sorted")}}function a(b){if(b.key!=="ArrowUp"&&b.key!=="ArrowDown")return;let d=b.target;if(!d||d.nodeType!==1||d.tagName!=="INPUT"||!d.hasAttribute("bind")||!d.hasAttribute("step"))return;let u=(d.getAttribute("type")||"text").toLowerCase();if(u!=="text"&&u!=="tel"&&u!=="search"||!t.appFor(d))return;b.preventDefault();let S=P(d.getAttribute("step"))||1,k=b.key==="ArrowUp"?1:-1,_=P(d.value)+S*(b.shiftKey?10:1)*k,h=d.getAttribute("min"),A=d.getAttribute("max");h!==null&&h!==""&&_<P(h)&&(_=P(h)),A!==null&&A!==""&&_>P(A)&&(_=P(A)),R(d).write(String(Number(_.toFixed(2))))}function g(b=document){b.addEventListener("reset",n),b.addEventListener("toggle",o,!0),b.addEventListener("input",r),b.addEventListener("change",r),b.addEventListener("clay:sorted",s),b.addEventListener("keydown",a)}return{install:g,addRouter:b=>e.push(b)}}function tn(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}function en(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 nn(t){function e(o){return o?typeof o=="string"?document.querySelector(o):o.nodeType===1?o:null:null}function r(o,s){let a=e(o);if(!a)return console.warn("sap why: element not found"),null;let g=[`sap why <${a.tagName.toLowerCase()}> \u2014 ${yt(a)}`],b=[...a.attributes].filter(u=>/^(bind|text|show|effect|invalid|detail|calc:|text:|attr:|class:|css:|set:|state|items|scope)/.test(u.name));for(let u of b)g.push(` ${u.name}="${u.value}"`);let d=a;for(;d&&!d._sapScope;)d=d.parentElement;if(d&&d._sapScope){let u=d._sapScope,E=s?[s]:Object.keys(u);g.push(" reads:");for(let S of E){let k=u[S];typeof k!="function"&&g.push(` ${S} = ${JSON.stringify(Array.isArray(k)?`[${k.length} rows]`:k)}`)}}return g.push(" serialization: textContent and value/checked attributes save with the file; reads live from properties"),console.log(g.join(`
|
|
10
|
+
`)),null}function n(){let o=[],s=0;for(let u of t.apps()){let E=u.root,S=It(E);s++;let k=new K(u.name);Pt(E,k);for(let w of k.errors)o.push({code:w.code,severity:"error",message:`${S}: ${w.code} ${w.slug} at ${w.el}`});for(let w of k.warnings)o.push({code:w.code,severity:"warn",message:`${S}: ${w.code} ${w.slug} at ${w.el}`});s++,it(u,{trigger:"doctor-dryrun"});let _=u._stats?u._stats.writes:0;_>0&&o.push({code:"W30",severity:"warn",message:`${S}: dry recompute wrote ${_} cells on a quiet page; an element is stale or non-idempotent`}),s++;let h=en(E).map(w=>w.src).join(" \0 "),A=[];for(let w of[E,...E.querySelectorAll("[state]")])for(let v of C(w.getAttribute("state")||""))A.push(v.name);for(let w of A)new RegExp(`(state|item)\\.${w}\\b`).test(h)||o.push({code:"I33",severity:"info",message:`${S}: field "${w}" is declared but read nowhere (dead state)`});s++;let p=new Map;for(let w of E.querySelectorAll("[id]"))p.set(w.id,(p.get(w.id)||0)+1);for(let[w,v]of p)v>1&&o.push({code:"W32",severity:"warn",message:`${S}: duplicate id "${w}" (${v} elements) \u2014 clone/edit collision`});s++;for(let w of en(E))w.src.length>120&&o.push({code:"I33",severity:"info",message:`${S}: ${w.attr} expression is ${w.src.length} chars; consider a calc: field`});s++;for(let w of E.querySelectorAll("[text], [text\\:num]")){let v=w.textContent||"";/\.\d{5,}/.test(v)&&o.push({code:"I33",severity:"info",message:`${S}: ${yt(w)} paints >4 decimals; consider text:FMT`})}}let a=o.filter(u=>u.severity==="error").length,g=o.filter(u=>u.severity==="warn").length,b=o.filter(u=>u.severity==="info").length;console.log(`sap doctor \xB7 ${t.apps().map(u=>It(u.root)).join(", ")} \xB7 errors ${a} \xB7 warnings ${g} \xB7 info ${b} \xB7 ${s} checks \xB7 0ms`);for(let u of o)(u.severity==="error"?console.error:u.severity==="warn"?console.warn:console.info)(` ${u.severity==="error"?"\u2717":u.severity==="warn"?"\u26A0":"\xB7"} ${u.message}`);return o}return{why:r,doctor:n}}function ir(t,e){let r=String(t).split("."),n=s=>{for(let a of r){if(s==null)return;s=Array.isArray(s)?s.flatMap(g=>g&&g[a]!=null?g[a]:[]):s[a]}return s},o=n(e.state);return o===void 0?n(e.root):o}function sr(t,e,r,n){e._sapScope=r;let o=e.getAttribute("detail")||"",s=/^([\w.]+)\s+by\s+(.+)$/.exec(o);if(!s){e.hidden=!0,e._sapDetailRow=null;return}let a=s[1],g=s[2].trim(),b=ir(a,n),d;try{d=Y(N(g),{state:r,item:n.item,el:e,root:n.root})}catch{d=void 0}let u=Array.isArray(b)&&d!=null?b.find(S=>S&&typeof S=="object"&&S.$el&&String(S.$key)===String(d)):null;if(e._sapDetailRow=u?u.$el:null,e.tagName==="DIALOG"){let S=u?String(u.$key):null;if(S!==e._sapDetailKey&&(e._sapDetailKey=S,e._sapDismissed=!1),!u){e._sapOpenedFor=null,e.open&&typeof e.close=="function"&&(e._sapEngineClose=!0,e.close());return}e.open?e._sapOpenedFor=S:(e._sapOpenedFor===S&&(e._sapDismissed=!0),e._sapOpenedFor=null,!e._sapDismissed&&e.isConnected&&typeof e.showModal=="function"&&(e.hidden&&(e.hidden=!1),e.showModal(),e._sapOpenedFor=S))}else{if(!u){e.hidden||(e.hidden=!0);return}e.hidden&&(e.hidden=!1)}Nt();let E={root:n.root,state:r,item:u,ownerEl:u.$el,projection:!0};t.collectEl(e,q(e),E),t.walkScope(e,u,E)}var rn={name:"detail",begin(t){t.deferredDetails=[]},boundary:{detail(t,e,r,n,o){for(let s of C(e.getAttribute("state")||""))s.name in n||(n[s.name]=G(e,s)?e.hasAttribute(s.attr):t.resolveDefault(e,s));t.deferredDetails.push({el:e,parentObj:n,ctx:o})}},afterIntake(t){for(let e=0;e<t.deferredDetails.length;e++){let{el:r,parentObj:n,ctx:o}=t.deferredDetails[e];sr(t,r,n,o)}}};function on(t){let e=0,r=t;for(;r&&!(r.hasAttribute&&r.hasAttribute("sap"));)r=r.parentElement,e++;return e}var sn={name:"calc",begin(t){t.calcs=[]},collect(t,e,r,n){if(!r.calcs)return;let o=n.item||n.state;for(let s of r.calcs)t.calcs.push({owner:o,ownerEl:n.ownerEl,name:s.name,entry:s.entry,def:s,el:e,ctx:n})},compute(t){let e=t.app,r=new Map;for(let o of t.calcs){let s=r.get(o.owner);s||(s={ownerEl:o.ownerEl,list:[]},r.set(o.owner,s)),s.list.push(o)}let n=[...r.values()].sort((o,s)=>on(s.ownerEl)-on(o.ownerEl));for(let o of n){let s;try{s=be(o.list)}catch(a){e.diag.error("E07",o.list[0].el,{problem:a.message}),s=o.list}for(let a of s)try{a.owner[a.name]=I(a.entry,a.ctx.state,a.ctx.item,a.el,a.ctx.root),Q(a.el)}catch(g){a.owner[a.name]=void 0,e.diag.error("E24",a.el,{attr:"calc:"+a.name,expr:a.entry.src,problem:String(g.message)}),M(a.el,g.sapCode||"E24")}}t.stats.calcs=t.calcs.length,t.stats.lists=r.size}};function ar(t,e,r){let n=r.nextSibling;if(e.isConnected&&t.moveBefore)try{t.moveBefore(e,n);return}catch{}t.insertBefore(e,n)}function ur(t,e,r){for(let n=e.parentElement;n;n=n.parentElement)if(n._sapScope===r&&!n.hasAttribute("detail")||n.hasAttribute("sap"))return n;return t}function cr(t,e,r){let n=t.app;e._sapDrawnEl=ur(t.root,e,r.state);let o=null;for(let h=e.firstElementChild;h;h=h.nextElementSibling)if(h.tagName==="TEMPLATE"){o=h;break}let s=o&&o.content.children.length===1?o.content.firstElementChild:null;if(!s)return n.diag.error("E42",e,{attr:"each",problem:"each needs one <template> child with exactly one element root"}),0;let a=e.getAttribute("each"),g;try{g=Y(N(a),{state:r.state,item:r.item,el:e,root:r.root})}catch(h){return n.diag.error("E24",e,{attr:"each",expr:a,problem:String(h.message)}),0}if(!Array.isArray(g))return n.diag.error("E40",e,{attr:"each",expr:a,problem:"each must evaluate to an array; the list keeps its last good rows"}),0;let b=N(e.getAttribute("key")||"item.$key"),d=[],u=new Set;for(let h of g){let A;try{A=I(b,r.state,h,e,r.root)}catch{A=void 0}let p=A==null?"":String(A);if(p===""||u.has(p))return n.diag.error("E41",e,{attr:"key",expr:b.src,problem:p===""?"an item has no key; the list keeps its last good rows":`duplicate key "${p}"; the list keeps its last good rows`}),0;u.add(p),d.push(p)}let E=e._sapEach||new Map,S=new Map,k=0,_=o;d.forEach((h,A)=>{let p=E.get(h);if(!p||p.parentElement!==e){p=e.ownerDocument.importNode(s,!0);let w=(p.getAttribute("clay")||"").split(/\s+/).filter(Boolean);w.includes("editor-ui")||p.setAttribute("clay",[...w,"editor-ui"].join(" ")),p._sapEachRow=!0,k++}p.getAttribute("data-key")!==h&&p.setAttribute("data-key",h),_.nextElementSibling!==p&&(ar(e,p,_),k++),p._sapEachItem=g[A],S.set(h,p),_=p});for(let[h,A]of E)S.get(h)!==A&&A.parentElement===e&&(A.remove(),k++);return e._sapEach=S,Nt(),d.forEach((h,A)=>{let p=S.get(h),w={root:r.root,state:r.state,item:g[A],ownerEl:p,projection:!1,view:!0};t.collectEl(p,q(p),w),t.walkScope(p,{},w)}),k}var an={name:"each",begin(t){t.eachList=[]},boundary:{each(t,e,r,n,o){t.collectEl(e,r,o),t.eachList.push({el:e,ctx:o})}},reconcile(t){let e=0;for(let r=0;r<t.eachList.length;r++)e+=cr(t,t.eachList[r].el,t.eachList[r].ctx);return e}};function fr(t,e){try{I(t.def.entry,t.ctx.state,t.ctx.item,t.el,t.ctx.root),Q(t.el)}catch(r){e.diag.error("E24",t.el,{attr:"effect",expr:t.def.entry&&t.def.entry.src,problem:String(r.message)}),M(t.el,"E24")}}var un={name:"effect",begin(t){t.effects=[]},collect(t,e,r,n){if(r.effects)for(let o of r.effects)t.effects.push({def:o,el:e,ctx:n})},afterPaint(t){for(let e of t.effects)fr(e,t.app)}};function lr(t){let e="";try{let r=I(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)}var cn={name:"validation",begin(t){t.invalids=[]},collect(t,e,r,n){if(r.invalids)for(let o of r.invalids)t.invalids.push({def:o,el:e,ctx:n})},afterPaint(t){for(let e of t.invalids)lr(e)}};function fn(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=ht(t),n=Rt(t,r),o=e??"";return String(n)!==String(o)?(Re(t,r,o),1):0}var ln={name:"projection",collect(t,e,r,n){if(!(r.bind!=null&&(n.view||n.projection)&&!vt(e)))return;let o=r.bind,s=t.paints;n.view?tt(oe(n.item),o)?(e._sapViewBind="item",s.push({def:{kind:"projection",field:o,from:"item"},el:e,ctx:n})):o in n.state||o in n.root?(e._sapViewBind="drawn",s.push({def:{kind:"projection",field:o,from:"drawn"},el:e,ctx:n})):(e._sapViewBind=null,t.app.diag.error("E43",e,{attr:"bind",expr:o,problem:`bind="${o}" 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:o,from:null},el:e,ctx:n})},paintKinds:{projection(t){let e=t.def;if(e.from==="drawn"){let r=e.field in t.ctx.state?t.ctx.state:t.ctx.root;return fn(t.el,r[e.field])}return fn(t.el,t.ctx.item?t.ctx.item[e.field]:"")}}};function dn(){for(let t of[rn,sn,an,un,cn,ln])Oe(t)}dn();qe((t,e,r)=>{for(let n of t.attributes){let o=tn(n.name);o&&(e("E01",t,{attr:n.name,expr:n.value,problem:`"${n.name}" is a foreign-dialect attribute; Sap has no ${n.name.split(/[:=]/)[0]} directive`,fix:o+" \u2014 or wrap the subtree in sap-ignore if intentional"}),r(n.name))}});var{Sap:Mt,mountAll:pn,mount:dr,runtime:pr}=Ye({createAccessor:Je,debugExtras:nn,installInput(t,e,r){let n=Ze(t),o=Qe(t,e);n.addRouter(o.routeInput),n.install(r),o.install(r)}}),bt=typeof window<"u"?window.Sap:null;bt&&bt!==Mt&&bt.core&&typeof bt.unmount=="function"&&bt.unmount();Xe(pn);typeof window<"u"&&(window.Sap=Mt);var mr=Mt;return yn(hr);})();
|
|
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.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "clayjs: malleable documents. Save lifecycle for self-saving HTML.",
|
|
6
6
|
"license": "MIT-0",
|
|
@@ -34,7 +34,16 @@
|
|
|
34
34
|
"./entries/*": "./entries/*",
|
|
35
35
|
"./clay.standalone.js": "./dist/clay.standalone.js",
|
|
36
36
|
"./tailwind": "./src/tailwind.js",
|
|
37
|
+
"./page/yjs": "./src/page/ybind/external.js",
|
|
37
38
|
"./dist/*": "./dist/*",
|
|
39
|
+
"./server/rooms": {
|
|
40
|
+
"import": "./dist/server/rooms.mjs",
|
|
41
|
+
"require": "./dist/server/rooms.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./server/checkpoint": {
|
|
44
|
+
"import": "./dist/server/checkpoint.mjs",
|
|
45
|
+
"require": "./dist/server/checkpoint.cjs"
|
|
46
|
+
},
|
|
38
47
|
"./*": "./entries/*"
|
|
39
48
|
},
|
|
40
49
|
"files": [
|
|
@@ -63,6 +72,7 @@
|
|
|
63
72
|
"deploy": "node build.js && wrangler deploy && git rev-parse HEAD > .deploy",
|
|
64
73
|
"build:parse5": "node scripts/build-parse5-vendor.mjs",
|
|
65
74
|
"build:prosemirror": "node scripts/build-prosemirror-vendor.mjs",
|
|
75
|
+
"build:yjs": "node scripts/build-yjs-vendor.mjs",
|
|
66
76
|
"build:bevel": "node scripts/build-bevel-subset.mjs",
|
|
67
77
|
"check:bevel": "node scripts/build-bevel-subset.mjs --check",
|
|
68
78
|
"build:skins": "node scripts/build-vendor-skins.mjs",
|
|
@@ -74,10 +84,13 @@
|
|
|
74
84
|
"@web/test-runner": "^0.20.2",
|
|
75
85
|
"@web/test-runner-commands": "^0.9.0",
|
|
76
86
|
"@web/test-runner-playwright": "^0.11.1",
|
|
87
|
+
"cheerio": "1.2.0",
|
|
77
88
|
"esbuild": "^0.28.2",
|
|
89
|
+
"hyper-morph": "1.6.3",
|
|
78
90
|
"jest": "^29.7.0",
|
|
79
91
|
"jest-environment-jsdom": "^29.7.0",
|
|
80
92
|
"jsdom": "^20.0.3",
|
|
93
|
+
"lib0": "0.2.119",
|
|
81
94
|
"marked": "^18.0.14",
|
|
82
95
|
"parse5": "^7.3.0",
|
|
83
96
|
"playwright": "1.62.1",
|
|
@@ -93,7 +106,8 @@
|
|
|
93
106
|
"prosemirror-transform": "1.12.2",
|
|
94
107
|
"prosemirror-view": "1.42.6",
|
|
95
108
|
"turndown": "^7.2.4",
|
|
96
|
-
"turndown-plugin-gfm": "^1.0.2"
|
|
109
|
+
"turndown-plugin-gfm": "^1.0.2",
|
|
110
|
+
"yjs": "13.6.27"
|
|
97
111
|
},
|
|
98
112
|
"hyper": {
|
|
99
113
|
"kind": "lib",
|
package/packed-contract.json
CHANGED
|
@@ -11,8 +11,23 @@
|
|
|
11
11
|
"@panphora/clayjs/entries/clay-ui.js",
|
|
12
12
|
"@panphora/clayjs/entries/clay-utils.js",
|
|
13
13
|
"@panphora/clayjs/entries/sap.js",
|
|
14
|
-
"@panphora/clayjs/clay.standalone.js"
|
|
14
|
+
"@panphora/clayjs/clay.standalone.js",
|
|
15
|
+
"@panphora/clayjs/server/rooms",
|
|
16
|
+
"@panphora/clayjs/server/checkpoint",
|
|
17
|
+
"@panphora/clayjs/page/yjs"
|
|
15
18
|
],
|
|
16
|
-
"members": [
|
|
17
|
-
|
|
19
|
+
"members": [
|
|
20
|
+
"THIRD-PARTY-NOTICES.md",
|
|
21
|
+
"dist/server/core.cjs",
|
|
22
|
+
"dist/server/rooms.cjs",
|
|
23
|
+
"dist/server/rooms.mjs",
|
|
24
|
+
"dist/server/checkpoint.cjs",
|
|
25
|
+
"dist/server/checkpoint.mjs",
|
|
26
|
+
"docs/guide.md"
|
|
27
|
+
],
|
|
28
|
+
"families": [
|
|
29
|
+
"./entries/*",
|
|
30
|
+
"./dist/*",
|
|
31
|
+
"./src/*"
|
|
32
|
+
]
|
|
18
33
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Boot state shared by the loader and save.js. On a page with a derive engine
|
|
2
|
+
// (a [sap] root) the loader holds save.js's settled boot baseline until the
|
|
3
|
+
// engine's first pass has painted the page, then releases it (loader.js,
|
|
4
|
+
// mountDerivedEngine). Every other page, and any test that imports save.js
|
|
5
|
+
// directly, never sets the hold.
|
|
6
|
+
export const bootPhase = { holdSettle: false };
|
|
@@ -36,7 +36,7 @@ export function buildRecovery(records, { refused = false } = {}) {
|
|
|
36
36
|
if (apply && !seen.has(apply.id)) { seen.add(apply.id); applies.push(apply); }
|
|
37
37
|
}
|
|
38
38
|
applies.sort((a, b) => (a.ticket || 0) - (b.ticket || 0));
|
|
39
|
-
const pageOf = (a) => serializeRecoveryClone(a.root, { prepared: a.domain === "save" });
|
|
39
|
+
const pageOf = (a) => serializeRecoveryClone(a.recoveryRoot ?? a.root, { prepared: a.domain === "save" });
|
|
40
40
|
|
|
41
41
|
let html;
|
|
42
42
|
let older;
|
|
@@ -67,10 +67,9 @@ export function buildRecovery(records, { refused = false } = {}) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export function
|
|
70
|
+
export function downloadHtml({ html, name }) {
|
|
71
71
|
let url = null;
|
|
72
72
|
try {
|
|
73
|
-
const { html, name } = buildRecovery(records, { refused });
|
|
74
73
|
url = URL.createObjectURL(new Blob([html], { type: "text/html" }));
|
|
75
74
|
const a = document.createElement("a");
|
|
76
75
|
a.setAttribute("clay", "no-save no-watch no-snapshot");
|
|
@@ -89,3 +88,13 @@ export function downloadRecovery(records, { refused = false } = {}) {
|
|
|
89
88
|
return false;
|
|
90
89
|
}
|
|
91
90
|
}
|
|
91
|
+
|
|
92
|
+
export function downloadRecovery(records, { refused = false } = {}) {
|
|
93
|
+
try {
|
|
94
|
+
const { html, name } = buildRecovery(records, { refused });
|
|
95
|
+
return downloadHtml({ html, name });
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error("clayjs: could not build the download", err);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
package/src/core/host-meta.js
CHANGED
|
@@ -107,6 +107,81 @@ export function resetHostMeta() {
|
|
|
107
107
|
refreshing = null;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Ask the host what became of one identified save.
|
|
112
|
+
*
|
|
113
|
+
* The same discovery document answers it, but this is a separate request with its
|
|
114
|
+
* own abort timer: it must not share the memoized discovery promise, must not
|
|
115
|
+
* update the cached document, and must not record any ETag. Two concurrent
|
|
116
|
+
* questions get two independent answers.
|
|
117
|
+
*
|
|
118
|
+
* The host must have advertised `save-history`, the response must be a spec
|
|
119
|
+
* document that still advertises it, and the echoed id and hash must match this
|
|
120
|
+
* question exactly. Anything else, including a network failure or a timeout at
|
|
121
|
+
* six seconds, is null; a wrong or missing answer is never read as "not applied".
|
|
122
|
+
*
|
|
123
|
+
* @param {Object} query
|
|
124
|
+
* @param {string} query.saveId
|
|
125
|
+
* @param {string} query.requestHash
|
|
126
|
+
* @param {AbortSignal} [query.signal]
|
|
127
|
+
* @returns {Promise<?{saveId: string, requestHash: string, status: "applied"|"unknown"}>}
|
|
128
|
+
*/
|
|
129
|
+
export async function querySaveOutcome({ saveId, requestHash, signal } = {}) {
|
|
130
|
+
if (isDraftMode) return null;
|
|
131
|
+
if (typeof saveId !== 'string' || !saveId) return null;
|
|
132
|
+
if (typeof requestHash !== 'string' || !requestHash) return null;
|
|
133
|
+
if (!/^https?:$/.test(window.location.protocol)) return null;
|
|
134
|
+
if (signal?.aborted) return null;
|
|
135
|
+
|
|
136
|
+
const controller = new AbortController();
|
|
137
|
+
const abort = () => controller.abort();
|
|
138
|
+
const timeoutId = setTimeout(abort, META_TIMEOUT_MS);
|
|
139
|
+
signal?.addEventListener('abort', abort);
|
|
140
|
+
try {
|
|
141
|
+
const meta = await hostMeta();
|
|
142
|
+
if (hostMetaOutcome(meta) !== 'ok' || !meta.extensions.includes('save-history')) return null;
|
|
143
|
+
if (controller.signal.aborted) return null;
|
|
144
|
+
|
|
145
|
+
const token = saveToken();
|
|
146
|
+
const path = token ? `${META_PATH}/${token}` : META_PATH;
|
|
147
|
+
const res = await fetch(new URL(path, window.location.origin).href, {
|
|
148
|
+
method: 'GET',
|
|
149
|
+
credentials: token ? 'omit' : 'same-origin',
|
|
150
|
+
headers: {
|
|
151
|
+
'Document-URL': window.location.href,
|
|
152
|
+
'Save-ID': saveId,
|
|
153
|
+
'Save-Request-Hash': requestHash
|
|
154
|
+
},
|
|
155
|
+
cache: 'no-store',
|
|
156
|
+
redirect: 'manual',
|
|
157
|
+
signal: controller.signal
|
|
158
|
+
});
|
|
159
|
+
if (!res.ok) return null;
|
|
160
|
+
const text = await res.text();
|
|
161
|
+
if (!text) return null;
|
|
162
|
+
|
|
163
|
+
let body;
|
|
164
|
+
try {
|
|
165
|
+
body = JSON.parse(text);
|
|
166
|
+
} catch (_) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
if (!body || typeof body !== 'object' || typeof body.spec !== 'number') return null;
|
|
170
|
+
if (!Array.isArray(body.extensions) || !body.extensions.includes('save-history')) return null;
|
|
171
|
+
const outcome = body.document && typeof body.document === 'object' ? body.document.saveOutcome : null;
|
|
172
|
+
if (!outcome || typeof outcome !== 'object') return null;
|
|
173
|
+
if (outcome.saveId !== saveId || outcome.requestHash !== requestHash) return null;
|
|
174
|
+
if (outcome.status !== 'applied' && outcome.status !== 'unknown') return null;
|
|
175
|
+
|
|
176
|
+
return { saveId, requestHash, status: outcome.status };
|
|
177
|
+
} catch (_) {
|
|
178
|
+
return null;
|
|
179
|
+
} finally {
|
|
180
|
+
clearTimeout(timeoutId);
|
|
181
|
+
signal?.removeEventListener('abort', abort);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
110
185
|
async function fetchMeta() {
|
|
111
186
|
// A file opened from disk has no host to ask, and fetch would only throw.
|
|
112
187
|
if (!/^https?:$/.test(window.location.protocol)) return settle("none");
|