@panphora/clayjs 1.26.1 → 1.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +4 -3
  11. package/dist/m/{c-EQ5NBOGA.js → c-26W3BMWK.js} +1 -1
  12. package/dist/m/{c-AQVQKFKB.js → c-3JQY5MB2.js} +1 -1
  13. package/dist/m/{c-MKAUC6DB.js → c-3KG4SDZ5.js} +1 -1
  14. package/dist/m/{c-HYNM5U6B.js → c-5CJCIAFK.js} +1 -1
  15. package/dist/m/{c-O3DPFZCE.js → c-6266A3CU.js} +1 -1
  16. package/dist/m/{c-WOJ2RTV4.js → c-627JDXWT.js} +1 -1
  17. package/dist/m/{c-MMEVDN6D.js → c-7PZS45FY.js} +1 -1
  18. package/dist/m/{c-NYJ577NL.js → c-7RJCYD4F.js} +1 -1
  19. package/dist/m/{c-EHAR4RJJ.js → c-CKG4NF7J.js} +2 -2
  20. package/dist/m/{c-EXZOA6XY.js → c-E37MV4WS.js} +1 -1
  21. package/dist/m/{c-N4GEJMXW.js → c-EFXPKDJP.js} +1 -1
  22. package/dist/m/{c-ZPI7M5U5.js → c-G426P2SE.js} +1 -1
  23. package/dist/m/{c-BJ2RRQBQ.js → c-GXOUAT7E.js} +1 -1
  24. package/dist/m/{c-VU4WEWPH.js → c-H25R2UF3.js} +1 -1
  25. package/dist/m/{c-VO6RSFCO.js → c-HBSBQBD7.js} +1 -1
  26. package/dist/m/{c-CL5LSATX.js → c-I4ZVJZC7.js} +1 -1
  27. package/dist/m/{c-67TBU56I.js → c-I62KCFMW.js} +1 -1
  28. package/dist/m/{c-Y3MPVURA.js → c-IJ4VUYDN.js} +1 -1
  29. package/dist/m/{c-FC5RUFPR.js → c-IOJOJTPL.js} +1 -1
  30. package/dist/m/{c-HXGNH6GY.js → c-IPCSVZAB.js} +1 -1
  31. package/dist/m/c-JEWSJHMK.js +1 -0
  32. package/dist/m/{c-3F3AADKG.js → c-JOA4OJGK.js} +1 -1
  33. package/dist/m/{c-GFASNR55.js → c-JUSHNY3I.js} +1 -1
  34. package/dist/m/{c-7RHOMAMR.js → c-K5HRHUTK.js} +1 -1
  35. package/dist/m/{c-H3M6UDNV.js → c-KFXW6SZO.js} +1 -1
  36. package/dist/m/{c-EAV7A6BT.js → c-MB5FZ2PD.js} +1 -1
  37. package/dist/m/{c-2EPHRF47.js → c-MIQYK2VM.js} +1 -1
  38. package/dist/m/{c-ARO6CPMA.js → c-O3BSWMVD.js} +1 -1
  39. package/dist/m/{c-U35T5NAY.js → c-O54PVIAQ.js} +1 -1
  40. package/dist/m/{c-H4M2T4A6.js → c-OEEJRV2M.js} +1 -1
  41. package/dist/m/{c-KU3PX7LL.js → c-OSGTRM4C.js} +1 -1
  42. package/dist/m/{c-YZGWSCMT.js → c-QLGTY326.js} +1 -1
  43. package/dist/m/{c-WOWGGNCJ.js → c-RC37IFYT.js} +1 -1
  44. package/dist/m/{c-SMLAJASY.js → c-RHYX6KUH.js} +1 -1
  45. package/dist/m/{c-RGFPLQGV.js → c-SMCZC3V6.js} +1 -1
  46. package/dist/m/{c-P73XPAOA.js → c-T6RRRHX7.js} +1 -1
  47. package/dist/m/{c-3S5TNRZA.js → c-USO6XV23.js} +1 -1
  48. package/dist/m/{c-ZFAPQQIB.js → c-VPUSMVKE.js} +1 -1
  49. package/dist/m/{c-YYIN4NAF.js → c-VXJJ7BJL.js} +1 -1
  50. package/dist/m/{c-EEWPNUM2.js → c-W3DMFFGK.js} +1 -1
  51. package/dist/m/{c-755ZOHOM.js → c-W5HY5JHM.js} +1 -1
  52. package/dist/m/{c-C5UGNOC2.js → c-WJVW76R6.js} +1 -1
  53. package/dist/m/{c-Q2CB57UG.js → c-X3WLDGBX.js} +1 -1
  54. package/dist/m/{c-SRW5OBCF.js → c-XLVZN7DT.js} +1 -1
  55. package/dist/m/{c-3WX5FABT.js → c-YIFBOWQE.js} +1 -1
  56. package/dist/m/{c-34J5HC7N.js → c-YJS2V3MX.js} +1 -1
  57. package/dist/m/core/{admin-attrs-43JBA6JB.js → admin-attrs-H26XE2AE.js} +1 -1
  58. package/dist/m/core/{autosave-HD7Y7UNV.js → autosave-U5UIKPM3.js} +1 -1
  59. package/dist/m/core/{conflict-notice-UNDOD4BL.js → conflict-notice-HTF6CECH.js} +1 -1
  60. package/dist/m/core/{host-permission-5BYP24GC.js → host-permission-JHMPKRPO.js} +1 -1
  61. package/dist/m/core/{is-edit-mode-73OXKK5H.js → is-edit-mode-QBJUFMVF.js} +1 -1
  62. package/dist/m/core/{persist-MX3VYVBN.js → persist-TRXZPS6T.js} +1 -1
  63. package/dist/m/core/{recovery-VZF7RJZF.js → recovery-YJS7CI66.js} +1 -1
  64. package/dist/m/core/{save-JZ7R4ET2.js → save-KY3ZMPU4.js} +1 -1
  65. package/dist/m/core/{save-core-I4N6S4ED.js → save-core-LBW6DNJ6.js} +1 -1
  66. package/dist/m/core/{site-edits-C22O53GS.js → site-edits-M44KWAQN.js} +1 -1
  67. package/dist/m/core/{unsaved-warning-BP6ZY3PG.js → unsaved-warning-2X7NJNHZ.js} +1 -1
  68. package/dist/m/internals/{index-3LAVREAU.js → index-CDXUFQZK.js} +1 -1
  69. package/dist/m/{loader-RHUGUKXI.js → loader-CRCEH7TD.js} +1 -1
  70. package/dist/m/manifest-6D031725.js +1 -0
  71. package/dist/m/{manifest-edit-93AA79D7.js → manifest-edit-A75598BC.js} +1 -1
  72. package/dist/m/manifest.json +584 -584
  73. package/dist/m/plugins/{ai-edit-WDV2GLDU.js → ai-edit-T2SM7TRD.js} +1 -1
  74. package/dist/m/plugins/{demo-LMCMBILC.js → demo-57MJ3GOO.js} +1 -1
  75. package/dist/m/plugins/{indicator-OLPZ4WFI.js → indicator-D5PZJGVS.js} +1 -1
  76. package/dist/m/plugins/{live-DF5YS5AH.js → live-J52JO243.js} +1 -1
  77. package/dist/m/plugins/{menu-ESEFQARM.js → menu-KCCEDUMJ.js} +1 -1
  78. package/dist/m/plugins/{page-GZSU77JS.js → page-F7JG3JZX.js} +2 -2
  79. package/dist/m/plugins/{page-view-7MM3FEAR.js → page-view-QPRXXAT3.js} +1 -1
  80. package/dist/m/plugins/{people-EBWE337I.js → people-FEMXINJK.js} +1 -1
  81. package/dist/m/plugins/{richclay-MXH2GFAZ.js → richclay-XL64ZGOZ.js} +2 -2
  82. package/dist/m/plugins/{sortable-BAG3MSWS.js → sortable-HE7Q4KKP.js} +1 -1
  83. package/dist/m/plugins/{source-OYHDXKTB.js → source-5RTLTD75.js} +1 -1
  84. package/dist/m/plugins/{undo-KLHAGV75.js → undo-5MFW3OD5.js} +1 -1
  85. package/dist/m/plugins/{upgrade-SZQJYEQQ.js → upgrade-ORK24FK6.js} +1 -1
  86. package/dist/m/plugins/{upload-NZET3DNQ.js → upload-YMBDWTLR.js} +1 -1
  87. package/dist/m/plugins/{visitor-drafts-ZE6PCAFP.js → visitor-drafts-DCVGLCBX.js} +2 -2
  88. package/dist/m/plugins/{visitor-drafts-owner-TLECTYWS.js → visitor-drafts-owner-QLF6IALP.js} +1 -1
  89. package/dist/m/plugins/{visitor-menu-5XY57JQA.js → visitor-menu-VNWJZ6PV.js} +1 -1
  90. package/dist/m/plugins/{wire-S5ATC4QI.js → wire-I3TDGBGZ.js} +1 -1
  91. package/dist/m/{reader-core-AHOAP5DH.js → reader-core-7JOVUCEQ.js} +2 -2
  92. package/dist/m/sync/{live-sync-RZQSDMZW.js → live-sync-2UYQQSD7.js} +1 -1
  93. package/dist/offline-manifest.json +377 -377
  94. package/package.json +1 -1
  95. package/src/core/mode-receipt.js +7 -5
  96. package/dist/m/c-C7SUMNMI.js +0 -1
  97. package/dist/m/manifest-D70FE013.js +0 -1
  98. /package/dist/m/plugins/{richclay-MXH2GFAZ.js.LEGAL.txt → richclay-XL64ZGOZ.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{a as I,c as V}from"../c-RVMWGXEJ.js";import{a as P,d as j}from"../c-EQ5NBOGA.js";import{f as K,j as M}from"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var b=()=>window.clay&&"isEditMode"in window.clay?!!window.clay.isEditMode:K,pe=/^[A-Za-z0-9_-]{8,64}$/,D="clay:people:me",de=2e3,B=120,Q=/\S+@\S+\.\S+/,a={supports:!1,me:null,members:null,unavailable:!1},l=null,m,u=null,f=null,y=null,x=null,N="",_=null;function g(e){if(!e||typeof e!="object")return null;let t=typeof e.id=="string"?e.id:"",n=typeof e.name=="string"?e.name.trim().replace(/\s+/g," "):"";return!pe.test(t)||!n||n.length>B||Q.test(n)?null:{id:t,name:n}}function p({id:e,name:t}){return Object.freeze({id:e,name:t,initials:V(t),color:I(e)})}function E(){document.dispatchEvent(new CustomEvent("clay:people",{detail:{me:ee()}}))}function fe(){return document.querySelector("[clay-people]")}function O(){return[...document.querySelectorAll("[clay-people] data[value]")]}function R(){if(u)return u;u=new Map;for(let e of O()){let t=g({id:e.getAttribute("value"),name:e.textContent});t&&!u.has(t.id)&&u.set(t.id,p(t))}return u}function S(){if(m===void 0){m=null;try{m=g(JSON.parse(window.localStorage.getItem(D)||"null"))}catch{}}return m}function q(e){m=e;try{window.localStorage.setItem(D,JSON.stringify(e))}catch{}}function me(){let e=new Uint8Array(16);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ee(){if(!b())return null;if(a.me)return p(a.me);if(a.unavailable||l!=="ok"&&l!=="none")return null;let e=S();return e?p(e):null}function te(e){let t=P(e);if(t!=="ok"&&a.supports)return;let n=e.document?.people,o=e.extensions.includes("people")&&!!n&&typeof n=="object",r={supports:o,me:o?g(n.me):null,members:o&&Array.isArray(n.members)?n.members.map(g).filter(Boolean):null,unavailable:o&&n.unavailable===!0},s=t!==l||JSON.stringify(r)!==JSON.stringify(a);a=r,l=t,s&&E()}async function k(e){te(await j({fresh:e}))}function ne(e){L();let t=String(e??""),n=a.me?.id===t&&a.me||a.members?.find(r=>r.id===t);if(n)return p(n);let o=S();return o?.id===t?p(o):R().get(t)||Object.freeze({id:t,name:"Unknown person",initials:"?",color:I(t)})}function oe(){return L(),[...R().keys()].map(ne)}async function be(){return await k(l!=="none"),a.members?a.members.map(p):null}function J(e){let t=g(e);if(!t)throw new TypeError("clay.people.add: needs an id of 8 to 64 letters, digits, _ or -, and a name of 1 to 120 characters");let n=fe();n||(n=document.createElement("div"),n.setAttribute("clay-people",""),n.hidden=!0,document.body.append(n));let o=O().filter(r=>r.getAttribute("value")===t.id);if(o.length){o[0].textContent!==t.name&&(o[0].textContent=t.name);for(let r of o.slice(1))r.remove()}else{let r=document.createElement("data");r.setAttribute("value",t.id),r.textContent=t.name,n.append(r)}return u=null,p(t)}function ge(e){let t=String(e??"");for(let n of O())n.getAttribute("value")===t&&n.remove();u=null}function re(){return b()&&!a.me&&(l==="ok"||l==="none")&&!!S()&&!a.unavailable}function he(e){if(!re())throw Object.assign(new Error("clay.people.rename: only a name chosen in this browser can be changed here"),{code:"not-renamable"});let t=S(),n=g({id:t.id,name:e});if(!n)throw new TypeError("clay.people.rename: needs a name of 1 to 120 characters that is not an email address");return q(n),O().some(o=>o.getAttribute("value")===n.id)&&J(n),E(),p(n)}var ye=e=>e!==M().generation||!b();function z(e){if(ye(e))throw Object.assign(new Error("clay.author: the page left edit mode before your name was recorded"),{code:"stale-document"})}function X(){return Object.assign(new Error("Can't reach the host to check who you are. Try again in a moment."),{code:"people-unavailable"})}async function Pe(e,t="data-by"){if(!window.clay?.isEditMode)throw new Error("clay.author: this page is not in edit mode");if(!(e instanceof Element))throw new TypeError("clay.author: needs an element");let n=M().generation;if(a.supports){let r=await j({fresh:!0});z(n);let s=P(r);if(s==="none")throw Object.assign(new Error("This page lost its connection to the host. Reload it to keep editing."),{code:"people-unavailable"});if(s!=="ok")throw X();if(te(r),a.unavailable)throw Object.assign(new Error("The app hosting this file can't name you right now. Check its Profile settings, then try again."),{code:"people-unavailable"})}else l!=="ok"&&l!=="none"&&(await k(l==="failed"),z(n));if(l==="failed")throw X();let o=ee();if(!o){let r=await ve();if(z(n),!r)return null;q(r),o=p(r),E()}return J(o),e.setAttribute(t,o.id),o}function we(){return _??=Promise.all([import("../c-RES2S5Q3.js"),import("../c-33SS5A4Y.js"),import("../c-OCSZ4QGN.js")]).then(([e,t,n])=>({...e,...t,resolveTheme:n.resolveTheme})).catch(e=>{throw _=null,e}),_}function ve(){return f&&(!y||y.isConnected)||(f&&x(),f=xe().catch(e=>{throw f=null,y=null,x=null,e})),f}async function xe(){let e=await we();return new Promise(t=>{let n=e.resolveTheme(),{root:o,overlay:r,panel:s,heading:ae,body:U,footer:le,close:se}=e.bevelDialog({zIndex:"2147483001",width:"420px",closable:!0,titled:!0,theme:n,surface:"people"});y=o,x=()=>d(null),ae.textContent="What name should appear on your changes?",s.setAttribute("aria-label","Your name");let c=e.bevelInput("input",{rules:["display:block","width:100%","margin:0"],theme:n,parts:["dialog.input","people.input"]});c.setAttribute("aria-label","Your name"),c.maxLength=B,c.autocomplete="name";let h=e.bevelText("p",["display:block","margin:10px 0 0","font-size:13px","opacity:.8"],"Saved in this browser. Everyone who can read this page will see it.",{theme:n,parts:["dialog.hint","people.hint"],role:"mutedText"}),F=h.textContent;U.append(c,h);let W=oe().slice(0,8);if(W.length){let i=e.bevelText("p",["display:block","margin:18px 0 8px","font-size:13px"],"Or continue as someone already in this page:",{theme:n,parts:["people.choiceLabel"],role:"mutedText"}),H=e.bevelBox("div",["display:flex","flex-wrap:wrap","gap:8px"],{theme:n,parts:["people.choices"]});for(let T of W)H.append(e.bevelButton(T.name,{small:!0,onClick:()=>d({id:T.id,name:T.name}),theme:n,parts:["dialog.button","people.button","people.choice"],labelParts:["dialog.buttonLabel","people.buttonLabel"]}));U.append(i,H)}let ce=e.bevelButton("Cancel",{onClick:()=>d(null),theme:n,parts:["dialog.button","people.button"],labelParts:["dialog.buttonLabel","people.buttonLabel"]}),ue=e.bevelButton("Continue",{variant:"primary",onClick:()=>A(),theme:n,parts:["dialog.button","people.button"],labelParts:["dialog.buttonLabel","people.buttonLabel"]});le.append(ce,ue);let A=()=>{let i=c.value.trim().replace(/\s+/g," ");if(!i){c.focus();return}if(Q.test(i)){h.textContent="Use a name, not an email address. Everyone who can read this page will see it.",c.focus();return}d({id:me(),name:i.slice(0,B)})};c.addEventListener("input",()=>{h.textContent!==F&&(h.textContent=F)}),s.addEventListener("submit",i=>{i.preventDefault(),A()}),se?.addEventListener("click",()=>d(null));let C=!1;r.addEventListener("mousedown",i=>{C=i.target===r}),r.addEventListener("click",i=>{C&&i.target===r&&d(null),C=!1});let Y=i=>{if(i.key==="Tab"){i.stopPropagation(),e.keepFocusIn(s,i);return}i.key==="Escape"?(i.preventDefault(),i.stopPropagation(),d(null)):i.key==="Enter"&&i.target===c&&(i.preventDefault(),i.stopPropagation(),A())};document.addEventListener("keydown",Y,!0);let $=!1;function d(i){$||($=!0,document.removeEventListener("keydown",Y,!0),o.remove(),i&&q(i),f=null,y=null,x=null,t(i))}e.dismissOf.set(o,()=>d(null)),o.setAttribute("aria-hidden","false"),Ee().append(o),c.focus()})}function Ee(){let e=[...document.querySelectorAll("dialog[open]")].filter(t=>t.matches(":modal"));return e[e.length-1]||document.body}function Z(e){return e.nodeType===1&&(e.matches("[clay-people]")||!!e.querySelector("[clay-people]"))}function G(){return JSON.stringify([...R().values()].map(({id:e,name:t})=>[e,t]))}var w=null;function L(){let e=document;if(w?.doc===e)return;w?.observer.disconnect(),N=G();let t=new MutationObserver(n=>{if(!(typeof document>"u"||document!==e))for(let o of n){let r=o.target.nodeType===1?o.target:o.target.parentElement;if(o.attributeName==="clay-people"||r?.closest("[clay-people]")||[...o.addedNodes].some(Z)||[...o.removedNodes].some(Z)){u=null;let s=G();s!==N&&(N=s,E());return}}});t.observe(e.body,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["value","clay-people"]}),w={doc:e,observer:t}}function ke(){w?.observer.disconnect(),w=null}var v=null;function ie(){if(!b())return Promise.resolve(null);if(!v){let e=new AbortController,{signal:t}=e;window.addEventListener("storage",n=>{n.key!==D||!b()||(m=void 0,E())},{signal:t}),document.addEventListener("visibilitychange",()=>{b()&&document.visibilityState==="visible"&&l!=="none"&&k(!0)},{signal:t}),v={listeners:e,first:k(!1)}}return Promise.race([v.first,new Promise(e=>setTimeout(e,de))])}function Oe(){v?.listeners.abort(),v=null}async function Se(){L(),await ie()}function Le(){return{enable(){L(),ie()},quiesce(){if(f)throw Object.assign(new Error("clay:people: a name is still being chosen"),{code:"pending-input",pending:["name"]})},resume(){},dispose(){x?.(),ke(),Oe()}}}function je(){return{id:"clay:people",order:330,prepare(e={}){let t=Le();return e.initial!==!0?t:{...t,enable(){}}}}}var Ae=Object.freeze({get:ne,list:oe,available:be,add:J,remove:ge,canRename:re,rename:he}),Ie=Se(),Ne=Ae;export{Pe as author,ee as currentMe,Ne as default,je as modeParticipant,Ae as people,je as peopleParticipant,Ie as ready};
1
+ import{a as I,c as V}from"../c-RVMWGXEJ.js";import{a as P,d as j}from"../c-26W3BMWK.js";import{f as K,j as M}from"../c-JEWSJHMK.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var b=()=>window.clay&&"isEditMode"in window.clay?!!window.clay.isEditMode:K,pe=/^[A-Za-z0-9_-]{8,64}$/,D="clay:people:me",de=2e3,B=120,Q=/\S+@\S+\.\S+/,a={supports:!1,me:null,members:null,unavailable:!1},l=null,m,u=null,f=null,y=null,x=null,N="",_=null;function g(e){if(!e||typeof e!="object")return null;let t=typeof e.id=="string"?e.id:"",n=typeof e.name=="string"?e.name.trim().replace(/\s+/g," "):"";return!pe.test(t)||!n||n.length>B||Q.test(n)?null:{id:t,name:n}}function p({id:e,name:t}){return Object.freeze({id:e,name:t,initials:V(t),color:I(e)})}function E(){document.dispatchEvent(new CustomEvent("clay:people",{detail:{me:ee()}}))}function fe(){return document.querySelector("[clay-people]")}function O(){return[...document.querySelectorAll("[clay-people] data[value]")]}function R(){if(u)return u;u=new Map;for(let e of O()){let t=g({id:e.getAttribute("value"),name:e.textContent});t&&!u.has(t.id)&&u.set(t.id,p(t))}return u}function S(){if(m===void 0){m=null;try{m=g(JSON.parse(window.localStorage.getItem(D)||"null"))}catch{}}return m}function q(e){m=e;try{window.localStorage.setItem(D,JSON.stringify(e))}catch{}}function me(){let e=new Uint8Array(16);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ee(){if(!b())return null;if(a.me)return p(a.me);if(a.unavailable||l!=="ok"&&l!=="none")return null;let e=S();return e?p(e):null}function te(e){let t=P(e);if(t!=="ok"&&a.supports)return;let n=e.document?.people,o=e.extensions.includes("people")&&!!n&&typeof n=="object",r={supports:o,me:o?g(n.me):null,members:o&&Array.isArray(n.members)?n.members.map(g).filter(Boolean):null,unavailable:o&&n.unavailable===!0},s=t!==l||JSON.stringify(r)!==JSON.stringify(a);a=r,l=t,s&&E()}async function k(e){te(await j({fresh:e}))}function ne(e){L();let t=String(e??""),n=a.me?.id===t&&a.me||a.members?.find(r=>r.id===t);if(n)return p(n);let o=S();return o?.id===t?p(o):R().get(t)||Object.freeze({id:t,name:"Unknown person",initials:"?",color:I(t)})}function oe(){return L(),[...R().keys()].map(ne)}async function be(){return await k(l!=="none"),a.members?a.members.map(p):null}function J(e){let t=g(e);if(!t)throw new TypeError("clay.people.add: needs an id of 8 to 64 letters, digits, _ or -, and a name of 1 to 120 characters");let n=fe();n||(n=document.createElement("div"),n.setAttribute("clay-people",""),n.hidden=!0,document.body.append(n));let o=O().filter(r=>r.getAttribute("value")===t.id);if(o.length){o[0].textContent!==t.name&&(o[0].textContent=t.name);for(let r of o.slice(1))r.remove()}else{let r=document.createElement("data");r.setAttribute("value",t.id),r.textContent=t.name,n.append(r)}return u=null,p(t)}function ge(e){let t=String(e??"");for(let n of O())n.getAttribute("value")===t&&n.remove();u=null}function re(){return b()&&!a.me&&(l==="ok"||l==="none")&&!!S()&&!a.unavailable}function he(e){if(!re())throw Object.assign(new Error("clay.people.rename: only a name chosen in this browser can be changed here"),{code:"not-renamable"});let t=S(),n=g({id:t.id,name:e});if(!n)throw new TypeError("clay.people.rename: needs a name of 1 to 120 characters that is not an email address");return q(n),O().some(o=>o.getAttribute("value")===n.id)&&J(n),E(),p(n)}var ye=e=>e!==M().generation||!b();function z(e){if(ye(e))throw Object.assign(new Error("clay.author: the page left edit mode before your name was recorded"),{code:"stale-document"})}function X(){return Object.assign(new Error("Can't reach the host to check who you are. Try again in a moment."),{code:"people-unavailable"})}async function Pe(e,t="data-by"){if(!window.clay?.isEditMode)throw new Error("clay.author: this page is not in edit mode");if(!(e instanceof Element))throw new TypeError("clay.author: needs an element");let n=M().generation;if(a.supports){let r=await j({fresh:!0});z(n);let s=P(r);if(s==="none")throw Object.assign(new Error("This page lost its connection to the host. Reload it to keep editing."),{code:"people-unavailable"});if(s!=="ok")throw X();if(te(r),a.unavailable)throw Object.assign(new Error("The app hosting this file can't name you right now. Check its Profile settings, then try again."),{code:"people-unavailable"})}else l!=="ok"&&l!=="none"&&(await k(l==="failed"),z(n));if(l==="failed")throw X();let o=ee();if(!o){let r=await ve();if(z(n),!r)return null;q(r),o=p(r),E()}return J(o),e.setAttribute(t,o.id),o}function we(){return _??=Promise.all([import("../c-RES2S5Q3.js"),import("../c-33SS5A4Y.js"),import("../c-OCSZ4QGN.js")]).then(([e,t,n])=>({...e,...t,resolveTheme:n.resolveTheme})).catch(e=>{throw _=null,e}),_}function ve(){return f&&(!y||y.isConnected)||(f&&x(),f=xe().catch(e=>{throw f=null,y=null,x=null,e})),f}async function xe(){let e=await we();return new Promise(t=>{let n=e.resolveTheme(),{root:o,overlay:r,panel:s,heading:ae,body:U,footer:le,close:se}=e.bevelDialog({zIndex:"2147483001",width:"420px",closable:!0,titled:!0,theme:n,surface:"people"});y=o,x=()=>d(null),ae.textContent="What name should appear on your changes?",s.setAttribute("aria-label","Your name");let c=e.bevelInput("input",{rules:["display:block","width:100%","margin:0"],theme:n,parts:["dialog.input","people.input"]});c.setAttribute("aria-label","Your name"),c.maxLength=B,c.autocomplete="name";let h=e.bevelText("p",["display:block","margin:10px 0 0","font-size:13px","opacity:.8"],"Saved in this browser. Everyone who can read this page will see it.",{theme:n,parts:["dialog.hint","people.hint"],role:"mutedText"}),F=h.textContent;U.append(c,h);let W=oe().slice(0,8);if(W.length){let i=e.bevelText("p",["display:block","margin:18px 0 8px","font-size:13px"],"Or continue as someone already in this page:",{theme:n,parts:["people.choiceLabel"],role:"mutedText"}),H=e.bevelBox("div",["display:flex","flex-wrap:wrap","gap:8px"],{theme:n,parts:["people.choices"]});for(let T of W)H.append(e.bevelButton(T.name,{small:!0,onClick:()=>d({id:T.id,name:T.name}),theme:n,parts:["dialog.button","people.button","people.choice"],labelParts:["dialog.buttonLabel","people.buttonLabel"]}));U.append(i,H)}let ce=e.bevelButton("Cancel",{onClick:()=>d(null),theme:n,parts:["dialog.button","people.button"],labelParts:["dialog.buttonLabel","people.buttonLabel"]}),ue=e.bevelButton("Continue",{variant:"primary",onClick:()=>A(),theme:n,parts:["dialog.button","people.button"],labelParts:["dialog.buttonLabel","people.buttonLabel"]});le.append(ce,ue);let A=()=>{let i=c.value.trim().replace(/\s+/g," ");if(!i){c.focus();return}if(Q.test(i)){h.textContent="Use a name, not an email address. Everyone who can read this page will see it.",c.focus();return}d({id:me(),name:i.slice(0,B)})};c.addEventListener("input",()=>{h.textContent!==F&&(h.textContent=F)}),s.addEventListener("submit",i=>{i.preventDefault(),A()}),se?.addEventListener("click",()=>d(null));let C=!1;r.addEventListener("mousedown",i=>{C=i.target===r}),r.addEventListener("click",i=>{C&&i.target===r&&d(null),C=!1});let Y=i=>{if(i.key==="Tab"){i.stopPropagation(),e.keepFocusIn(s,i);return}i.key==="Escape"?(i.preventDefault(),i.stopPropagation(),d(null)):i.key==="Enter"&&i.target===c&&(i.preventDefault(),i.stopPropagation(),A())};document.addEventListener("keydown",Y,!0);let $=!1;function d(i){$||($=!0,document.removeEventListener("keydown",Y,!0),o.remove(),i&&q(i),f=null,y=null,x=null,t(i))}e.dismissOf.set(o,()=>d(null)),o.setAttribute("aria-hidden","false"),Ee().append(o),c.focus()})}function Ee(){let e=[...document.querySelectorAll("dialog[open]")].filter(t=>t.matches(":modal"));return e[e.length-1]||document.body}function Z(e){return e.nodeType===1&&(e.matches("[clay-people]")||!!e.querySelector("[clay-people]"))}function G(){return JSON.stringify([...R().values()].map(({id:e,name:t})=>[e,t]))}var w=null;function L(){let e=document;if(w?.doc===e)return;w?.observer.disconnect(),N=G();let t=new MutationObserver(n=>{if(!(typeof document>"u"||document!==e))for(let o of n){let r=o.target.nodeType===1?o.target:o.target.parentElement;if(o.attributeName==="clay-people"||r?.closest("[clay-people]")||[...o.addedNodes].some(Z)||[...o.removedNodes].some(Z)){u=null;let s=G();s!==N&&(N=s,E());return}}});t.observe(e.body,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["value","clay-people"]}),w={doc:e,observer:t}}function ke(){w?.observer.disconnect(),w=null}var v=null;function ie(){if(!b())return Promise.resolve(null);if(!v){let e=new AbortController,{signal:t}=e;window.addEventListener("storage",n=>{n.key!==D||!b()||(m=void 0,E())},{signal:t}),document.addEventListener("visibilitychange",()=>{b()&&document.visibilityState==="visible"&&l!=="none"&&k(!0)},{signal:t}),v={listeners:e,first:k(!1)}}return Promise.race([v.first,new Promise(e=>setTimeout(e,de))])}function Oe(){v?.listeners.abort(),v=null}async function Se(){L(),await ie()}function Le(){return{enable(){L(),ie()},quiesce(){if(f)throw Object.assign(new Error("clay:people: a name is still being chosen"),{code:"pending-input",pending:["name"]})},resume(){},dispose(){x?.(),ke(),Oe()}}}function je(){return{id:"clay:people",order:330,prepare(e={}){let t=Le();return e.initial!==!0?t:{...t,enable(){}}}}}var Ae=Object.freeze({get:ne,list:oe,available:be,add:J,remove:ge,canRename:re,rename:he}),Ie=Se(),Ne=Ae;export{Pe as author,ee as currentMe,Ne as default,je as modeParticipant,Ae as people,je as peopleParticipant,Ie as ready};
@@ -1,4 +1,4 @@
1
- import{a as Oo}from"../c-KD2ME5UN.js";import"../c-J2ZW4HMR.js";import"../c-A5LASUEZ.js";import"../c-4JZDZFF6.js";import"../c-5RZNFTWD.js";import"../c-PKCCHJ5X.js";import{a as br,b as vr}from"../c-FILLTJA7.js";import"../c-NUHP2XDB.js";import{k as Do}from"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import{b as No}from"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var Ro=[".richclay-toolbar",".richclay-float",".richclay-dialog"],Io=`@layer clay-skin{
1
+ import{a as Oo}from"../c-KD2ME5UN.js";import"../c-J2ZW4HMR.js";import"../c-A5LASUEZ.js";import"../c-4JZDZFF6.js";import"../c-5RZNFTWD.js";import"../c-PKCCHJ5X.js";import{a as br,b as vr}from"../c-FILLTJA7.js";import"../c-NUHP2XDB.js";import{k as Do}from"../c-JEWSJHMK.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import{b as No}from"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var Ro=[".richclay-toolbar",".richclay-float",".richclay-dialog"],Io=`@layer clay-skin{
2
2
  :is(.richclay-toolbar, .richclay-float, .richclay-dialog),:is(.richclay-toolbar, .richclay-float, .richclay-dialog) *{--richclay-surface:light-dark(#FFFCF6, #11131E) !important;--richclay-surface-alt:light-dark(#F4ECDF, #1A1D2C) !important;--richclay-text:light-dark(#2B241B, #ECEAF2) !important;--richclay-muted:light-dark(#6B5942, #8A90AB) !important;--richclay-border:light-dark(#D8C8AF, #353B52) !important;--richclay-accent:light-dark(#8F6310, #D9A445) !important;--richclay-accent-ink:light-dark(#FDF8F0, #0B0C13) !important;--richclay-focus:light-dark(#8F6310, #D9A445) !important;--richclay-danger:light-dark(#A83A2C, #FF5566) !important;--richclay-radius:0px !important;--richclay-control-size:32px !important;--richclay-shadow:0 1px 2px rgba(0,0,0,.12),0 10px 28px -12px rgba(0,0,0,.35) !important}
3
3
  :is(.richclay-toolbar, .richclay-float, .richclay-dialog){font-family:system-ui,-apple-system,"Segoe UI",sans-serif !important}
4
4
  :where(.richclay-float, .richclay-dialog):is(.richclay-toolbar, .richclay-float, .richclay-dialog){color:light-dark(#2B241B, #ECEAF2) !important;background:light-dark(#FFFCF6, #11131E) !important;border:1px solid light-dark(#D8C8AF, #353B52) !important}
@@ -546,4 +546,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
546
546
  }
547
547
  }
548
548
  `,re=typeof globalThis<"u"?globalThis:self;re&&!re.Squire&&(re.Squire=_a),re&&!re.DOMPurify&&(re.DOMPurify=ll),ys(Ms);var Bs=Yi.autoInit(),Fs=Yi;return Ko(Cr)})();window.__hyperclayNoAutoExport||(window.hyperclay=window.hyperclay||{},window.hyperclay.RichClay=ti.default,window.RichClay=window.RichClay||ti.default,window.h=window.hyperclay);var tt=ti.default,Nc=ti.default;Oo("richclay",Io,{roots:Ro});var Er=m=>{if(m.hasAttribute("no-undo")&&!m.hasAttribute("data-richclay-runtime-no-undo")||(m.getAttribute("clay")||"").split(/\s+/).includes("no-undo"))return!0;let w=m.parentElement;return!!w&&window.clay?.region?.resolveRegionPolicy?.(w)?.undoable===!1},uc=/^(P|DIV|UL|OL|LI|H[1-6]|BLOCKQUOTE|TABLE|THEAD|TBODY|TR|TD|TH|FIGURE|FIGCAPTION|HR|SECTION|ARTICLE|ASIDE|HEADER|FOOTER|DL|DT|DD)$/,wr=m=>m?.nodeType===1&&uc.test(m.nodeName),pc=m=>{let w=m.ownerDocument.createTreeWalker(m,4),k=[];for(let P=w.nextNode();P;P=w.nextNode()){if(/\S/.test(P.data)||P.parentElement?.closest("pre"))continue;let Ft=P.parentNode;((!P.previousSibling||!P.nextSibling)&&(Ft===m||wr(Ft))||wr(P.previousSibling)||wr(P.nextSibling))&&k.push(P)}k.forEach(P=>P.remove())},Ho=m=>{let w=m.cloneNode(!0);return No(w),pc(w),tt.savedContent(w)},Mo='[editor-ui], [clay~="editor-ui"], [no-undo]:not([data-richclay-runtime-no-undo]), [clay~="no-undo"]',Uo=m=>[...m.querySelectorAll(Mo)].filter(w=>{for(let k=w.parentElement;k&&k!==m;k=k.parentElement)if(k.matches(Mo))return!1;return!0}),fc=m=>{let w=m.cloneNode(!0);return Uo(w).forEach(k=>k.replaceWith(w.ownerDocument.createElement("clay-kept"))),Ho(w)},mc=(m,w)=>{if(!w.includes("<clay-kept"))return w;let k=m.ownerDocument.createElement("template");k.innerHTML=w;let P=Uo(m);return[...k.content.querySelectorAll("clay-kept")].forEach((Ft,he)=>{P[he]?Ft.replaceWith(P[he].cloneNode(!0)):Ft.remove()}),k.innerHTML},yc=m=>!m.matches?.(tt.selector)||Er(m)?void 0:Ho(m),gc=(m,w)=>{m.innerHTML=w},bc=m=>{let w=br();return w?w.morph:(vr().catch(()=>{}),m.querySelector('[editor-ui], [clay~="editor-ui"]')?void 0:gc)},qo=()=>window.clay?.undo?.pageHistory===!0&&window.clay.undo.recordingMode!=="commands",xr=new Map,zo=m=>{let w=window.clay?.undo;if(!(!qo()||Er(m))&&(xr.set(m,w.trackContent(m,{read:fc,write:(k,P)=>{tt.setSavedContent(k,mc(k,P),{morph:bc(k)})}})),!br()&&m.querySelector('[editor-ui], [clay~="editor-ui"]')&&typeof w.hold=="function")){let k=w.hold();vr().catch(()=>{}).finally(k)}},vc=()=>{for(let m of xr.values())m();xr.clear()};document.addEventListener("richclay:mount",m=>zo(m.target));var Bo=null,Tr=()=>{let m=window.clay?.undo;m?.addDurableForm&&Bo!==m&&(m.addDurableForm(yc),Bo=m),tt.hostHistory=qo(),tt.keepsOwnHistory=Er,tt.hostHistory?document.querySelectorAll("[data-richclay-active]").forEach(zo):vc()};document.addEventListener("clay:undo-session",Tr);document.addEventListener("clay:undo-recording",Tr);document.addEventListener("clay:ready",Tr);document.addEventListener("richclay:history-exhausted",m=>{let w=window.clay?.undo;!w||window.clay.modeLifecycle?.canWrite?.()===!1||(m.detail?.direction==="redo"?w.redo():w.undo())});var ei=null,Fo=(m,w)=>Object.assign(new Error(`clay:richclay: ${m}`),{code:w}),wc=m=>m?m.signal?.aborted?!0:typeof m.isCurrent=="function"&&!m.isCurrent():!1,xc=m=>({root:m,win:m.ownerDocument?.defaultView||window,admitted:!1,stopWatch:null,subscriber:null}),Wo=m=>[...m.root.querySelectorAll(tt.selector)];function Po(m){for(let w of tt.init(Wo(m)))w.reattach()}function Ec(m){let w=()=>Po(m);return{enable(){if(m.admitted)return;m.admitted=!0,Po(m),m.stopWatch=tt.watch(m.win);let k=m.root.ownerDocument||document;m.subscriber={target:k,type:"clay:sync-applied",handler:w},k.addEventListener(m.subscriber.type,w)},quiesce(){m.admitted=!1,m.stopWatch&&(m.stopWatch(),m.stopWatch=null)},resume(){m.admitted||(m.admitted=!0,m.stopWatch=tt.watch(m.win))},dispose(){m.admitted=!1,m.stopWatch&&(m.stopWatch(),m.stopWatch=null);let k=m.subscriber;m.subscriber=null,k&&k.target.removeEventListener(k.type,k.handler);for(let P of Wo(m))tt.stripElement(P);ei===m&&(ei=null)}}}function Tc(m=document){return{id:"clay:richclay",order:310,async prepare(w={}){if(w.initial===!0)return Cc();if(typeof tt.watch!="function"||typeof tt.stripElement!="function")throw Fo("this vendor build has no watchable lifecycle","unsupported-plugin");if(wc(w))throw Fo("prepared for a stale generation","stale-document");let k=tt.autoInit?.();return typeof k=="function"&&k(),Ec(ei||(ei=xc(m)))}}}async function Cc(){let m=await kc;return{enable(){},quiesce:()=>m?.quiesce(),resume:()=>m?.resume(),dispose:()=>m?.dispose()}}async function Sc(){if(!Do())return null;let m=await Tc().prepare();return m.enable(),m}var kc=Sc();var Kc=tt;export{tt as RichClay,Kc as default,Sc as init,Tc as modeParticipant,kc as ready,Tc as richclayParticipant};
549
- /*! For license information please see richclay-MXH2GFAZ.js.LEGAL.txt */
549
+ /*! For license information please see richclay-XL64ZGOZ.js.LEGAL.txt */
@@ -1 +1 @@
1
- import{a as x,d as I,e as g,f as P,g as M}from"../c-7DJDKPGL.js";import{a as $}from"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import{f as R,k as F}from"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import{k as N}from"../c-UW6MMZ4V.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import{e as k}from"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var T=k("history"),W="[cms-template]",L=["draggable","style"],X=["pointerup","pointercancel","dragend","drop"],y=new Set,h=null,E=null,m=null;function q(e,t,n,r,i){let o={target:t,type:n,handler:r,options:i};return t.addEventListener(n,r,i),e.listeners.push(o),o}function H(e,t){t.target.removeEventListener(t.type,t.handler,t.options);let n=e.listeners.indexOf(t);n!==-1&&e.listeners.splice(n,1)}function U(e,t){let n=setTimeout(()=>{e.timers.delete(n),t()},0);return e.timers.add(n),n}function Y(e,t){return{Sortable:e,root:t,admitted:!1,instances:new Set,listeners:[],timers:new Set,presses:new Set,stop:null}}var Z={admitted:!0,instances:new Set,listeners:[],timers:new Set,presses:new Set};function C(e){return[e,...e.querySelectorAll("*")].filter(t=>!t.closest(T)).map(t=>[t,L.map(n=>t.getAttribute(n))])}function _(e){for(let[t,n]of e)L.forEach((r,i)=>{let o=n[i],u=t.getAttribute(r);if(u!==o)if(o===null){if(r==="style"&&u)return;t.removeAttribute(r)}else t.setAttribute(r,o)})}function B(e){return/^(UL|OL)$/.test(e.tagName)?"li":"*"}function ee(e){return`> ${B(e)}:not(${T})`}function V(e,t){return!e||!t||t.nodeType!==1||!t.matches(B(e))?!1:!t.closest(T)&&!t.closest(W)}function D(e,t){return!e||!t||t.parentElement!==e?!1:V(e,t)}function te(e,t){let n=t.nextElementSibling;for(;n&&!D(e,n);)n=n.nextElementSibling;return n}function j(e,t){return Array.prototype.indexOf.call(e.children,t)}function G(e,t){if(t)try{new Function(`return (async function(evt) { ${t} })`)().call(e.from,e)}catch(n){console.error("Error in onsorted execution:",n)}e.from.dispatchEvent(new CustomEvent("clay:sorted",{bubbles:!0,detail:{item:e.item,from:e.from,to:e.to,oldIndex:e.oldIndex,newIndex:e.newIndex}})),e.from.dispatchEvent(new Event("input",{bubbles:!0}))}function z(e,t,n=Z){let r={};if(r.draggable=ee(e),r.setData=s=>{s.clearData(),s.setData("application/x-clay-sortable","")},t.get(e))return;let i=e.getAttribute("sortable");i&&(r.group=i);let o=e.querySelectorAll("[sortable-handle]"),u=e.querySelectorAll("[sortable]");Array.from(o).some(s=>!Array.from(u).some(l=>l.contains(s)))&&(r.handle="[sortable-handle]");let c=e.getAttribute("onsorting");if(c){let s=null;try{s=/\bawait\b/.test(c)?new Function(`return (async function(evt) { ${c} })`)():new Function("evt",c)}catch(l){console.error("Error in onsorting compilation:",l)}s&&(r.onMove=function(l){if(n.admitted)try{let a=s.call(e,l);return a instanceof Promise?void 0:a}catch(a){console.error("Error in onsorting execution:",a)}})}let d=e.getAttribute("onsorted");r.onEnd=function(s){if(!n.admitted)return;let l={item:s.item,from:s.from,to:s.to,oldIndex:s.oldIndex,newIndex:s.newIndex},a=f;f=null,b&&(_(b),b=null),a&&(M(a,l),g(a)),G(l,d)};let p=null,f=null,b=null,S=!1,A=!1,v=[],K=()=>{let s=f;f=null,b=null,g(s)},O=()=>{let s=p;p=null,s&&(n.presses.delete(s),y.delete(s),b=s),v.forEach(l=>H(n,l)),v=[],s&&U(n,()=>_(s))},Q=s=>{A&&s?.type==="pointercancel"||(A=!1,S?I(f):(g(f),f=null),S=!1,O(),U(n,K))};q(n,e,"pointerdown",s=>{let l=s.target instanceof Element?s.target:null;for(;l&&l.parentElement!==e;)l=l.parentElement;!l||p||(p=C(l),f=x(l),S=!1,A=!1,n.presses.add(p),y.add(p),v=X.map(a=>q(n,document,a,Q,!0)),v.push(q(n,document,"dragstart",()=>{A=!0},!0)))},!0),r.onUnchoose=O,r.onStart=()=>{S=!0},t.create(e,r),n.instances.add(e)}function ne(e,t,n=null){let r=d=>({ok:!1,code:d});if(!R||m&&!m.admitted)return r("not-editable");let i=document;if(!e||e.nodeType!==1||!e.isConnected||e.ownerDocument!==i)return r("detached");let o=e.parentElement;if(!o||!o.isConnected||!t||t.nodeType!==1||!t.isConnected||t.ownerDocument!==i)return r("detached");if(!o.hasAttribute("sortable")||!D(o,e)||!t.hasAttribute("sortable")||!V(t,e)||e===t||e.contains(t))return r("item");if(o!==t){let d=o.getAttribute("sortable");if(!d||d!==t.getAttribute("sortable"))return r("group")}if(n===e)return{ok:!0,moved:!1};if(n!==null&&!D(t,n))return r("anchor");if(o===t&&te(o,e)===n)return{ok:!0,moved:!1};let u=j(o,e),w=x(e);I(w);let c;try{t.insertBefore(e,n),c={item:e,from:o,to:t,oldIndex:u,newIndex:j(t,e)},M(w,c)}finally{g(w)}return G(c,o.getAttribute("onsorted")),{ok:!0,moved:!0,...c}}function re(){return h||(h=import("../vendor/Sortable.vendor-A755ITLN.js").then(e=>window.Sortable||e.default),h.catch(()=>{h=null})),h}function se(){return E||(N((e,{original:t})=>{for(let r of e.querySelectorAll("[sortable] .sortable-chosen, [sortable] .sortable-ghost, [sortable] .sortable-drag"))r.classList.remove("sortable-chosen","sortable-ghost","sortable-drag"),r.classList.length||r.removeAttribute("class");if(!y.size)return;let n=new Map;for(let r of y)for(let[i,o]of r)n.set(i,o);for(let r of e.querySelectorAll("[sortable] *")){let i=n.get(t(r));i&&L.forEach((o,u)=>{i[u]===null?r.removeAttribute(o):r.setAttribute(o,i[u])})}}),E=!0,E)}function oe(e){return{enable(){if(!e.admitted){e.admitted=!0;for(let t of e.root.querySelectorAll("[sortable]"))z(t,e.Sortable,e);e.stop=$.onAddElement({selectorFilter:"[sortable]",debounce:200,require:"observed",pausable:!1},t=>{e.admitted&&t.forEach(({element:n})=>{z(n,e.Sortable,e)})})}},quiesce(){e.admitted=!1},resume(){e.admitted=!0},dispose(){e.admitted=!1,e.stop&&(e.stop(),e.stop=null);for(let t of[...e.listeners])H(e,t);for(let t of e.timers)clearTimeout(t);e.timers.clear();for(let t of e.presses)y.delete(t);e.presses.clear(),P();for(let t of e.instances)e.Sortable?.get?.(t)?.destroy?.();e.instances.clear(),m===e&&(m=null)}}}var le=e=>e?e.signal?.aborted?!0:typeof e.isCurrent=="function"&&!e.isCurrent():!1;function ie(e=document){return{id:"clay:sortable",order:300,async prepare(t={}){if(t.initial===!0)return ae();let n=await re();if(le(t))throw Object.assign(new Error("clay:sortable prepared for a stale generation"),{code:"stale-document"});return se(),oe(m||(m=Y(n,e)))}}}async function ae(){let e=await ue;return{enable(){},quiesce:()=>e?.quiesce(),resume:()=>e?.resume(),dispose:()=>e?.dispose()}}async function J(){if(!F())return null;let e=await ie().prepare();return e.enable(),e}var ue=J(),be=Object.freeze({move:ne});var ge=J;export{ge as default,J as init,z as makeSortable,ie as modeParticipant,ne as move,ue as ready,be as sortable,ie as sortableParticipant};
1
+ import{a as x,d as I,e as g,f as P,g as M}from"../c-7DJDKPGL.js";import{a as $}from"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import{f as R,k as F}from"../c-JEWSJHMK.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import{k as N}from"../c-UW6MMZ4V.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import{e as k}from"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var T=k("history"),W="[cms-template]",L=["draggable","style"],X=["pointerup","pointercancel","dragend","drop"],y=new Set,h=null,E=null,m=null;function q(e,t,n,r,i){let o={target:t,type:n,handler:r,options:i};return t.addEventListener(n,r,i),e.listeners.push(o),o}function H(e,t){t.target.removeEventListener(t.type,t.handler,t.options);let n=e.listeners.indexOf(t);n!==-1&&e.listeners.splice(n,1)}function U(e,t){let n=setTimeout(()=>{e.timers.delete(n),t()},0);return e.timers.add(n),n}function Y(e,t){return{Sortable:e,root:t,admitted:!1,instances:new Set,listeners:[],timers:new Set,presses:new Set,stop:null}}var Z={admitted:!0,instances:new Set,listeners:[],timers:new Set,presses:new Set};function C(e){return[e,...e.querySelectorAll("*")].filter(t=>!t.closest(T)).map(t=>[t,L.map(n=>t.getAttribute(n))])}function _(e){for(let[t,n]of e)L.forEach((r,i)=>{let o=n[i],u=t.getAttribute(r);if(u!==o)if(o===null){if(r==="style"&&u)return;t.removeAttribute(r)}else t.setAttribute(r,o)})}function B(e){return/^(UL|OL)$/.test(e.tagName)?"li":"*"}function ee(e){return`> ${B(e)}:not(${T})`}function V(e,t){return!e||!t||t.nodeType!==1||!t.matches(B(e))?!1:!t.closest(T)&&!t.closest(W)}function D(e,t){return!e||!t||t.parentElement!==e?!1:V(e,t)}function te(e,t){let n=t.nextElementSibling;for(;n&&!D(e,n);)n=n.nextElementSibling;return n}function j(e,t){return Array.prototype.indexOf.call(e.children,t)}function G(e,t){if(t)try{new Function(`return (async function(evt) { ${t} })`)().call(e.from,e)}catch(n){console.error("Error in onsorted execution:",n)}e.from.dispatchEvent(new CustomEvent("clay:sorted",{bubbles:!0,detail:{item:e.item,from:e.from,to:e.to,oldIndex:e.oldIndex,newIndex:e.newIndex}})),e.from.dispatchEvent(new Event("input",{bubbles:!0}))}function z(e,t,n=Z){let r={};if(r.draggable=ee(e),r.setData=s=>{s.clearData(),s.setData("application/x-clay-sortable","")},t.get(e))return;let i=e.getAttribute("sortable");i&&(r.group=i);let o=e.querySelectorAll("[sortable-handle]"),u=e.querySelectorAll("[sortable]");Array.from(o).some(s=>!Array.from(u).some(l=>l.contains(s)))&&(r.handle="[sortable-handle]");let c=e.getAttribute("onsorting");if(c){let s=null;try{s=/\bawait\b/.test(c)?new Function(`return (async function(evt) { ${c} })`)():new Function("evt",c)}catch(l){console.error("Error in onsorting compilation:",l)}s&&(r.onMove=function(l){if(n.admitted)try{let a=s.call(e,l);return a instanceof Promise?void 0:a}catch(a){console.error("Error in onsorting execution:",a)}})}let d=e.getAttribute("onsorted");r.onEnd=function(s){if(!n.admitted)return;let l={item:s.item,from:s.from,to:s.to,oldIndex:s.oldIndex,newIndex:s.newIndex},a=f;f=null,b&&(_(b),b=null),a&&(M(a,l),g(a)),G(l,d)};let p=null,f=null,b=null,S=!1,A=!1,v=[],K=()=>{let s=f;f=null,b=null,g(s)},O=()=>{let s=p;p=null,s&&(n.presses.delete(s),y.delete(s),b=s),v.forEach(l=>H(n,l)),v=[],s&&U(n,()=>_(s))},Q=s=>{A&&s?.type==="pointercancel"||(A=!1,S?I(f):(g(f),f=null),S=!1,O(),U(n,K))};q(n,e,"pointerdown",s=>{let l=s.target instanceof Element?s.target:null;for(;l&&l.parentElement!==e;)l=l.parentElement;!l||p||(p=C(l),f=x(l),S=!1,A=!1,n.presses.add(p),y.add(p),v=X.map(a=>q(n,document,a,Q,!0)),v.push(q(n,document,"dragstart",()=>{A=!0},!0)))},!0),r.onUnchoose=O,r.onStart=()=>{S=!0},t.create(e,r),n.instances.add(e)}function ne(e,t,n=null){let r=d=>({ok:!1,code:d});if(!R||m&&!m.admitted)return r("not-editable");let i=document;if(!e||e.nodeType!==1||!e.isConnected||e.ownerDocument!==i)return r("detached");let o=e.parentElement;if(!o||!o.isConnected||!t||t.nodeType!==1||!t.isConnected||t.ownerDocument!==i)return r("detached");if(!o.hasAttribute("sortable")||!D(o,e)||!t.hasAttribute("sortable")||!V(t,e)||e===t||e.contains(t))return r("item");if(o!==t){let d=o.getAttribute("sortable");if(!d||d!==t.getAttribute("sortable"))return r("group")}if(n===e)return{ok:!0,moved:!1};if(n!==null&&!D(t,n))return r("anchor");if(o===t&&te(o,e)===n)return{ok:!0,moved:!1};let u=j(o,e),w=x(e);I(w);let c;try{t.insertBefore(e,n),c={item:e,from:o,to:t,oldIndex:u,newIndex:j(t,e)},M(w,c)}finally{g(w)}return G(c,o.getAttribute("onsorted")),{ok:!0,moved:!0,...c}}function re(){return h||(h=import("../vendor/Sortable.vendor-A755ITLN.js").then(e=>window.Sortable||e.default),h.catch(()=>{h=null})),h}function se(){return E||(N((e,{original:t})=>{for(let r of e.querySelectorAll("[sortable] .sortable-chosen, [sortable] .sortable-ghost, [sortable] .sortable-drag"))r.classList.remove("sortable-chosen","sortable-ghost","sortable-drag"),r.classList.length||r.removeAttribute("class");if(!y.size)return;let n=new Map;for(let r of y)for(let[i,o]of r)n.set(i,o);for(let r of e.querySelectorAll("[sortable] *")){let i=n.get(t(r));i&&L.forEach((o,u)=>{i[u]===null?r.removeAttribute(o):r.setAttribute(o,i[u])})}}),E=!0,E)}function oe(e){return{enable(){if(!e.admitted){e.admitted=!0;for(let t of e.root.querySelectorAll("[sortable]"))z(t,e.Sortable,e);e.stop=$.onAddElement({selectorFilter:"[sortable]",debounce:200,require:"observed",pausable:!1},t=>{e.admitted&&t.forEach(({element:n})=>{z(n,e.Sortable,e)})})}},quiesce(){e.admitted=!1},resume(){e.admitted=!0},dispose(){e.admitted=!1,e.stop&&(e.stop(),e.stop=null);for(let t of[...e.listeners])H(e,t);for(let t of e.timers)clearTimeout(t);e.timers.clear();for(let t of e.presses)y.delete(t);e.presses.clear(),P();for(let t of e.instances)e.Sortable?.get?.(t)?.destroy?.();e.instances.clear(),m===e&&(m=null)}}}var le=e=>e?e.signal?.aborted?!0:typeof e.isCurrent=="function"&&!e.isCurrent():!1;function ie(e=document){return{id:"clay:sortable",order:300,async prepare(t={}){if(t.initial===!0)return ae();let n=await re();if(le(t))throw Object.assign(new Error("clay:sortable prepared for a stale generation"),{code:"stale-document"});return se(),oe(m||(m=Y(n,e)))}}}async function ae(){let e=await ue;return{enable(){},quiesce:()=>e?.quiesce(),resume:()=>e?.resume(),dispose:()=>e?.dispose()}}async function J(){if(!F())return null;let e=await ie().prepare();return e.enable(),e}var ue=J(),be=Object.freeze({move:ne});var ge=J;export{ge as default,J as init,z as makeSortable,ie as modeParticipant,ne as move,ue as ready,be as sortable,ie as sortableParticipant};
@@ -1 +1 @@
1
- import"../c-EHAR4RJJ.js";import{a as d}from"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-KU3PX7LL.js";import"../c-EQ5NBOGA.js";import"../c-IJUK2GPW.js";import{k as p}from"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import"../c-UW6MMZ4V.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var g={installed:!1,refused:null,sourceBytes:null,paired:0,unresolved:0,unmatchedLive:0,unmatchedSource:0,attrDiffs:0,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastRenderMs:null,lastBytes:null,refreshes:0,timing:{fetch:null,model:null,pair:null,refresh:null}},n=null,c=null,i=null,u=p(),s=0,r=null,a=!1,o=null;function v(){return o??=import("../c-H4M2T4A6.js").catch(e=>{throw o=null,e}),o}function f(e,t,l){typeof e=="string"&&(i=Object.freeze({bytes:e,etag:t??null,seq:l??null}))}function h(){if(r)return r;let e=s,t=c;return r=v().then(l=>(n=l,e!==s?(r=null,null):l.start({context:t,latest:()=>i}))).catch(l=>(r=null,console.info("clayjs: source map off ("+(l&&l.message?l.message:l)+"); saves use the full serialization"),null)).then(l=>(e===s&&(a=!0),l)),r}function x(){return!u||a?null:h()}function m(){s++,u=!1,a=!1,r=null,c=null,n&&n.release()}d((e,t)=>{f(e,i?i.etag:null,i?i.seq:null),n&&!n.installed()&&n.adoptAccepted(e,t)});document.addEventListener("clay:sync-applied",e=>{let t=e&&e.detail;!t||t.source!=="disk"||typeof t.html!="string"||(f(t.html,t.etag,t.seq),n&&!n.installed()&&n.adoptAccepted(t.html,null))});function y(e,t,l={}){return n?n.renderSave(e,t,l):t}var A={get ready(){return u?h():null},stats:()=>n?n.stats():{...g},text:()=>n?n.text():null,locate:e=>n?n.locateLive(e):null,unpaired:()=>n?n.unpaired():null,ensureForSave:x,get repairGeneration(){return n?n.repairGeneration():0}};function L(){return{id:"clay:source",order:30,prepare(e={}){let t=e&&e.represented;if(t&&(c={represented:t},f(t.bytes,t.etag,t.seq)),e&&e.initial===!0)return u=!0,{enable(){},quiesce(){},resume(){},dispose:m};let l=++s;return u=!1,a=!1,r=null,{enable(){l===s&&(u=!0)},quiesce(){},resume(){l===s&&(u=!0)},dispose(){l===s&&m()}}}}}var R=A;export{R as default,L as modeParticipant,y as renderSave,A as source,L as sourceParticipant};
1
+ import"../c-CKG4NF7J.js";import{a as d}from"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-OSGTRM4C.js";import"../c-26W3BMWK.js";import"../c-IJUK2GPW.js";import{k as p}from"../c-JEWSJHMK.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import"../c-UW6MMZ4V.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var g={installed:!1,refused:null,sourceBytes:null,paired:0,unresolved:0,unmatchedLive:0,unmatchedSource:0,attrDiffs:0,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastRenderMs:null,lastBytes:null,refreshes:0,timing:{fetch:null,model:null,pair:null,refresh:null}},n=null,c=null,i=null,u=p(),s=0,r=null,a=!1,o=null;function v(){return o??=import("../c-OEEJRV2M.js").catch(e=>{throw o=null,e}),o}function f(e,t,l){typeof e=="string"&&(i=Object.freeze({bytes:e,etag:t??null,seq:l??null}))}function h(){if(r)return r;let e=s,t=c;return r=v().then(l=>(n=l,e!==s?(r=null,null):l.start({context:t,latest:()=>i}))).catch(l=>(r=null,console.info("clayjs: source map off ("+(l&&l.message?l.message:l)+"); saves use the full serialization"),null)).then(l=>(e===s&&(a=!0),l)),r}function x(){return!u||a?null:h()}function m(){s++,u=!1,a=!1,r=null,c=null,n&&n.release()}d((e,t)=>{f(e,i?i.etag:null,i?i.seq:null),n&&!n.installed()&&n.adoptAccepted(e,t)});document.addEventListener("clay:sync-applied",e=>{let t=e&&e.detail;!t||t.source!=="disk"||typeof t.html!="string"||(f(t.html,t.etag,t.seq),n&&!n.installed()&&n.adoptAccepted(t.html,null))});function y(e,t,l={}){return n?n.renderSave(e,t,l):t}var A={get ready(){return u?h():null},stats:()=>n?n.stats():{...g},text:()=>n?n.text():null,locate:e=>n?n.locateLive(e):null,unpaired:()=>n?n.unpaired():null,ensureForSave:x,get repairGeneration(){return n?n.repairGeneration():0}};function L(){return{id:"clay:source",order:30,prepare(e={}){let t=e&&e.represented;if(t&&(c={represented:t},f(t.bytes,t.etag,t.seq)),e&&e.initial===!0)return u=!0,{enable(){},quiesce(){},resume(){},dispose:m};let l=++s;return u=!1,a=!1,r=null,{enable(){l===s&&(u=!0)},quiesce(){},resume(){l===s&&(u=!0)},dispose(){l===s&&m()}}}}}var R=A;export{R as default,L as modeParticipant,y as renderSave,A as source,L as sourceParticipant};
@@ -1 +1 @@
1
- import{b as xt,c as Nt}from"../c-7DJDKPGL.js";import{g as ke}from"../c-P73XPAOA.js";import{a as ve}from"../c-WYFDLITL.js";import"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import{k as Ct}from"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import{a as Vt}from"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import{l as St}from"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var Pt=(()=>{var l=Object.defineProperty,f=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,A=Object.prototype.hasOwnProperty,x=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},j=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of m(n))!A.call(e,a)&&a!==t&&l(e,a,{get:()=>n[a],enumerable:!(o=f(n,a))||o.enumerable});return e},O=e=>j(l({},"__esModule",{value:!0}),e),q={};x(q,{default:()=>$n,endsSentence:()=>Qe,undo:()=>Pe});function pe(e,n=null){let t=[];if(e.type==="attributes"){let o=e.target,a=e.attributeName,i=e.oldValue,d=o.getAttribute(a);return i==null&&d!=null?t.push({kind:"attr-add",target:o,name:a,newValue:d}):i!=null&&d==null?t.push({kind:"attr-remove",target:o,name:a,oldValue:i}):i!==d&&t.push({kind:"attr-set",target:o,name:a,oldValue:i,newValue:d}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let o=e.target,a=e.nextSibling,i=e.nextSibling;for(;i&&n?.(i);)i=i.nextSibling;let d=e.previousSibling;for(;d&&n?.(d);)d=d.previousSibling;let c=n?Array.from(e.addedNodes).filter(v=>!n(v)):Array.from(e.addedNodes),g=n?Array.from(e.removedNodes).filter(v=>!n(v)):Array.from(e.removedNodes);return c.length>0&&t.push({kind:"add",parent:o,nodes:c,before:a,afterAuthored:i,beforeAuthored:d,record:e}),g.length>0&&t.push({kind:"remove",parent:o,nodes:g,before:a,afterAuthored:i,beforeAuthored:d,record:e}),t}return t}function Ut(e,n=null){let t=[],o=new Map;for(let a of e){if(a.type==="attributes"){let i=a.target,d=a.attributeName,c=o.get(i);c||(c=new Map,o.set(i,c)),c.has(d)||(c.set(d,{idx:t.length,oldValue:a.oldValue}),t.push(null));continue}for(let i of pe(a,n))t.push(i)}for(let[a,i]of o)for(let[d,c]of i){let g=c.oldValue,v=a.getAttribute(d),b=null;g===v?b=null:g==null?b={kind:"attr-add",target:a,name:d,newValue:v}:v==null?b={kind:"attr-remove",target:a,name:d,oldValue:g}:b={kind:"attr-set",target:a,name:d,oldValue:g,newValue:v},t[c.idx]=b}return t.filter(a=>a!=null)}function _t(e,{sameContent:n=(t,o)=>t===o}={}){let t=[],o=new Map;for(let i of e){let d=Fe(i);if(d==null){t.push(i);continue}let c=o.get(i.target);c||(c=new Map,o.set(i.target,c));let g=c.get(d);if(g==null){let v=Ue(i);if(v.oldValue===v.newValue)continue;c.set(d,t.length),t.push({...i,...v})}else t[g]={...t[g],newValue:Ue(i).newValue}}let a=[];for(let i of t){if(Fe(i)==null){a.push(i);continue}i.oldValue!==i.newValue&&(i.kind==="value"&&i.content===!0&&n(i.oldValue,i.newValue)||a.push(Ht(i)))}return a}var Wt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function Fe(e){return Wt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ue(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function Ht(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var _e=new WeakMap,Jt=0;function $(e){let n=_e.get(e);return n||(n=`n${++Jt}`,_e.set(e,n)),n}function R(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function Yt(e){return e.kind==="add"||e.kind==="remove"}function We(e,n){let t=[],o=e.childNodes;if(!o)return t;for(let a of o)n&&n(a)||t.push($(a));return t}function He(e,n,t){if(typeof n!="function"||!R(e)||e.nodeType!==1)return null;let o=null;try{o=n(e,t)}catch{o=null}return typeof o=="string"?`#form:${JSON.stringify(o)}`:null}function le(e,n,t=null,o=null,a=null,i=null){if(!R(e))return null;let d=He(e,a,t);if(d!=null)return d;if(e.nodeType===3)return`#text:${JSON.stringify(i&&i.has(e)?i.get(e):e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let c=[];if(e.attributes){for(let v of e.attributes)Gt(v.name,e,n,t)||c.push(`${v.name}=${JSON.stringify(v.value)}`);c.sort()}let g=[];if(e.childNodes)for(let v of e.childNodes){let b=He(v,a,t);if(b!=null){g.push(b);continue}Xt(v,o)||g.push(le(v,n,t,o,a,i))}return`<${String(e.tagName||"").toLowerCase()}${c.length?` ${c.join(" ")}`:""}>${g.join("")}</>`}function Ae(e,n=[]){if(!R(e))return n;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&n.push(t)}if(e.childNodes)for(let t of e.childNodes)Ae(t,n);return n}function Gt(e,n,t,o=null){if(typeof t!="function")return!1;try{return!!t(e,n,o)}catch{return!1}}function Xt(e,n){if(typeof n!="function")return!1;try{return!!n(e)}catch{return!1}}function Je(e,n){if(typeof n!="function")return[];let t=[],o=a=>{if(!R(a))return;let i=!1;try{i=!!n(a)}catch{i=!1}if(i&&t.push(D(a,"protected")),a.childNodes)for(let d of a.childNodes)o(d)};for(let a of e)o(a);return t}function D(e,n,t=null){let o=e;o&&o.nodeType!==1&&(o=o.parentElement);let a=o&&typeof o.closest=="function"?o.closest("[data-id]"):null;return!a&&t&&typeof t.closest=="function"&&(a=t.closest("[data-id]")),{id:(a?a.getAttribute("data-id"):null)||null,kind:n||null}}function Zt(e,n,t=null){return(e||[]).filter(R).map(o=>D(o,n,t))}function de(e){return{replayable:!1,reason:e,steps:[]}}function ge(e,n){let t=[[n.afterAuthored,a=>a],[n.beforeAuthored,a=>a+1],[n.before,a=>a]],o=!1;for(let[a,i]of t){if(!R(a))continue;o=!0;let d=e.indexOf($(a));if(d>=0)return i(d)}return o?null:e.length}function Qt(e,n={}){let t=n.isIgnored||null,o=n.ignoreAttribute||null,a=n.durableForm||null,i=_t(e,{sameContent:Ee}),d=[];for(let E of i){if(!Yt(E)){if(!R(E.target))return de("non-dom-target");continue}if(!R(E.parent))return de("non-dom-parent");let C=Array.from(E.nodes||[]).filter(R);if(C.length!==0){if(C.length!==Array.from(E.nodes||[]).length)return de("non-dom-node");d.push({primitive:E,nodes:C,parent:E.parent})}}if(en(d))return de("in-record-move");let c=tn(d,t);if(!c)return de("ambiguous-structure");let g=nn(d,c),v=new Map(d.map(E=>[E.primitive,E])),b=[];for(let E of i){let C=v.get(E);if(!C){b.push(on(E));continue}let N=g.get(C);if(N){N.at===C&&b.push(N.step);continue}b.push(rn(C,c.get(C),o,t,a))}return{replayable:!0,reason:null,steps:b}}function en(e){let n=new Map;for(let t of e){let o=t.primitive.record;if(!o)continue;let a=n.get(o);a||(a=new Map,n.set(o,a));for(let i of t.nodes){let d=a.get(i);d||(d=new Set,a.set(i,d)),d.add(t.primitive.kind)}}for(let t of n.values())for(let o of t.values())if(o.size>1)return!0;return!1}function tn(e,n){let t=new Map;for(let a of e)t.has(a.parent)||t.set(a.parent,We(a.parent,n));let o=new Map;for(let a=e.length-1;a>=0;a--){let i=e[a],d=t.get(i.parent);if(!d)return null;let c=d.slice(),g;if(i.primitive.kind==="add"){let v=i.nodes.map($);if(!v.every(b=>d.includes(b)))return null;g=d.filter(b=>!v.includes(b))}else{let v=ge(c,i.primitive);if(v==null)return null;g=c.slice(),g.splice(v,0,...i.nodes.map($))}o.set(i,{before:g,after:c}),t.set(i.parent,g)}return o}function nn(e,n){let t=new Map,o=new Map;e.forEach((i,d)=>{for(let c of i.nodes){let g=$(c);i.primitive.kind==="remove"?t.set(g,{item:i,index:d,node:c}):o.set(g,{item:i,index:d,node:c})}});let a=new Map;for(let[i,d]of t){let c=o.get(i);if(!c||c.index<d.index||d.item.nodes.length!==1||c.item.nodes.length!==1)continue;let g={type:"move",node:d.node,sourceParent:d.item.parent,destParent:c.item.parent,source:n.get(d.item),dest:n.get(c.item),sourceSlot:d.item.primitive,destSlot:c.item.primitive,targets:[D(d.node,"move")]};a.set(d.item,{step:g,at:c.item}),a.set(c.item,{step:g,at:c.item})}return a}function rn(e,n,t,o,a=null){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:n.before,seqAfter:n.after,slot:e.primitive,content:e.nodes.map(d=>le(d,t,e.parent,o,a)),ids:i==="remove"?e.nodes.flatMap(d=>Ae(d)):[],targets:Zt(e.nodes,i==="add"?"added":"removed",e.parent)}}function on(e){return{type:e.kind,primitive:e,targets:[D(e.target,e.name||e.prop||"text")]}}function an(e,n,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let o={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,durableForm:t.durableForm||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,texts:new Map,operations:[]};for(let a=0;a<e.steps.length;a++){let i=e.steps[n==="undo"?e.steps.length-1-a:a],d=ln(i,n,o);if(d)return{ok:!1,code:d.code,targets:d.targets}}return{ok:!0,operations:o.operations}}function Q(e,n){return e.sim.has(n)||e.sim.set(n,We(n,e.isIgnored)),e.sim.get(n)}function ee(e,n){for(let t=e;t;t=t.parentNode)if(n.planned.has(t))return n.planned.get(t);return n.inScope(e)}function Ye(e,n){return n.liveNodesWithIds(e).filter(t=>ee(t,n)).length>0}function S(e,n){return{code:e,targets:n||[]}}function Ee(e,n){return e===n?!0:typeof e!="string"||typeof n!="string"?!1:e.replace(/\u00A0|&nbsp;/g," ")===n.replace(/\u00A0|&nbsp;/g," ")}function un(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function ln(e,n,t){let o=n==="undo";return e.type==="move"?pn(e,o,t):e.type==="add"?sn(e,o,t):e.type==="restore"?cn(e,o,t):dn(e,o,t)}function dn(e,n,t){let o=e.primitive,a=n?o.newValue:o.oldValue,i=n?o.oldValue:o.newValue;if(!R(o.target))return S("unsupported",e.targets);if(!ee(o.target,t))return S("target-detached",e.targets);if(o.kind==="value"&&typeof o.write=="function"&&typeof o.read!="function")return S("unsupported",e.targets);let d=un(o);return(o.content===!0?!Ee(d,a):d!==a)?S("content-changed",e.targets):(o.kind==="value"?t.operations.push({type:"value",target:o.target,prop:o.prop||"value",value:i,read:o.read||null,write:o.write||null,content:o.content===!0}):o.kind==="text"?(t.operations.push({type:"text",target:o.target,data:i}),t.texts.set(o.target,i)):t.operations.push({type:"attr",target:o.target,name:o.name,value:i??null}),null)}function sn(e,n,t){if(!R(e.parent)||!ee(e.parent,t))return S("target-detached",e.targets);if(n){if(!te(Q(t,e.parent),e.seqAfter))return S("structure-changed",e.targets);let c=Je(e.nodes,t.isProtected);if(c.length>0)return S("protected",c);for(let g=0;g<e.nodes.length;g++)if(le(e.nodes[g],t.ignoreAttribute,e.parent,t.isIgnored,t.durableForm)!==e.content[g])return S("content-changed",e.targets);for(let g of e.nodes)t.operations.push({type:"remove",node:g}),t.planned.set(g,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!te(Q(t,e.parent),e.seqBefore))return S("structure-changed",e.targets);for(let c of e.nodes)if(c.parentNode)return S("structure-changed",e.targets);let o=e.nodes.flatMap(c=>Ae(c));if(o.length>0&&Ye(o,t))return S("duplicate-id",e.targets);let a=ge(e.seqBefore,e.slot);if(a==null)return S("unsupported",e.targets);let i=e.seqBefore.slice(),d=a;for(let c of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:c,beforeId:i[d]??null}),i=i.slice(0,d).concat($(c),i.slice(d)),d+=1,t.planned.set(c,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function cn(e,n,t){if(!R(e.parent)||!ee(e.parent,t))return S("target-detached",e.targets);if(n){if(!te(Q(t,e.parent),e.seqAfter))return S("structure-changed",e.targets);for(let g=0;g<e.nodes.length;g++){let v=e.nodes[g];if(v.parentNode||le(v,t.ignoreAttribute,e.parent,t.isIgnored,t.durableForm)!==e.content[g])return S("content-changed",e.targets)}if(e.ids.length>0&&Ye(e.ids,t))return S("duplicate-id",e.targets);let i=ge(e.seqAfter,e.slot);if(i==null)return S("unsupported",e.targets);let d=e.seqAfter.slice(),c=i;for(let g of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:g,beforeId:d[c]??null}),d=d.slice(0,c).concat($(g),d.slice(c)),c+=1,t.planned.set(g,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!te(Q(t,e.parent),e.seqBefore))return S("structure-changed",e.targets);let o=Je(e.nodes,t.isProtected);if(o.length>0)return S("protected",o);let a=i=>t.planned.get(i)===!0||typeof t.isIgnored=="function"&&t.isIgnored(i);for(let i=0;i<e.nodes.length;i++){let d=e.nodes[i];if(d.parentNode!==e.parent||le(d,t.ignoreAttribute,e.parent,a,t.durableForm,t.texts)!==e.content[i])return S("content-changed",e.targets)}for(let i of e.nodes)t.operations.push({type:"remove",node:i}),t.planned.set(i,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function fn(e,n){let t=e.indexOf(n);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function pn(e,n,t){let o=$(e.node),a=n?e.destParent:e.sourceParent,i=n?e.sourceParent:e.destParent,d=Q(t,a),c=Q(t,i),g=n?e.dest.after:e.source.before,v=n?e.source.after:e.dest.before,b=n?e.sourceSlot:e.destSlot;if(!R(a)||!R(i)||!ee(a,t)||!ee(i,t))return S("target-detached",e.targets);if(!te(d,g))return S("structure-changed",e.targets);let E=a===i?fn(c,o):c;if(!te(E,v))return S("structure-changed",e.targets);let C=ge(v,b);return C==null?S("unsupported",e.targets):(t.operations.push({type:"insert",parent:i,node:e.node,beforeId:v[C]??null}),t.planned.set(e.node,!0),n?(t.sim.set(i,e.source.before.slice()),a!==i&&t.sim.set(a,e.dest.before.slice())):(t.sim.set(i,e.dest.after.slice()),a!==i&&t.sim.set(a,e.source.after.slice())),null)}function te(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function gn(e,n){for(let t of e.childNodes||[])if($(t)===n)return t;return null}function Ge(e,n){let t=Math.min(e.length,n.length),o=0;for(;o<t&&e[o]===n[o];)o++;let a=0;for(;a<t-o&&e[e.length-1-a]===n[n.length-1-a];)a++;return n.length-a}function Xe(e,n){typeof e.write=="function"?e.write(e.target,n):e.target[e.prop]=n}function mn(e){let n=[];try{let t=null;for(let o of e)t=yn(o,n)||t;return{ok:!0,caret:t}}catch(t){for(let o=n.length-1;o>=0;o--)try{n[o]()}catch{}return{ok:!1,error:t}}}function yn(e,n){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),n.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;return e.target.data=e.data,n.push(()=>{e.target.data=t}),{node:e.target,offset:Ge(t,e.data)}}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop],o=e.content?e.target.textContent:null;if(Xe(e,e.value),n.push(()=>Xe(e,t)),!e.content)return;let a=e.target.textContent;return a===o?void 0:{root:e.target,textOffset:Ge(o,a)}}if(e.type==="insert"){let t=e.beforeId==null?null:gn(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let o=e.node.parentNode,a=e.node.nextSibling;return e.parent.insertBefore(e.node,t),n.push(()=>{o?o.insertBefore(e.node,a&&a.parentNode===o?a:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)}),e.node.nodeType!==3?void 0:{node:e.node,offset:e.node.data.length}}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let o=e.node.nextSibling,a=Array.prototype.indexOf.call(t.childNodes,e.node);return t.removeChild(e.node),n.push(()=>t.insertBefore(e.node,o)),e.node.nodeType!==3?void 0:{node:t,offset:a}}}var hn=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],bn=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],wn=hn.join(","),vn=new RegExp("^(?:"+bn.join("|")+")(?:-|$)"),Ir=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),kn=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),An=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function Se(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function Ze(e,n){if(Se(e,n))return!0;for(let[t,o]of Object.entries(kn))if(o.includes(n)&&Se(e,t))return!0;return!1}function En(e){return e==="clay"||An.includes(e)}var Sn=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function Cn(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function Ce(e){let n=Cn();if(n)try{if(!n(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(wn))return!0;for(;t&&t.nodeType===1;){if(Ze(t,"no-undo")||Ze(t,"no-watch"))return!0;for(let o of Sn)if(Se(t,o))return!0;t=t.parentElement}return!1}function Vn(e){let n=e.target,t=n.cloneNode(!1),o=t;for(;n.parentElement;){n=n.parentElement;let a=n.cloneNode(!1);a.appendChild(t),t=a}return e.oldValue==null?o.removeAttribute(e.attributeName):o.setAttribute(e.attributeName,e.oldValue),Ce(o)}function me(e,n,t){if(t?.type==="attributes"&&En(t.attributeName)){if(Ce(e)&&Vn(t))return!0}else if(Ce(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&vn.test(t.attributeName.toLowerCase()))return!0;if(n)try{if(n(t.attributeName,t.target))return!0}catch{}}return!1}function xn(){let e=new Map;function n(a,i){let d=e.get(a);return d||(d=new Set,e.set(a,d)),d.add(i),()=>t(a,i)}function t(a,i){let d=e.get(a);d&&d.delete(i)}function o(a,i){let d=e.get(a);if(d)for(let c of Array.from(d))try{c(i)}catch(g){console.error("[hyper-undo] listener threw",g)}}return{on:n,off:t,emit:o}}var Nn=/[.?!]["'\u201D\u2019)\]]*$/,Pn=new Set(["insertParagraph","insertLineBreak"]),Rn=new Set(["insertFromPaste","insertFromDrop","insertFromYank","insertReplacementText","deleteByCut","deleteByDrag"]),In=new Set(["Enter","Backspace","Delete"]),Tn=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Qe(e){return Nn.test(e)}function On(e,{sentence:n,endStep:t,stepOpen:o=()=>!0,composing:a}){let i=e.ownerDocument&&e.ownerDocument.defaultView;if(!i)return()=>{};let d=h=>!!h&&typeof h.nodeType=="number"&&(h===e||e.contains(h)),c=!1,g=!1,v=!1,b={kind:"other",host:null},E=h=>Rn.has(h)||h.startsWith("format")?"alone":h.startsWith("delete")?"delete":h.startsWith("insert")?"insert":"other",C=h=>{if(!h)return null;let T=h.nodeType===1?h:h.parentElement;return T&&T.closest&&T.closest('[contenteditable]:not([contenteditable="false"])')||h},N=()=>{c&&(c=!1,t())},I=h=>{if(!n||h.isComposing||!d(h.target))return;let T=h.inputType||"",z=E(T),se=C(h.target),ye=i.getSelection&&i.getSelection(),ce=!ye||ye.isCollapsed,Re=g;g=!1;let ne=v;if(v=!1,(z==="alone"||!ne&&z!==b.kind&&z!=="other"&&b.kind!=="other"||!ne&&(b.host!==null&&se!==b.host||!ce||Re))&&t(),b={kind:z,host:se},z==="alone"){c=!0,setTimeout(N,0);return}let re=T==="insertText"&&(h.data===" "||h.data==="\xA0");!re&&!Pn.has(T)||re&&!o()||Qe(Ln(i))&&(c=!0,setTimeout(N,0))},B=h=>{d(h.target)&&N()},L=h=>{d(h.target)&&a(!0)},W=h=>{d(h.target)&&a(!1)},H=h=>{d(h.target)&&(g=!0)},J=h=>{if(!d(h.target))return;if(Tn.has(h.key)){g=!0;return}if(!n||h.isComposing||h.keyCode===229||h.ctrlKey||h.metaKey||!h.key||h.key.length!==1&&!In.has(h.key))return;let T=i.getSelection&&i.getSelection(),z=b.host!==null&&C(h.target)!==b.host;!g&&!z&&(!T||T.isCollapsed)||(t(),g=!1,v=!0,setTimeout(()=>{v=!1},0))};return e.addEventListener("beforeinput",I,!0),e.addEventListener("input",B,!0),e.addEventListener("compositionstart",L,!0),e.addEventListener("compositionend",W,!0),e.addEventListener("pointerdown",H,!0),e.addEventListener("keydown",J,!0),()=>{e.removeEventListener("beforeinput",I,!0),e.removeEventListener("input",B,!0),e.removeEventListener("compositionstart",L,!0),e.removeEventListener("compositionend",W,!0),e.removeEventListener("pointerdown",H,!0),e.removeEventListener("keydown",J,!0)}}function Ln(e){let n=e.getSelection&&e.getSelection();if(!n||!n.isCollapsed||!n.anchorNode)return"";let t=n.anchorNode,o=t.nodeType===1?t:t.parentElement,a=o&&o.closest('[contenteditable]:not([contenteditable="false"])');if(!a)return"";let i=a.ownerDocument.createRange();return i.setStart(a,0),i.setEnd(t,n.anchorOffset),i.toString().replace(/\u200B/g,"").slice(-8)}var Mn={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,durableForm:null,typingBreak:null,refused:null,debug:!1};function et(e){let n={...Mn,...e};if(!n.scope)throw new Error("hyper-undo: scope is required");let t=xn(),o=[],a=[],i=`u${Math.random().toString(36).slice(2,8)}`,d=0,c=null,g=[],v=null,b=null,E=0,C=!1,N=n.recording==="commands"?"commands":"automatic",I=null,B=!1,L=new WeakMap,W=!1,H=!1,J=null;function h(...r){n.debug&&console.log("[hyper-undo]",...r)}function T(){C||(C=!0,b=z(Y),b.observe(n.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),J=On(n.scope,{sentence:n.typingBreak==="sentence",stepOpen:()=>(E===0&&b&&Y(b.takeRecords()),g.length>0),endStep:X,composing:Fn}),h("started"))}function z(r){let u=typeof document<"u"&&n.scope===document.body,s=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&s&&typeof s.createObserver=="function"?(h("sourcing records from the platform Mutation hub (shared observer)"),s.createObserver(r)):new MutationObserver(r)}function se(){C&&(C=!1,b&&(b.disconnect(),b=null),J&&(J(),J=null),W=!1,G(),o.length=0,a.length=0,g=[],c=null,I=null,B=!1,E=0,L=new WeakMap,h("stopped"))}function ye(){let r=n.scope;return!!(r&&r.nodeType===1&&r.isConnected===!1)}function ce(r,u){try{let s=u(r);return typeof s=="string"?s:null}catch{return null}}function Re(r,{read:u,write:s,prop:p="content"}={}){if(!r||typeof u!="function"||typeof s!="function")return()=>{};let k={prop:p,read:u,write:s,baseline:ce(r,u)};return L.set(r,k),()=>{L.get(r)===k&&L.delete(r)}}function ne(r){for(let u=r;u;u=u.parentNode)if(L.has(u))return u;return null}function re(r){let u=ne(r.target);return!!u&&!(r.type==="attributes"&&r.target===u)}function _(r){let u=new Set;for(let s of r)re(s)&&u.add(ne(s.target));return u}function Ie(r){let u=[];for(let s of r){let p=L.get(s),k=ce(s,p.read);if(k!=null){if(Ee(k,p.baseline)){p.baseline=k;continue}p.baseline!=null&&u.push({kind:"value",target:s,prop:p.prop,oldValue:p.baseline,newValue:k,read:p.read,write:p.write,content:!0}),p.baseline=k}}return u}function oe(r){for(let u of r){let s=L.get(u);s.baseline=ce(u,s.read)}}function ut(r){let u=_(r);!H&&g.some(s=>s.kind==="value"?u.has(s.target):r.some(p=>p.target===s.target&&(p.type==="characterData"?s.kind==="text":p.type==="attributes"&&p.attributeName===s.name)))&&(H=!0),oe(u)}function Y(r){lt(r,!1)}function lt(r,u){if(I){for(let p of r)I.records.push(p);return}if(N==="commands"){oe(_(r));return}if(E>0){ut(r);return}let s=Te(Bn(r),u);for(let p of Ie(_(r)))s.push(p);if(s.length>0){for(let p of s)g.push(p);Oe()}}function Bn(r){return typeof n.ignoreNode!="function"?r:r.filter(u=>{if(u.type!=="childList")return!0;let s=[...u.addedNodes,...u.removedNodes];return s.length===0?!0:!s.every(p=>zn(p))})}function zn(r){try{return!!n.ignoreNode(r)}catch{return!1}}function Te(r,u=!1){let s=ar(r),p=r.filter(k=>(De(k.target)||s(k.target)||u&&Et(k.target))&&!re(k)&&!me(k.target,n.ignoreAttribute,k));return Ut(p,k=>me(k,n.ignoreAttribute))}function Fn(r){W=!!r,!W&&g.length>0&&Oe()}function Oe(){G(),v=setTimeout(dt,n.idleWindowMs)}function dt(){if(v=null,W){v=setTimeout(dt,n.idleWindowMs);return}Le()}function G(){v!=null&&(clearTimeout(v),v=null)}function Le(){if(v=null,g.length===0)return;let r=g;g=[],he(n.idleLabel,r)}function he(r,u){let s=Qt(u,{isIgnored:be,ignoreAttribute:st,durableForm:n.durableForm});if(s.steps.length===0)return h("commit",r,"with nothing to record"),t.emit("commit"),null;let p={id:`${i}-${++d}`,label:r,timestamp:Date.now(),primitives:u,certificate:s};for(o.push(p),a.length=0,c=null;o.length>n.maxHistory;)o.shift();return h("commit",r,"primitives:",u.length),t.emit("commit"),p}function be(r){return me(r,n.ignoreAttribute)}function st(r,u,s=null){if(typeof n.ignoreAttribute!="function")return!1;try{return!!n.ignoreAttribute(r,u,s)}catch{return!1}}function Un(r){if(typeof n.isProtected!="function")return!1;try{return!!n.isProtected(r)}catch{return!1}}function _n(r,u){if(!C)throw new Error("hyper-undo: scope not started");if(N==="commands")return pt(r,u,{honorPause:!0,receipt:!1});Y(b.takeRecords()),X();let s=E===0?ct():null,p=u();if(p&&typeof p.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(lt(b.takeRecords(),!0),s!=null&&ft(s),g.length===0){t.emit("commit");return}G();let k=g;g=[],he(r,k)}function Wn(r){if(!C)throw new Error("hyper-undo: scope not started");if(!b)return;if(E>1){oe(_(b.takeRecords()));return}X();let u=b.takeRecords(),s=Te(u,!0);for(let p of Ie(_(u)))s.push(p);s.length!==0&&(G(),he(r,s))}function Hn(){b&&oe(_(b.takeRecords()))}function Me(){let r=n.scope;return r&&r.ownerDocument||(typeof document<"u"?document:null)}function we(){let r=Me();return!r||!r.head||typeof r.head.querySelector!="function"?null:r.head.querySelector("title")}function ct(){let r=we();return r?r.textContent:null}function ft(r){let u=we();if(!u||r==null)return;let s=u.textContent;s!==r&&mt({kind:"value",target:u,prop:"textContent",oldValue:r,newValue:s})}function Jn(r){if(!r)return null;let u=Me();if(!u||r.target!==u||r.prop!=="title")return r;let s=we();return s?{kind:"value",target:s,prop:"textContent",oldValue:r.oldValue,newValue:r.newValue}:null}function Yn(){if(typeof window>"u")return!1;let r=window.clay?.effect||window.hyperclay?.effect;return!!(r&&r.running)}function Gn(){b&&Y(b.takeRecords()),X(),I={records:[],primitives:[]}}function Xn(){let r=I;if(I=null,!r)return[];let u=Te(r.records,!0);for(let s of Ie(_(r.records)))u.push(s);for(let s of r.primitives)u.push(s);return u}function pt(r,u,{honorPause:s,receipt:p}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(I)throw new Error("hyper-undo: command() cannot nest inside another command");if(B)throw new Error("hyper-undo: command() cannot run during undo or redo");if(Yn())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let k=s&&E>0,V=k?null:ct();Gn();let M=[],P=null,K;try{try{K=u()}catch(ie){P=ie}if(b&&Y(b.takeRecords()),K&&typeof K.then=="function"){try{K.then(void 0,()=>{})}catch{}P||(P=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}k||ft(V)}finally{M=Xn()}let F=k||M.length===0?null:he(r,M);if(P)throw P;return p?F?{id:F.id,label:F.label}:null:F}function Zn(r,u){if(!C)throw new Error("hyper-undo: scope not started");return pt(r,u,{honorPause:!1,receipt:!0})}function Qn(r){if(r!=="automatic"&&r!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(I)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return N===r||(X(),N=r,h("recording",r)),N}function gt(r){if(!C||!r||!I&&(E>0||N==="commands"))return;let u=Jn(r);u&&mt(u)}function mt(r){if(I){I.primitives.push(r);return}g.push(r),Oe()}function er(r,{prop:u="value",oldValue:s,newValue:p,read:k,write:V}={}){!r||s===p||gt({kind:"value",target:r,prop:u,oldValue:s,newValue:p,read:k,write:V})}function X(){E===0&&b&&Y(b.takeRecords()),g.length!==0&&(G(),Le())}function yt(){E===0&&b&&Y(b.takeRecords()),E++,h("paused",E)}function ht(){E!==0&&(E--,E===0&&b&&(ut(b.takeRecords()),H&&(H=!1,G(),Le())),h("resumed",E))}function bt(r,u){if(ye())return se(),{ok:!1,code:"disconnected"};if(typeof n.holdReplay=="function"&&n.holdReplay())return{ok:!1,code:"held"};X();let s=r==="undo"?o:a,p=r==="undo"?a:o,k=[],V=s.at(-1);if(!V)return{ok:!1,code:"empty"};if(u&&u!==V.id){let P=vt(u)||V;return je(P,r,"stale-entry")}let M=n.refused==="skip"&&!u;for(;V;){let P;B=!0;try{P=an(V.certificate,r,{isIgnored:be,ignoreAttribute:st,durableForm:n.durableForm,isProtected:Un,inScope:ur,liveNodesWithIds:lr})}finally{B=!1}if(!P.ok){if(!M)return je(V,r,P.code,P.targets);wt(V,r,P.code,P.targets,k),V=s.at(-1);continue}yt();let K;B=!0;try{K=mn(P.operations)}finally{B=!1,ht()}if(!K.ok){if(h(`${r} failed and was rolled back`,K.error),!M)return je(V,r,"replay-error");wt(V,r,"replay-error",[],k),V=s.at(-1);continue}oe(new Set(P.operations.filter(ie=>ie.type==="value"&&L.has(ie.target)).map(ie=>ie.target))),s.pop(),p.push(V),c=null;let F={ok:!0,entryId:V.id,label:V.label,direction:r};return k.length&&(F.skipped=k),K.caret&&(F.caret=K.caret),h(r,V.label),t.emit(r,F),F}return{ok:!1,code:"empty",direction:r,skipped:k}}function wt(r,u,s,p,k){c={entryId:r.id,direction:u,code:s,targets:p};let V=kt(r.id);(u==="undo"?o:a).pop(),c=null;let M={entryId:r.id,label:r.label,direction:u,code:s,targets:p,description:V};h("skipped",u,s),t.emit("skipped",M),k.push(M)}function tr(r){return bt("undo",r&&r.entryId)}function nr(r){return bt("redo",r&&r.entryId)}function vt(r){return o.find(u=>u.id===r)||a.find(u=>u.id===r)||null}function je(r,u,s,p=[]){return c={entryId:r.id,direction:u,code:s,targets:p},h("refused",u,s),t.emit("refused",{entryId:r.id,label:r.label,direction:u,code:s,targets:p}),{ok:!1,code:s,entryId:r.id,label:r.label,direction:u}}function rr(r){if(!c||c.entryId!==r)return{ok:!1,code:"not-refused",entryId:r};let u=c.direction,s=u==="undo"?o:a,p=s.at(-1);return!p||p.id!==r?{ok:!1,code:"stale-entry",entryId:r}:(s.pop(),c=null,h("discarded",p.label),t.emit("discard",{entryId:r,label:p.label,direction:u}),{ok:!0,entryId:r,direction:u})}function kt(r){let u=vt(r);if(!u||!u.certificate||!u.certificate.replayable)return null;let s=c&&c.entryId===u.id?{direction:c.direction,code:c.code,targets:(c.targets||[]).map(p=>({id:p.id??null,kind:p.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:s,steps:u.certificate.steps.map(ir)}}function or(r){return typeof r!="string"?null:r.replace(/#form:("(?:[^"\\]|\\.)*")/g,(u,s)=>{try{return JSON.parse(s)}catch{return""}})}function ir(r){if(r.type==="move")return{kind:"move",node:{id:D(r.node).id},from:{id:D(r.sourceParent).id},to:{id:D(r.destParent).id}};if(r.type==="add"||r.type==="restore")return{kind:r.type==="add"?"add":"remove",parent:{id:D(r.parent).id},nodes:r.nodes.map((V,M)=>({id:D(V).id,html:or(r.content[M])}))};let u=r.primitive,s={id:D(u.target).id},p=u.oldValue??null,k=u.newValue??null;return r.type==="value"?{kind:"value",target:s,prop:u.prop??"value",before:p,after:k}:r.type==="text"?{kind:"text",target:s,before:p,after:k}:r.type==="attr-set"||r.type==="attr-add"||r.type==="attr-remove"?{kind:"attribute",target:s,name:u.name??null,before:p,after:k}:{kind:r.type,target:s,before:p,after:k}}function ar(r){let u=new Set,s=!0;for(;s;){s=!1;for(let p of r)if(!(p.type!=="childList"||!p.removedNodes?.length)&&!re(p)&&!(!De(p.target)&&!At(p.target,u))&&!me(p.target,n.ignoreAttribute,p))for(let k of p.removedNodes)u.has(k)||(u.add(k),s=!0)}return p=>!De(p)&&At(p,u)}function At(r,u){for(let s=r;s;s=s.parentNode)if(u.has(s))return!0;return!1}function De(r){let u=n.scope;return!u||!r||typeof r.nodeType!="number"?!1:r===u||typeof u.contains=="function"&&u.contains(r)}function Et(r){let u=Me(),s=u&&u.head;if(!s||!r)return!1;let p=r.nodeType===1?r:r.parentElement;for(;p&&p!==s;p=p.parentElement)if(p.localName==="title")return!1;return p===s}function ur(r){let u=n.scope;return!r||!u?!1:r===u||we()===r||Et(r)?!0:typeof u.contains=="function"?u.contains(r):!1}function lr(r){let u=n.scope;if(!r||r.length===0||typeof u?.querySelectorAll!="function")return[];let s=new Set(r),p=[];for(let k of u.querySelectorAll("[data-id]"))s.has(k.getAttribute("data-id"))&&(be(k)||p.push(k));return p}function dr(){b&&oe(_(b.takeRecords())),o.length=0,a.length=0,g=[],c=null,G(),h("cleared"),t.emit("clear")}return{_config:n,_tracksContentAt:r=>N!=="commands"&&!!ne(r),_recordsAt:r=>N!=="commands"&&!be(r),start:T,stop:se,commit:_n,commitCaptured:Wn,discardCaptured:Hn,flush:X,command:Zn,setRecording:Qn,record:gt,recordValue:er,trackContent:Re,undo:tr,redo:nr,clear:dr,discard:rr,describe:kt,pause:yt,resume:ht,on:t.on,off:t.off,get canUndo(){return o.length>0},get canRedo(){return a.length>0},get isPaused(){return E>0},get history(){return o.map(r=>{let u={id:r.id,label:r.label,timestamp:r.timestamp};return c&&c.entryId===r.id&&(u.refused={direction:c.direction,code:c.code,targets:c.targets}),u})},get future(){return a.map(r=>{let u={id:r.id,label:r.label,timestamp:r.timestamp};return c&&c.entryId===r.id&&(u.refused={direction:c.direction,code:c.code,targets:c.targets}),u}).reverse()},get scope(){return n.scope}}}var jn=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function tt(e){let n=typeof e.composedPath=="function"?e.composedPath():[];return n.length>0?n:Kn(e.target)}function Dn(e){for(let n of tt(e)){if(!n||n.nodeType!==1)continue;let t=String(n.tagName||"").toUpperCase();if(t==="TEXTAREA"||t==="SELECT"||t==="INPUT"&&!jn.has(String(n.type||n.getAttribute?.("type")||"text").toLowerCase()))return!0}return!1}function nt(e){for(let n of tt(e)){if(!n||n.nodeType!==1)continue;if(n.isContentEditable===!0)return!0;let t=n.getAttribute&&n.getAttribute("contenteditable");if(t!=null&&String(t).toLowerCase()!=="false")return!0}return!1}function Ve(e,n){if(!e||!e.closest||!Array.isArray(n))return!1;for(let t of n)try{if(e.closest(t))return!0}catch{}return!1}function rt(e,n){if(Dn(e))return!0;let t=n._config,o=e.target;return t.editableKeys!=="page"?nt(e)||Ve(o,t.shadowKeydownIn):Ve(o,t.ownKeysIn)||n._tracksContentAt(o)?!1:Ve(o,t.shadowKeydownIn)?!0:nt(e)&&!n._recordsAt(o)}function Kn(e){let n=[];for(let t=e;t;t=t.parentNode||(t.host??null))n.push(t);return n}function qn(e,n){let t=i=>{let d=e.scope;if(d&&d.nodeType===1&&d.isConnected===!1){n&&n();return}if(i.defaultPrevented||i.isComposing||i.keyCode===229||rt(i,e)||!(i.metaKey||i.ctrlKey))return;let c=(i.key||"").toLowerCase();if(c==="z"&&!i.shiftKey){i.preventDefault(),i.stopPropagation(),e.undo();return}if(c==="z"&&i.shiftKey){i.preventDefault(),i.stopPropagation(),e.redo();return}if(c==="y"&&!i.shiftKey){i.preventDefault(),i.stopPropagation(),e.redo();return}},o=i=>{if(i.inputType!=="historyUndo"&&i.inputType!=="historyRedo")return;let d=e.scope;d&&d.nodeType===1&&d.isConnected===!1||i.defaultPrevented||i.isComposing||rt(i,e)||(i.preventDefault(),i.stopPropagation(),i.inputType==="historyRedo"?e.redo():e.undo())},a=e._config.editableKeys==="page";return window.addEventListener("keydown",t,!0),a&&window.addEventListener("beforeinput",o,!0),()=>{window.removeEventListener("keydown",t,!0),a&&window.removeEventListener("beforeinput",o,!0)}}var xe=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]",".ck-editor__editable","[data-lexical-editor]","[data-slate-editor]","trix-editor",".mce-content-body"],y=null,Ne=null,ot=null,U=null;function it(e,n){if(U){if(U.inst===e)return U.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=qn(e,n);return U={inst:e,cleanup:t},t}function at(e){U&&U.inst===e&&(U.cleanup(),U=null)}var Pe={defaults:{shadowKeydownIn:xe},start(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(y){if(Ne===n)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),y;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||xe};return y=et(t),y.start(),Ne=n,e.bindKeys!==!1&&(ot=it(y,()=>Pe.stop())),y},stop(){y&&(at(y),ot=null,y.stop(),y=null,Ne=null)},create(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||xe},o=et(t),a=null,i={_config:o._config,commit:o.commit,command:o.command,setRecording:o.setRecording,commitCaptured:o.commitCaptured,discardCaptured:o.discardCaptured,flush:o.flush,record:o.record,recordValue:o.recordValue,trackContent:o.trackContent,undo:o.undo,redo:o.redo,clear:o.clear,discard:o.discard,describe:o.describe,pause:o.pause,resume:o.resume,on:o.on,off:o.off,get canUndo(){return o.canUndo},get canRedo(){return o.canRedo},get isPaused(){return o.isPaused},get history(){return o.history},get future(){return o.future},get scope(){return o.scope},start(){e.bindKeys&&(a=it(o,()=>i.stop())),o.start()},stop(){at(o),a=null,o.stop()}};return i},commit(e,n){return y?y.commit(e,n):void 0},command(e,n){return y?y.command(e,n):void 0},setRecording(e){return y?y.setRecording(e):void 0},commitCaptured(e){return y?y.commitCaptured(e):void 0},discardCaptured(){return y?y.discardCaptured():void 0},record(e){return y?y.record(e):void 0},recordValue(e,n){return y?y.recordValue(e,n):void 0},trackContent(e,n){return y?y.trackContent(e,n):()=>{}},undo(e){return y?y.undo(e):void 0},redo(e){return y?y.redo(e):void 0},clear(){return y?y.clear():void 0},discard(e){return y?y.discard(e):void 0},describe(e){return y?y.describe(e):void 0},pause(){return y?y.pause():void 0},resume(){return y?y.resume():void 0},flush(){return y?y.flush():void 0},on(e,n){return y?y.on(e,n):void 0},off(e,n){return y?y.off(e,n):void 0},get canUndo(){return y?y.canUndo:!1},get canRedo(){return y?y.canRedo:!1},get history(){return y?y.history:[]},get future(){return y?y.future:[]},get isPaused(){return y?y.isPaused:!1}},$n=Pe;return O(q)})();window.__hyperclayNoAutoExport||(window.hyperclay=window.hyperclay||{},window.hyperclay.undo=Pt.undo,window.h=window.hyperclay);var w=Pt.undo;var jt='[contenteditable]:not([contenteditable="false"])';function sr(l,f){let m=Number(f)||0;m<0&&(m=0);let x=(l.ownerDocument||document).createTreeWalker(l,4),j=null;for(let O=x.nextNode();O;O=x.nextNode()){if(m<=O.data.length)return{node:O,offset:m};m-=O.data.length,j=O}return j?{node:j,offset:j.data.length}:{node:l,offset:l.childNodes.length}}function cr(l){let m=(l.nodeType===1?l:l.parentElement)?.closest?.(jt);return!m||!m.isConnected||typeof m.checkVisibility=="function"&&m.checkVisibility()===!1?null:m}function fr(l){if(!l)return;let f=l.root?sr(l.root,l.textOffset):l;if(!f?.node)return;let m=cr(f.node);m&&(typeof m.scrollIntoView=="function"&&m.scrollIntoView({block:"nearest",inline:"nearest"}),document.activeElement?.closest?.(jt)&&(document.activeElement!==m&&m.focus({preventScroll:!0}),document.getSelection()?.collapse(f.node,f.offset)))}var qe=new Set,$e=new Set,Dt=(l,f=null)=>{for(let m of $e){let A=m(l,f);if(typeof A=="string")return A}},Kt=(l={})=>{let f=l.ignoreAttribute;return{...l,ignoreAttribute:(m,A,x)=>qe.has(m)||St(m,A)||Vt(A,m,x)||xt(m,A)||(f?f(m,A,x):!1),isProtected:l.isProtected||pr,ignoreNode:l.ignoreNode||Nt,durableForm:l.durableForm||Dt}};function pr(l){let f=window.clay?.region?.resolveRegionPolicy;if(!f||l.nodeType!==1||Dt(l)!==void 0)return!1;let m=f(l);if(m.undoable!==!1||m.persist==="none")return!1;let A=l.parentElement;return!A||f(A).undoable!==!1}var gr=w.create.bind(w);w.create=l=>gr(Kt(l));var fe=null,mr=w.setRecording.bind(w);w.setRecording=l=>(fe=l??null,document.dispatchEvent(new CustomEvent("clay:undo-recording",{detail:{mode:fe}})),mr(l));Object.defineProperty(w,"recordingMode",{get:()=>fe,configurable:!0});var Rt=()=>w.history.at(-1)?.id??null,qt=w.command.bind(w);w.command=(l,f)=>{let m=qt(l,f);return m&&ke(),m};w.recordStep=(l,f)=>qt(l,()=>w.record(f));var $t=l=>!!l?.steps?.length&&l.steps.every(f=>f.kind==="value"&&/^blockeditor-step(?::|$)/.test(f.prop)),yr=w.commit.bind(w),It=!1;w.commit=(l,f)=>{!It&&window.clay?.effect?.running&&(It=!0,console.warn(`clay.effect: undo.commit("${l}") was called inside an effect. Run commands from event handlers, not from an effect.`));let m=Rt(),A=yr(l,f);return(A||Rt()!==m)&&ke(),A};var hr=`input${ve}:not([type="password"]):not([type="hidden"]):not([type="file"]), textarea${ve}, select${ve}`;function br(){let l=f=>window.clay?.region?.resolveRegionPolicy?.(f)?.undoable!==!1;document.querySelectorAll(hr).forEach(f=>{if(!l(f))return;if(f.tagName==="SELECT"){for(let q of f.options){let pe=q.hasAttribute("selected");q.selected!==pe&&(q.selected=pe)}return}let m=(f.getAttribute("type")||"text").toLowerCase();if(f.tagName==="INPUT"&&(m==="checkbox"||m==="radio")){let q=f.hasAttribute("checked");f.checked!==q&&(f.checked=q);return}let A=f.tagName==="TEXTAREA"?f.getAttribute("data-value")??f.textContent:f.getAttribute("value")??"";if(f.value===A)return;let x=f===document.activeElement,j,O;try{j=f.selectionStart,O=f.selectionEnd}catch{}if(f.value=A,x&&j!=null)try{f.setSelectionRange(Math.min(j,A.length),Math.min(O,A.length))}catch{}})}var Tt=l=>{l?.ok&&($t(w.describe(l.entryId))||ke(),br(),l.caret&&w.pageHistory&&fr(l.caret))},Ot=({entryId:l,label:f,direction:m,code:A})=>{document.dispatchEvent(new CustomEvent("clay:undo-refused",{detail:{ok:!1,code:A,entryId:l,label:f,direction:m}})),zt({ok:!1,code:A,entryId:l,label:f,direction:m})},Lt=({entryId:l,label:f,direction:m,code:A,description:x})=>{document.dispatchEvent(new CustomEvent("clay:undo-skipped",{detail:{entryId:l,label:f,direction:m,code:A}})),!$t(x)&&zt({ok:!1,code:A,entryId:l,label:f,direction:m,description:x})},Ke=null;function Bt(){return Ke??=import("../c-2EPHRF47.js").catch(l=>(Ke=null,console.error("clayjs: the undo recovery module could not be downloaded; a refused step stays in this tab only",l),null)),Ke}async function zt(l){let f={ok:!1,code:"unavailable"};try{let A=await Bt();A&&(f=await A.keepRefusal(w,l))}catch{f={ok:!1,code:"error"}}let m=f?.ok===!0?{ok:!0,entryId:l.entryId,direction:l.direction}:{ok:!1,code:f?.code||"error",entryId:l.entryId,direction:l.direction};document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:m}))}var ze=(l,f)=>(...m)=>Bt().then(A=>A?A[l](...m):f,()=>f),wr=ze("keep",{ok:!1,code:"unavailable"});w.addDurableForm=l=>($e.add(l),()=>{$e.delete(l)});w.ignoreAttribute=l=>{let f=String(l||"");return f?(qe.add(f),()=>{qe.delete(f)}):()=>{}};w.keep=async l=>{let f=await wr(l);return f?.ok===!0&&document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:{ok:!0,key:l?.key==null?null:`app:${l.key}`}})),f};w.kept=ze("kept",{ok:!1,code:"unavailable",records:[]});w.dismissKept=ze("dismissKept",{ok:!1,code:"unavailable"});var Be=new Set;w.reviewActions=l=>typeof l!="function"?()=>{}:(Be.add(l),()=>{Be.delete(l)});w.reviewActionsFor=l=>{let f=[];for(let m of Be){let A;try{A=m(l)}catch(x){console.error("clayjs: a review action could not describe itself; the copy stays reviewable",x);continue}for(let x of Array.isArray(A)?A:[])x&&typeof x.run=="function"&&x.label&&f.push(x)}return f};var vr=["commit","undo","redo","refused","skipped","discard","clear"],ue=new Set,Ft=l=>{for(let f=w;f;f=Object.getPrototypeOf(f)){let m=Object.getOwnPropertyDescriptor(f,l);if(m)return typeof m.get=="function"?()=>m.get.call(w):()=>!!m.value.call(w)}return()=>!1},kr=Ft("canUndo"),Ar=Ft("canRedo");Object.defineProperty(w,"canUndo",{get:()=>ue.size===0&&kr(),configurable:!0});Object.defineProperty(w,"canRedo",{get:()=>ue.size===0&&Ar(),configurable:!0});w.hold=()=>{let l=Symbol("hold");ue.add(l),ae();let f=!1;return()=>{f||(f=!0,ue.delete(l),ae())}};var ae=()=>{let l=!!Z?.started&&ue.size===0;document.dispatchEvent(new CustomEvent("clay:undo-change",{detail:{canUndo:l&&w.canUndo,canRedo:l&&w.canRedo,undo:l&&w.history.at(-1)||null,redo:l&&w.future?.[0]||null}}))},Z=null;Object.defineProperty(w,"pageHistory",{get:()=>!!Z?.started,configurable:!0});var Mt=()=>{typeof document>"u"||document.dispatchEvent(new CustomEvent("clay:undo-session",{detail:{started:!!Z?.started,pageHistory:w.pageHistory}}))};function Er(){return{started:!1,admitted:!1,subscriptions:[]}}var Sr=l=>l?l.signal?.aborted?!0:typeof l.isCurrent=="function"&&!l.isCurrent():!1;function Cr(){return typeof document>"u"||document.readyState!=="loading"?Promise.resolve():new Promise(l=>document.addEventListener("DOMContentLoaded",l,{once:!0}))}function Vr(l){return{enable(){if(!l.started){l.started=!0,l.admitted=!0,w.start(Kt({bindKeys:!0,editableKeys:"page",ownKeysIn:[".blockeditor-editor"],typingBreak:"sentence",refused:"skip",holdReplay:()=>ue.size>0,...fe?{recording:fe}:{}}));for(let f of["undo","redo"])w.on(f,Tt),l.subscriptions.push({type:f,handler:Tt});w.on("refused",Ot),l.subscriptions.push({type:"refused",handler:Ot}),w.on("skipped",Lt),l.subscriptions.push({type:"skipped",handler:Lt});for(let f of vr)w.on(f,ae),l.subscriptions.push({type:f,handler:ae});ae(),Mt()}},quiesce(){l.admitted&&(l.admitted=!1,w.pause())},resume(){l.admitted||(l.admitted=!0,w.resume())},dispose(){if(l.admitted=!1,Z===l&&(Z=null),!!l.started){l.started=!1;for(let{type:f,handler:m}of l.subscriptions.splice(0))w.off(f,m);w.stop(),ae(),Mt()}}}}function xr(){return{id:"clay:undo",order:350,async prepare(l={}){if(l.initial===!0)return Nr();if(await Cr(),Sr(l))throw Object.assign(new Error("clay:undo prepared for a stale generation"),{code:"stale-document"});return Vr(Z||(Z=Er()))}}}async function Nr(){let l=await Rr;return{enable(){},quiesce:()=>l?.quiesce(),resume:()=>l?.resume(),dispose:()=>l?.dispose()}}async function Pr(){if(!Ct()||typeof document>"u")return null;let l=await xr().prepare();return l.enable(),l}var Rr=Pr();var Br=w;export{Br as default,Pr as init,xr as modeParticipant,Rr as ready,br as restoreControls,w as undo,xr as undoParticipant};
1
+ import{b as xt,c as Nt}from"../c-7DJDKPGL.js";import{g as ke}from"../c-T6RRRHX7.js";import{a as ve}from"../c-WYFDLITL.js";import"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import{k as Ct}from"../c-JEWSJHMK.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import{a as Vt}from"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import{l as St}from"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var Pt=(()=>{var l=Object.defineProperty,f=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,A=Object.prototype.hasOwnProperty,x=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},j=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of m(n))!A.call(e,a)&&a!==t&&l(e,a,{get:()=>n[a],enumerable:!(o=f(n,a))||o.enumerable});return e},O=e=>j(l({},"__esModule",{value:!0}),e),q={};x(q,{default:()=>$n,endsSentence:()=>Qe,undo:()=>Pe});function pe(e,n=null){let t=[];if(e.type==="attributes"){let o=e.target,a=e.attributeName,i=e.oldValue,d=o.getAttribute(a);return i==null&&d!=null?t.push({kind:"attr-add",target:o,name:a,newValue:d}):i!=null&&d==null?t.push({kind:"attr-remove",target:o,name:a,oldValue:i}):i!==d&&t.push({kind:"attr-set",target:o,name:a,oldValue:i,newValue:d}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let o=e.target,a=e.nextSibling,i=e.nextSibling;for(;i&&n?.(i);)i=i.nextSibling;let d=e.previousSibling;for(;d&&n?.(d);)d=d.previousSibling;let c=n?Array.from(e.addedNodes).filter(v=>!n(v)):Array.from(e.addedNodes),g=n?Array.from(e.removedNodes).filter(v=>!n(v)):Array.from(e.removedNodes);return c.length>0&&t.push({kind:"add",parent:o,nodes:c,before:a,afterAuthored:i,beforeAuthored:d,record:e}),g.length>0&&t.push({kind:"remove",parent:o,nodes:g,before:a,afterAuthored:i,beforeAuthored:d,record:e}),t}return t}function Ut(e,n=null){let t=[],o=new Map;for(let a of e){if(a.type==="attributes"){let i=a.target,d=a.attributeName,c=o.get(i);c||(c=new Map,o.set(i,c)),c.has(d)||(c.set(d,{idx:t.length,oldValue:a.oldValue}),t.push(null));continue}for(let i of pe(a,n))t.push(i)}for(let[a,i]of o)for(let[d,c]of i){let g=c.oldValue,v=a.getAttribute(d),b=null;g===v?b=null:g==null?b={kind:"attr-add",target:a,name:d,newValue:v}:v==null?b={kind:"attr-remove",target:a,name:d,oldValue:g}:b={kind:"attr-set",target:a,name:d,oldValue:g,newValue:v},t[c.idx]=b}return t.filter(a=>a!=null)}function _t(e,{sameContent:n=(t,o)=>t===o}={}){let t=[],o=new Map;for(let i of e){let d=Fe(i);if(d==null){t.push(i);continue}let c=o.get(i.target);c||(c=new Map,o.set(i.target,c));let g=c.get(d);if(g==null){let v=Ue(i);if(v.oldValue===v.newValue)continue;c.set(d,t.length),t.push({...i,...v})}else t[g]={...t[g],newValue:Ue(i).newValue}}let a=[];for(let i of t){if(Fe(i)==null){a.push(i);continue}i.oldValue!==i.newValue&&(i.kind==="value"&&i.content===!0&&n(i.oldValue,i.newValue)||a.push(Ht(i)))}return a}var Wt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function Fe(e){return Wt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ue(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function Ht(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var _e=new WeakMap,Jt=0;function $(e){let n=_e.get(e);return n||(n=`n${++Jt}`,_e.set(e,n)),n}function R(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function Yt(e){return e.kind==="add"||e.kind==="remove"}function We(e,n){let t=[],o=e.childNodes;if(!o)return t;for(let a of o)n&&n(a)||t.push($(a));return t}function He(e,n,t){if(typeof n!="function"||!R(e)||e.nodeType!==1)return null;let o=null;try{o=n(e,t)}catch{o=null}return typeof o=="string"?`#form:${JSON.stringify(o)}`:null}function le(e,n,t=null,o=null,a=null,i=null){if(!R(e))return null;let d=He(e,a,t);if(d!=null)return d;if(e.nodeType===3)return`#text:${JSON.stringify(i&&i.has(e)?i.get(e):e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let c=[];if(e.attributes){for(let v of e.attributes)Gt(v.name,e,n,t)||c.push(`${v.name}=${JSON.stringify(v.value)}`);c.sort()}let g=[];if(e.childNodes)for(let v of e.childNodes){let b=He(v,a,t);if(b!=null){g.push(b);continue}Xt(v,o)||g.push(le(v,n,t,o,a,i))}return`<${String(e.tagName||"").toLowerCase()}${c.length?` ${c.join(" ")}`:""}>${g.join("")}</>`}function Ae(e,n=[]){if(!R(e))return n;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&n.push(t)}if(e.childNodes)for(let t of e.childNodes)Ae(t,n);return n}function Gt(e,n,t,o=null){if(typeof t!="function")return!1;try{return!!t(e,n,o)}catch{return!1}}function Xt(e,n){if(typeof n!="function")return!1;try{return!!n(e)}catch{return!1}}function Je(e,n){if(typeof n!="function")return[];let t=[],o=a=>{if(!R(a))return;let i=!1;try{i=!!n(a)}catch{i=!1}if(i&&t.push(D(a,"protected")),a.childNodes)for(let d of a.childNodes)o(d)};for(let a of e)o(a);return t}function D(e,n,t=null){let o=e;o&&o.nodeType!==1&&(o=o.parentElement);let a=o&&typeof o.closest=="function"?o.closest("[data-id]"):null;return!a&&t&&typeof t.closest=="function"&&(a=t.closest("[data-id]")),{id:(a?a.getAttribute("data-id"):null)||null,kind:n||null}}function Zt(e,n,t=null){return(e||[]).filter(R).map(o=>D(o,n,t))}function de(e){return{replayable:!1,reason:e,steps:[]}}function ge(e,n){let t=[[n.afterAuthored,a=>a],[n.beforeAuthored,a=>a+1],[n.before,a=>a]],o=!1;for(let[a,i]of t){if(!R(a))continue;o=!0;let d=e.indexOf($(a));if(d>=0)return i(d)}return o?null:e.length}function Qt(e,n={}){let t=n.isIgnored||null,o=n.ignoreAttribute||null,a=n.durableForm||null,i=_t(e,{sameContent:Ee}),d=[];for(let E of i){if(!Yt(E)){if(!R(E.target))return de("non-dom-target");continue}if(!R(E.parent))return de("non-dom-parent");let C=Array.from(E.nodes||[]).filter(R);if(C.length!==0){if(C.length!==Array.from(E.nodes||[]).length)return de("non-dom-node");d.push({primitive:E,nodes:C,parent:E.parent})}}if(en(d))return de("in-record-move");let c=tn(d,t);if(!c)return de("ambiguous-structure");let g=nn(d,c),v=new Map(d.map(E=>[E.primitive,E])),b=[];for(let E of i){let C=v.get(E);if(!C){b.push(on(E));continue}let N=g.get(C);if(N){N.at===C&&b.push(N.step);continue}b.push(rn(C,c.get(C),o,t,a))}return{replayable:!0,reason:null,steps:b}}function en(e){let n=new Map;for(let t of e){let o=t.primitive.record;if(!o)continue;let a=n.get(o);a||(a=new Map,n.set(o,a));for(let i of t.nodes){let d=a.get(i);d||(d=new Set,a.set(i,d)),d.add(t.primitive.kind)}}for(let t of n.values())for(let o of t.values())if(o.size>1)return!0;return!1}function tn(e,n){let t=new Map;for(let a of e)t.has(a.parent)||t.set(a.parent,We(a.parent,n));let o=new Map;for(let a=e.length-1;a>=0;a--){let i=e[a],d=t.get(i.parent);if(!d)return null;let c=d.slice(),g;if(i.primitive.kind==="add"){let v=i.nodes.map($);if(!v.every(b=>d.includes(b)))return null;g=d.filter(b=>!v.includes(b))}else{let v=ge(c,i.primitive);if(v==null)return null;g=c.slice(),g.splice(v,0,...i.nodes.map($))}o.set(i,{before:g,after:c}),t.set(i.parent,g)}return o}function nn(e,n){let t=new Map,o=new Map;e.forEach((i,d)=>{for(let c of i.nodes){let g=$(c);i.primitive.kind==="remove"?t.set(g,{item:i,index:d,node:c}):o.set(g,{item:i,index:d,node:c})}});let a=new Map;for(let[i,d]of t){let c=o.get(i);if(!c||c.index<d.index||d.item.nodes.length!==1||c.item.nodes.length!==1)continue;let g={type:"move",node:d.node,sourceParent:d.item.parent,destParent:c.item.parent,source:n.get(d.item),dest:n.get(c.item),sourceSlot:d.item.primitive,destSlot:c.item.primitive,targets:[D(d.node,"move")]};a.set(d.item,{step:g,at:c.item}),a.set(c.item,{step:g,at:c.item})}return a}function rn(e,n,t,o,a=null){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:n.before,seqAfter:n.after,slot:e.primitive,content:e.nodes.map(d=>le(d,t,e.parent,o,a)),ids:i==="remove"?e.nodes.flatMap(d=>Ae(d)):[],targets:Zt(e.nodes,i==="add"?"added":"removed",e.parent)}}function on(e){return{type:e.kind,primitive:e,targets:[D(e.target,e.name||e.prop||"text")]}}function an(e,n,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let o={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,durableForm:t.durableForm||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,texts:new Map,operations:[]};for(let a=0;a<e.steps.length;a++){let i=e.steps[n==="undo"?e.steps.length-1-a:a],d=ln(i,n,o);if(d)return{ok:!1,code:d.code,targets:d.targets}}return{ok:!0,operations:o.operations}}function Q(e,n){return e.sim.has(n)||e.sim.set(n,We(n,e.isIgnored)),e.sim.get(n)}function ee(e,n){for(let t=e;t;t=t.parentNode)if(n.planned.has(t))return n.planned.get(t);return n.inScope(e)}function Ye(e,n){return n.liveNodesWithIds(e).filter(t=>ee(t,n)).length>0}function S(e,n){return{code:e,targets:n||[]}}function Ee(e,n){return e===n?!0:typeof e!="string"||typeof n!="string"?!1:e.replace(/\u00A0|&nbsp;/g," ")===n.replace(/\u00A0|&nbsp;/g," ")}function un(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function ln(e,n,t){let o=n==="undo";return e.type==="move"?pn(e,o,t):e.type==="add"?sn(e,o,t):e.type==="restore"?cn(e,o,t):dn(e,o,t)}function dn(e,n,t){let o=e.primitive,a=n?o.newValue:o.oldValue,i=n?o.oldValue:o.newValue;if(!R(o.target))return S("unsupported",e.targets);if(!ee(o.target,t))return S("target-detached",e.targets);if(o.kind==="value"&&typeof o.write=="function"&&typeof o.read!="function")return S("unsupported",e.targets);let d=un(o);return(o.content===!0?!Ee(d,a):d!==a)?S("content-changed",e.targets):(o.kind==="value"?t.operations.push({type:"value",target:o.target,prop:o.prop||"value",value:i,read:o.read||null,write:o.write||null,content:o.content===!0}):o.kind==="text"?(t.operations.push({type:"text",target:o.target,data:i}),t.texts.set(o.target,i)):t.operations.push({type:"attr",target:o.target,name:o.name,value:i??null}),null)}function sn(e,n,t){if(!R(e.parent)||!ee(e.parent,t))return S("target-detached",e.targets);if(n){if(!te(Q(t,e.parent),e.seqAfter))return S("structure-changed",e.targets);let c=Je(e.nodes,t.isProtected);if(c.length>0)return S("protected",c);for(let g=0;g<e.nodes.length;g++)if(le(e.nodes[g],t.ignoreAttribute,e.parent,t.isIgnored,t.durableForm)!==e.content[g])return S("content-changed",e.targets);for(let g of e.nodes)t.operations.push({type:"remove",node:g}),t.planned.set(g,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!te(Q(t,e.parent),e.seqBefore))return S("structure-changed",e.targets);for(let c of e.nodes)if(c.parentNode)return S("structure-changed",e.targets);let o=e.nodes.flatMap(c=>Ae(c));if(o.length>0&&Ye(o,t))return S("duplicate-id",e.targets);let a=ge(e.seqBefore,e.slot);if(a==null)return S("unsupported",e.targets);let i=e.seqBefore.slice(),d=a;for(let c of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:c,beforeId:i[d]??null}),i=i.slice(0,d).concat($(c),i.slice(d)),d+=1,t.planned.set(c,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function cn(e,n,t){if(!R(e.parent)||!ee(e.parent,t))return S("target-detached",e.targets);if(n){if(!te(Q(t,e.parent),e.seqAfter))return S("structure-changed",e.targets);for(let g=0;g<e.nodes.length;g++){let v=e.nodes[g];if(v.parentNode||le(v,t.ignoreAttribute,e.parent,t.isIgnored,t.durableForm)!==e.content[g])return S("content-changed",e.targets)}if(e.ids.length>0&&Ye(e.ids,t))return S("duplicate-id",e.targets);let i=ge(e.seqAfter,e.slot);if(i==null)return S("unsupported",e.targets);let d=e.seqAfter.slice(),c=i;for(let g of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:g,beforeId:d[c]??null}),d=d.slice(0,c).concat($(g),d.slice(c)),c+=1,t.planned.set(g,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!te(Q(t,e.parent),e.seqBefore))return S("structure-changed",e.targets);let o=Je(e.nodes,t.isProtected);if(o.length>0)return S("protected",o);let a=i=>t.planned.get(i)===!0||typeof t.isIgnored=="function"&&t.isIgnored(i);for(let i=0;i<e.nodes.length;i++){let d=e.nodes[i];if(d.parentNode!==e.parent||le(d,t.ignoreAttribute,e.parent,a,t.durableForm,t.texts)!==e.content[i])return S("content-changed",e.targets)}for(let i of e.nodes)t.operations.push({type:"remove",node:i}),t.planned.set(i,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function fn(e,n){let t=e.indexOf(n);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function pn(e,n,t){let o=$(e.node),a=n?e.destParent:e.sourceParent,i=n?e.sourceParent:e.destParent,d=Q(t,a),c=Q(t,i),g=n?e.dest.after:e.source.before,v=n?e.source.after:e.dest.before,b=n?e.sourceSlot:e.destSlot;if(!R(a)||!R(i)||!ee(a,t)||!ee(i,t))return S("target-detached",e.targets);if(!te(d,g))return S("structure-changed",e.targets);let E=a===i?fn(c,o):c;if(!te(E,v))return S("structure-changed",e.targets);let C=ge(v,b);return C==null?S("unsupported",e.targets):(t.operations.push({type:"insert",parent:i,node:e.node,beforeId:v[C]??null}),t.planned.set(e.node,!0),n?(t.sim.set(i,e.source.before.slice()),a!==i&&t.sim.set(a,e.dest.before.slice())):(t.sim.set(i,e.dest.after.slice()),a!==i&&t.sim.set(a,e.source.after.slice())),null)}function te(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function gn(e,n){for(let t of e.childNodes||[])if($(t)===n)return t;return null}function Ge(e,n){let t=Math.min(e.length,n.length),o=0;for(;o<t&&e[o]===n[o];)o++;let a=0;for(;a<t-o&&e[e.length-1-a]===n[n.length-1-a];)a++;return n.length-a}function Xe(e,n){typeof e.write=="function"?e.write(e.target,n):e.target[e.prop]=n}function mn(e){let n=[];try{let t=null;for(let o of e)t=yn(o,n)||t;return{ok:!0,caret:t}}catch(t){for(let o=n.length-1;o>=0;o--)try{n[o]()}catch{}return{ok:!1,error:t}}}function yn(e,n){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),n.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;return e.target.data=e.data,n.push(()=>{e.target.data=t}),{node:e.target,offset:Ge(t,e.data)}}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop],o=e.content?e.target.textContent:null;if(Xe(e,e.value),n.push(()=>Xe(e,t)),!e.content)return;let a=e.target.textContent;return a===o?void 0:{root:e.target,textOffset:Ge(o,a)}}if(e.type==="insert"){let t=e.beforeId==null?null:gn(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let o=e.node.parentNode,a=e.node.nextSibling;return e.parent.insertBefore(e.node,t),n.push(()=>{o?o.insertBefore(e.node,a&&a.parentNode===o?a:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)}),e.node.nodeType!==3?void 0:{node:e.node,offset:e.node.data.length}}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let o=e.node.nextSibling,a=Array.prototype.indexOf.call(t.childNodes,e.node);return t.removeChild(e.node),n.push(()=>t.insertBefore(e.node,o)),e.node.nodeType!==3?void 0:{node:t,offset:a}}}var hn=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],bn=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],wn=hn.join(","),vn=new RegExp("^(?:"+bn.join("|")+")(?:-|$)"),Ir=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),kn=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),An=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function Se(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function Ze(e,n){if(Se(e,n))return!0;for(let[t,o]of Object.entries(kn))if(o.includes(n)&&Se(e,t))return!0;return!1}function En(e){return e==="clay"||An.includes(e)}var Sn=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function Cn(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function Ce(e){let n=Cn();if(n)try{if(!n(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(wn))return!0;for(;t&&t.nodeType===1;){if(Ze(t,"no-undo")||Ze(t,"no-watch"))return!0;for(let o of Sn)if(Se(t,o))return!0;t=t.parentElement}return!1}function Vn(e){let n=e.target,t=n.cloneNode(!1),o=t;for(;n.parentElement;){n=n.parentElement;let a=n.cloneNode(!1);a.appendChild(t),t=a}return e.oldValue==null?o.removeAttribute(e.attributeName):o.setAttribute(e.attributeName,e.oldValue),Ce(o)}function me(e,n,t){if(t?.type==="attributes"&&En(t.attributeName)){if(Ce(e)&&Vn(t))return!0}else if(Ce(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&vn.test(t.attributeName.toLowerCase()))return!0;if(n)try{if(n(t.attributeName,t.target))return!0}catch{}}return!1}function xn(){let e=new Map;function n(a,i){let d=e.get(a);return d||(d=new Set,e.set(a,d)),d.add(i),()=>t(a,i)}function t(a,i){let d=e.get(a);d&&d.delete(i)}function o(a,i){let d=e.get(a);if(d)for(let c of Array.from(d))try{c(i)}catch(g){console.error("[hyper-undo] listener threw",g)}}return{on:n,off:t,emit:o}}var Nn=/[.?!]["'\u201D\u2019)\]]*$/,Pn=new Set(["insertParagraph","insertLineBreak"]),Rn=new Set(["insertFromPaste","insertFromDrop","insertFromYank","insertReplacementText","deleteByCut","deleteByDrag"]),In=new Set(["Enter","Backspace","Delete"]),Tn=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Qe(e){return Nn.test(e)}function On(e,{sentence:n,endStep:t,stepOpen:o=()=>!0,composing:a}){let i=e.ownerDocument&&e.ownerDocument.defaultView;if(!i)return()=>{};let d=h=>!!h&&typeof h.nodeType=="number"&&(h===e||e.contains(h)),c=!1,g=!1,v=!1,b={kind:"other",host:null},E=h=>Rn.has(h)||h.startsWith("format")?"alone":h.startsWith("delete")?"delete":h.startsWith("insert")?"insert":"other",C=h=>{if(!h)return null;let T=h.nodeType===1?h:h.parentElement;return T&&T.closest&&T.closest('[contenteditable]:not([contenteditable="false"])')||h},N=()=>{c&&(c=!1,t())},I=h=>{if(!n||h.isComposing||!d(h.target))return;let T=h.inputType||"",z=E(T),se=C(h.target),ye=i.getSelection&&i.getSelection(),ce=!ye||ye.isCollapsed,Re=g;g=!1;let ne=v;if(v=!1,(z==="alone"||!ne&&z!==b.kind&&z!=="other"&&b.kind!=="other"||!ne&&(b.host!==null&&se!==b.host||!ce||Re))&&t(),b={kind:z,host:se},z==="alone"){c=!0,setTimeout(N,0);return}let re=T==="insertText"&&(h.data===" "||h.data==="\xA0");!re&&!Pn.has(T)||re&&!o()||Qe(Ln(i))&&(c=!0,setTimeout(N,0))},B=h=>{d(h.target)&&N()},L=h=>{d(h.target)&&a(!0)},W=h=>{d(h.target)&&a(!1)},H=h=>{d(h.target)&&(g=!0)},J=h=>{if(!d(h.target))return;if(Tn.has(h.key)){g=!0;return}if(!n||h.isComposing||h.keyCode===229||h.ctrlKey||h.metaKey||!h.key||h.key.length!==1&&!In.has(h.key))return;let T=i.getSelection&&i.getSelection(),z=b.host!==null&&C(h.target)!==b.host;!g&&!z&&(!T||T.isCollapsed)||(t(),g=!1,v=!0,setTimeout(()=>{v=!1},0))};return e.addEventListener("beforeinput",I,!0),e.addEventListener("input",B,!0),e.addEventListener("compositionstart",L,!0),e.addEventListener("compositionend",W,!0),e.addEventListener("pointerdown",H,!0),e.addEventListener("keydown",J,!0),()=>{e.removeEventListener("beforeinput",I,!0),e.removeEventListener("input",B,!0),e.removeEventListener("compositionstart",L,!0),e.removeEventListener("compositionend",W,!0),e.removeEventListener("pointerdown",H,!0),e.removeEventListener("keydown",J,!0)}}function Ln(e){let n=e.getSelection&&e.getSelection();if(!n||!n.isCollapsed||!n.anchorNode)return"";let t=n.anchorNode,o=t.nodeType===1?t:t.parentElement,a=o&&o.closest('[contenteditable]:not([contenteditable="false"])');if(!a)return"";let i=a.ownerDocument.createRange();return i.setStart(a,0),i.setEnd(t,n.anchorOffset),i.toString().replace(/\u200B/g,"").slice(-8)}var Mn={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,durableForm:null,typingBreak:null,refused:null,debug:!1};function et(e){let n={...Mn,...e};if(!n.scope)throw new Error("hyper-undo: scope is required");let t=xn(),o=[],a=[],i=`u${Math.random().toString(36).slice(2,8)}`,d=0,c=null,g=[],v=null,b=null,E=0,C=!1,N=n.recording==="commands"?"commands":"automatic",I=null,B=!1,L=new WeakMap,W=!1,H=!1,J=null;function h(...r){n.debug&&console.log("[hyper-undo]",...r)}function T(){C||(C=!0,b=z(Y),b.observe(n.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),J=On(n.scope,{sentence:n.typingBreak==="sentence",stepOpen:()=>(E===0&&b&&Y(b.takeRecords()),g.length>0),endStep:X,composing:Fn}),h("started"))}function z(r){let u=typeof document<"u"&&n.scope===document.body,s=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&s&&typeof s.createObserver=="function"?(h("sourcing records from the platform Mutation hub (shared observer)"),s.createObserver(r)):new MutationObserver(r)}function se(){C&&(C=!1,b&&(b.disconnect(),b=null),J&&(J(),J=null),W=!1,G(),o.length=0,a.length=0,g=[],c=null,I=null,B=!1,E=0,L=new WeakMap,h("stopped"))}function ye(){let r=n.scope;return!!(r&&r.nodeType===1&&r.isConnected===!1)}function ce(r,u){try{let s=u(r);return typeof s=="string"?s:null}catch{return null}}function Re(r,{read:u,write:s,prop:p="content"}={}){if(!r||typeof u!="function"||typeof s!="function")return()=>{};let k={prop:p,read:u,write:s,baseline:ce(r,u)};return L.set(r,k),()=>{L.get(r)===k&&L.delete(r)}}function ne(r){for(let u=r;u;u=u.parentNode)if(L.has(u))return u;return null}function re(r){let u=ne(r.target);return!!u&&!(r.type==="attributes"&&r.target===u)}function _(r){let u=new Set;for(let s of r)re(s)&&u.add(ne(s.target));return u}function Ie(r){let u=[];for(let s of r){let p=L.get(s),k=ce(s,p.read);if(k!=null){if(Ee(k,p.baseline)){p.baseline=k;continue}p.baseline!=null&&u.push({kind:"value",target:s,prop:p.prop,oldValue:p.baseline,newValue:k,read:p.read,write:p.write,content:!0}),p.baseline=k}}return u}function oe(r){for(let u of r){let s=L.get(u);s.baseline=ce(u,s.read)}}function ut(r){let u=_(r);!H&&g.some(s=>s.kind==="value"?u.has(s.target):r.some(p=>p.target===s.target&&(p.type==="characterData"?s.kind==="text":p.type==="attributes"&&p.attributeName===s.name)))&&(H=!0),oe(u)}function Y(r){lt(r,!1)}function lt(r,u){if(I){for(let p of r)I.records.push(p);return}if(N==="commands"){oe(_(r));return}if(E>0){ut(r);return}let s=Te(Bn(r),u);for(let p of Ie(_(r)))s.push(p);if(s.length>0){for(let p of s)g.push(p);Oe()}}function Bn(r){return typeof n.ignoreNode!="function"?r:r.filter(u=>{if(u.type!=="childList")return!0;let s=[...u.addedNodes,...u.removedNodes];return s.length===0?!0:!s.every(p=>zn(p))})}function zn(r){try{return!!n.ignoreNode(r)}catch{return!1}}function Te(r,u=!1){let s=ar(r),p=r.filter(k=>(De(k.target)||s(k.target)||u&&Et(k.target))&&!re(k)&&!me(k.target,n.ignoreAttribute,k));return Ut(p,k=>me(k,n.ignoreAttribute))}function Fn(r){W=!!r,!W&&g.length>0&&Oe()}function Oe(){G(),v=setTimeout(dt,n.idleWindowMs)}function dt(){if(v=null,W){v=setTimeout(dt,n.idleWindowMs);return}Le()}function G(){v!=null&&(clearTimeout(v),v=null)}function Le(){if(v=null,g.length===0)return;let r=g;g=[],he(n.idleLabel,r)}function he(r,u){let s=Qt(u,{isIgnored:be,ignoreAttribute:st,durableForm:n.durableForm});if(s.steps.length===0)return h("commit",r,"with nothing to record"),t.emit("commit"),null;let p={id:`${i}-${++d}`,label:r,timestamp:Date.now(),primitives:u,certificate:s};for(o.push(p),a.length=0,c=null;o.length>n.maxHistory;)o.shift();return h("commit",r,"primitives:",u.length),t.emit("commit"),p}function be(r){return me(r,n.ignoreAttribute)}function st(r,u,s=null){if(typeof n.ignoreAttribute!="function")return!1;try{return!!n.ignoreAttribute(r,u,s)}catch{return!1}}function Un(r){if(typeof n.isProtected!="function")return!1;try{return!!n.isProtected(r)}catch{return!1}}function _n(r,u){if(!C)throw new Error("hyper-undo: scope not started");if(N==="commands")return pt(r,u,{honorPause:!0,receipt:!1});Y(b.takeRecords()),X();let s=E===0?ct():null,p=u();if(p&&typeof p.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(lt(b.takeRecords(),!0),s!=null&&ft(s),g.length===0){t.emit("commit");return}G();let k=g;g=[],he(r,k)}function Wn(r){if(!C)throw new Error("hyper-undo: scope not started");if(!b)return;if(E>1){oe(_(b.takeRecords()));return}X();let u=b.takeRecords(),s=Te(u,!0);for(let p of Ie(_(u)))s.push(p);s.length!==0&&(G(),he(r,s))}function Hn(){b&&oe(_(b.takeRecords()))}function Me(){let r=n.scope;return r&&r.ownerDocument||(typeof document<"u"?document:null)}function we(){let r=Me();return!r||!r.head||typeof r.head.querySelector!="function"?null:r.head.querySelector("title")}function ct(){let r=we();return r?r.textContent:null}function ft(r){let u=we();if(!u||r==null)return;let s=u.textContent;s!==r&&mt({kind:"value",target:u,prop:"textContent",oldValue:r,newValue:s})}function Jn(r){if(!r)return null;let u=Me();if(!u||r.target!==u||r.prop!=="title")return r;let s=we();return s?{kind:"value",target:s,prop:"textContent",oldValue:r.oldValue,newValue:r.newValue}:null}function Yn(){if(typeof window>"u")return!1;let r=window.clay?.effect||window.hyperclay?.effect;return!!(r&&r.running)}function Gn(){b&&Y(b.takeRecords()),X(),I={records:[],primitives:[]}}function Xn(){let r=I;if(I=null,!r)return[];let u=Te(r.records,!0);for(let s of Ie(_(r.records)))u.push(s);for(let s of r.primitives)u.push(s);return u}function pt(r,u,{honorPause:s,receipt:p}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(I)throw new Error("hyper-undo: command() cannot nest inside another command");if(B)throw new Error("hyper-undo: command() cannot run during undo or redo");if(Yn())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let k=s&&E>0,V=k?null:ct();Gn();let M=[],P=null,K;try{try{K=u()}catch(ie){P=ie}if(b&&Y(b.takeRecords()),K&&typeof K.then=="function"){try{K.then(void 0,()=>{})}catch{}P||(P=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}k||ft(V)}finally{M=Xn()}let F=k||M.length===0?null:he(r,M);if(P)throw P;return p?F?{id:F.id,label:F.label}:null:F}function Zn(r,u){if(!C)throw new Error("hyper-undo: scope not started");return pt(r,u,{honorPause:!1,receipt:!0})}function Qn(r){if(r!=="automatic"&&r!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(I)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return N===r||(X(),N=r,h("recording",r)),N}function gt(r){if(!C||!r||!I&&(E>0||N==="commands"))return;let u=Jn(r);u&&mt(u)}function mt(r){if(I){I.primitives.push(r);return}g.push(r),Oe()}function er(r,{prop:u="value",oldValue:s,newValue:p,read:k,write:V}={}){!r||s===p||gt({kind:"value",target:r,prop:u,oldValue:s,newValue:p,read:k,write:V})}function X(){E===0&&b&&Y(b.takeRecords()),g.length!==0&&(G(),Le())}function yt(){E===0&&b&&Y(b.takeRecords()),E++,h("paused",E)}function ht(){E!==0&&(E--,E===0&&b&&(ut(b.takeRecords()),H&&(H=!1,G(),Le())),h("resumed",E))}function bt(r,u){if(ye())return se(),{ok:!1,code:"disconnected"};if(typeof n.holdReplay=="function"&&n.holdReplay())return{ok:!1,code:"held"};X();let s=r==="undo"?o:a,p=r==="undo"?a:o,k=[],V=s.at(-1);if(!V)return{ok:!1,code:"empty"};if(u&&u!==V.id){let P=vt(u)||V;return je(P,r,"stale-entry")}let M=n.refused==="skip"&&!u;for(;V;){let P;B=!0;try{P=an(V.certificate,r,{isIgnored:be,ignoreAttribute:st,durableForm:n.durableForm,isProtected:Un,inScope:ur,liveNodesWithIds:lr})}finally{B=!1}if(!P.ok){if(!M)return je(V,r,P.code,P.targets);wt(V,r,P.code,P.targets,k),V=s.at(-1);continue}yt();let K;B=!0;try{K=mn(P.operations)}finally{B=!1,ht()}if(!K.ok){if(h(`${r} failed and was rolled back`,K.error),!M)return je(V,r,"replay-error");wt(V,r,"replay-error",[],k),V=s.at(-1);continue}oe(new Set(P.operations.filter(ie=>ie.type==="value"&&L.has(ie.target)).map(ie=>ie.target))),s.pop(),p.push(V),c=null;let F={ok:!0,entryId:V.id,label:V.label,direction:r};return k.length&&(F.skipped=k),K.caret&&(F.caret=K.caret),h(r,V.label),t.emit(r,F),F}return{ok:!1,code:"empty",direction:r,skipped:k}}function wt(r,u,s,p,k){c={entryId:r.id,direction:u,code:s,targets:p};let V=kt(r.id);(u==="undo"?o:a).pop(),c=null;let M={entryId:r.id,label:r.label,direction:u,code:s,targets:p,description:V};h("skipped",u,s),t.emit("skipped",M),k.push(M)}function tr(r){return bt("undo",r&&r.entryId)}function nr(r){return bt("redo",r&&r.entryId)}function vt(r){return o.find(u=>u.id===r)||a.find(u=>u.id===r)||null}function je(r,u,s,p=[]){return c={entryId:r.id,direction:u,code:s,targets:p},h("refused",u,s),t.emit("refused",{entryId:r.id,label:r.label,direction:u,code:s,targets:p}),{ok:!1,code:s,entryId:r.id,label:r.label,direction:u}}function rr(r){if(!c||c.entryId!==r)return{ok:!1,code:"not-refused",entryId:r};let u=c.direction,s=u==="undo"?o:a,p=s.at(-1);return!p||p.id!==r?{ok:!1,code:"stale-entry",entryId:r}:(s.pop(),c=null,h("discarded",p.label),t.emit("discard",{entryId:r,label:p.label,direction:u}),{ok:!0,entryId:r,direction:u})}function kt(r){let u=vt(r);if(!u||!u.certificate||!u.certificate.replayable)return null;let s=c&&c.entryId===u.id?{direction:c.direction,code:c.code,targets:(c.targets||[]).map(p=>({id:p.id??null,kind:p.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:s,steps:u.certificate.steps.map(ir)}}function or(r){return typeof r!="string"?null:r.replace(/#form:("(?:[^"\\]|\\.)*")/g,(u,s)=>{try{return JSON.parse(s)}catch{return""}})}function ir(r){if(r.type==="move")return{kind:"move",node:{id:D(r.node).id},from:{id:D(r.sourceParent).id},to:{id:D(r.destParent).id}};if(r.type==="add"||r.type==="restore")return{kind:r.type==="add"?"add":"remove",parent:{id:D(r.parent).id},nodes:r.nodes.map((V,M)=>({id:D(V).id,html:or(r.content[M])}))};let u=r.primitive,s={id:D(u.target).id},p=u.oldValue??null,k=u.newValue??null;return r.type==="value"?{kind:"value",target:s,prop:u.prop??"value",before:p,after:k}:r.type==="text"?{kind:"text",target:s,before:p,after:k}:r.type==="attr-set"||r.type==="attr-add"||r.type==="attr-remove"?{kind:"attribute",target:s,name:u.name??null,before:p,after:k}:{kind:r.type,target:s,before:p,after:k}}function ar(r){let u=new Set,s=!0;for(;s;){s=!1;for(let p of r)if(!(p.type!=="childList"||!p.removedNodes?.length)&&!re(p)&&!(!De(p.target)&&!At(p.target,u))&&!me(p.target,n.ignoreAttribute,p))for(let k of p.removedNodes)u.has(k)||(u.add(k),s=!0)}return p=>!De(p)&&At(p,u)}function At(r,u){for(let s=r;s;s=s.parentNode)if(u.has(s))return!0;return!1}function De(r){let u=n.scope;return!u||!r||typeof r.nodeType!="number"?!1:r===u||typeof u.contains=="function"&&u.contains(r)}function Et(r){let u=Me(),s=u&&u.head;if(!s||!r)return!1;let p=r.nodeType===1?r:r.parentElement;for(;p&&p!==s;p=p.parentElement)if(p.localName==="title")return!1;return p===s}function ur(r){let u=n.scope;return!r||!u?!1:r===u||we()===r||Et(r)?!0:typeof u.contains=="function"?u.contains(r):!1}function lr(r){let u=n.scope;if(!r||r.length===0||typeof u?.querySelectorAll!="function")return[];let s=new Set(r),p=[];for(let k of u.querySelectorAll("[data-id]"))s.has(k.getAttribute("data-id"))&&(be(k)||p.push(k));return p}function dr(){b&&oe(_(b.takeRecords())),o.length=0,a.length=0,g=[],c=null,G(),h("cleared"),t.emit("clear")}return{_config:n,_tracksContentAt:r=>N!=="commands"&&!!ne(r),_recordsAt:r=>N!=="commands"&&!be(r),start:T,stop:se,commit:_n,commitCaptured:Wn,discardCaptured:Hn,flush:X,command:Zn,setRecording:Qn,record:gt,recordValue:er,trackContent:Re,undo:tr,redo:nr,clear:dr,discard:rr,describe:kt,pause:yt,resume:ht,on:t.on,off:t.off,get canUndo(){return o.length>0},get canRedo(){return a.length>0},get isPaused(){return E>0},get history(){return o.map(r=>{let u={id:r.id,label:r.label,timestamp:r.timestamp};return c&&c.entryId===r.id&&(u.refused={direction:c.direction,code:c.code,targets:c.targets}),u})},get future(){return a.map(r=>{let u={id:r.id,label:r.label,timestamp:r.timestamp};return c&&c.entryId===r.id&&(u.refused={direction:c.direction,code:c.code,targets:c.targets}),u}).reverse()},get scope(){return n.scope}}}var jn=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function tt(e){let n=typeof e.composedPath=="function"?e.composedPath():[];return n.length>0?n:Kn(e.target)}function Dn(e){for(let n of tt(e)){if(!n||n.nodeType!==1)continue;let t=String(n.tagName||"").toUpperCase();if(t==="TEXTAREA"||t==="SELECT"||t==="INPUT"&&!jn.has(String(n.type||n.getAttribute?.("type")||"text").toLowerCase()))return!0}return!1}function nt(e){for(let n of tt(e)){if(!n||n.nodeType!==1)continue;if(n.isContentEditable===!0)return!0;let t=n.getAttribute&&n.getAttribute("contenteditable");if(t!=null&&String(t).toLowerCase()!=="false")return!0}return!1}function Ve(e,n){if(!e||!e.closest||!Array.isArray(n))return!1;for(let t of n)try{if(e.closest(t))return!0}catch{}return!1}function rt(e,n){if(Dn(e))return!0;let t=n._config,o=e.target;return t.editableKeys!=="page"?nt(e)||Ve(o,t.shadowKeydownIn):Ve(o,t.ownKeysIn)||n._tracksContentAt(o)?!1:Ve(o,t.shadowKeydownIn)?!0:nt(e)&&!n._recordsAt(o)}function Kn(e){let n=[];for(let t=e;t;t=t.parentNode||(t.host??null))n.push(t);return n}function qn(e,n){let t=i=>{let d=e.scope;if(d&&d.nodeType===1&&d.isConnected===!1){n&&n();return}if(i.defaultPrevented||i.isComposing||i.keyCode===229||rt(i,e)||!(i.metaKey||i.ctrlKey))return;let c=(i.key||"").toLowerCase();if(c==="z"&&!i.shiftKey){i.preventDefault(),i.stopPropagation(),e.undo();return}if(c==="z"&&i.shiftKey){i.preventDefault(),i.stopPropagation(),e.redo();return}if(c==="y"&&!i.shiftKey){i.preventDefault(),i.stopPropagation(),e.redo();return}},o=i=>{if(i.inputType!=="historyUndo"&&i.inputType!=="historyRedo")return;let d=e.scope;d&&d.nodeType===1&&d.isConnected===!1||i.defaultPrevented||i.isComposing||rt(i,e)||(i.preventDefault(),i.stopPropagation(),i.inputType==="historyRedo"?e.redo():e.undo())},a=e._config.editableKeys==="page";return window.addEventListener("keydown",t,!0),a&&window.addEventListener("beforeinput",o,!0),()=>{window.removeEventListener("keydown",t,!0),a&&window.removeEventListener("beforeinput",o,!0)}}var xe=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]",".ck-editor__editable","[data-lexical-editor]","[data-slate-editor]","trix-editor",".mce-content-body"],y=null,Ne=null,ot=null,U=null;function it(e,n){if(U){if(U.inst===e)return U.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=qn(e,n);return U={inst:e,cleanup:t},t}function at(e){U&&U.inst===e&&(U.cleanup(),U=null)}var Pe={defaults:{shadowKeydownIn:xe},start(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(y){if(Ne===n)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),y;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||xe};return y=et(t),y.start(),Ne=n,e.bindKeys!==!1&&(ot=it(y,()=>Pe.stop())),y},stop(){y&&(at(y),ot=null,y.stop(),y=null,Ne=null)},create(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||xe},o=et(t),a=null,i={_config:o._config,commit:o.commit,command:o.command,setRecording:o.setRecording,commitCaptured:o.commitCaptured,discardCaptured:o.discardCaptured,flush:o.flush,record:o.record,recordValue:o.recordValue,trackContent:o.trackContent,undo:o.undo,redo:o.redo,clear:o.clear,discard:o.discard,describe:o.describe,pause:o.pause,resume:o.resume,on:o.on,off:o.off,get canUndo(){return o.canUndo},get canRedo(){return o.canRedo},get isPaused(){return o.isPaused},get history(){return o.history},get future(){return o.future},get scope(){return o.scope},start(){e.bindKeys&&(a=it(o,()=>i.stop())),o.start()},stop(){at(o),a=null,o.stop()}};return i},commit(e,n){return y?y.commit(e,n):void 0},command(e,n){return y?y.command(e,n):void 0},setRecording(e){return y?y.setRecording(e):void 0},commitCaptured(e){return y?y.commitCaptured(e):void 0},discardCaptured(){return y?y.discardCaptured():void 0},record(e){return y?y.record(e):void 0},recordValue(e,n){return y?y.recordValue(e,n):void 0},trackContent(e,n){return y?y.trackContent(e,n):()=>{}},undo(e){return y?y.undo(e):void 0},redo(e){return y?y.redo(e):void 0},clear(){return y?y.clear():void 0},discard(e){return y?y.discard(e):void 0},describe(e){return y?y.describe(e):void 0},pause(){return y?y.pause():void 0},resume(){return y?y.resume():void 0},flush(){return y?y.flush():void 0},on(e,n){return y?y.on(e,n):void 0},off(e,n){return y?y.off(e,n):void 0},get canUndo(){return y?y.canUndo:!1},get canRedo(){return y?y.canRedo:!1},get history(){return y?y.history:[]},get future(){return y?y.future:[]},get isPaused(){return y?y.isPaused:!1}},$n=Pe;return O(q)})();window.__hyperclayNoAutoExport||(window.hyperclay=window.hyperclay||{},window.hyperclay.undo=Pt.undo,window.h=window.hyperclay);var w=Pt.undo;var jt='[contenteditable]:not([contenteditable="false"])';function sr(l,f){let m=Number(f)||0;m<0&&(m=0);let x=(l.ownerDocument||document).createTreeWalker(l,4),j=null;for(let O=x.nextNode();O;O=x.nextNode()){if(m<=O.data.length)return{node:O,offset:m};m-=O.data.length,j=O}return j?{node:j,offset:j.data.length}:{node:l,offset:l.childNodes.length}}function cr(l){let m=(l.nodeType===1?l:l.parentElement)?.closest?.(jt);return!m||!m.isConnected||typeof m.checkVisibility=="function"&&m.checkVisibility()===!1?null:m}function fr(l){if(!l)return;let f=l.root?sr(l.root,l.textOffset):l;if(!f?.node)return;let m=cr(f.node);m&&(typeof m.scrollIntoView=="function"&&m.scrollIntoView({block:"nearest",inline:"nearest"}),document.activeElement?.closest?.(jt)&&(document.activeElement!==m&&m.focus({preventScroll:!0}),document.getSelection()?.collapse(f.node,f.offset)))}var qe=new Set,$e=new Set,Dt=(l,f=null)=>{for(let m of $e){let A=m(l,f);if(typeof A=="string")return A}},Kt=(l={})=>{let f=l.ignoreAttribute;return{...l,ignoreAttribute:(m,A,x)=>qe.has(m)||St(m,A)||Vt(A,m,x)||xt(m,A)||(f?f(m,A,x):!1),isProtected:l.isProtected||pr,ignoreNode:l.ignoreNode||Nt,durableForm:l.durableForm||Dt}};function pr(l){let f=window.clay?.region?.resolveRegionPolicy;if(!f||l.nodeType!==1||Dt(l)!==void 0)return!1;let m=f(l);if(m.undoable!==!1||m.persist==="none")return!1;let A=l.parentElement;return!A||f(A).undoable!==!1}var gr=w.create.bind(w);w.create=l=>gr(Kt(l));var fe=null,mr=w.setRecording.bind(w);w.setRecording=l=>(fe=l??null,document.dispatchEvent(new CustomEvent("clay:undo-recording",{detail:{mode:fe}})),mr(l));Object.defineProperty(w,"recordingMode",{get:()=>fe,configurable:!0});var Rt=()=>w.history.at(-1)?.id??null,qt=w.command.bind(w);w.command=(l,f)=>{let m=qt(l,f);return m&&ke(),m};w.recordStep=(l,f)=>qt(l,()=>w.record(f));var $t=l=>!!l?.steps?.length&&l.steps.every(f=>f.kind==="value"&&/^blockeditor-step(?::|$)/.test(f.prop)),yr=w.commit.bind(w),It=!1;w.commit=(l,f)=>{!It&&window.clay?.effect?.running&&(It=!0,console.warn(`clay.effect: undo.commit("${l}") was called inside an effect. Run commands from event handlers, not from an effect.`));let m=Rt(),A=yr(l,f);return(A||Rt()!==m)&&ke(),A};var hr=`input${ve}:not([type="password"]):not([type="hidden"]):not([type="file"]), textarea${ve}, select${ve}`;function br(){let l=f=>window.clay?.region?.resolveRegionPolicy?.(f)?.undoable!==!1;document.querySelectorAll(hr).forEach(f=>{if(!l(f))return;if(f.tagName==="SELECT"){for(let q of f.options){let pe=q.hasAttribute("selected");q.selected!==pe&&(q.selected=pe)}return}let m=(f.getAttribute("type")||"text").toLowerCase();if(f.tagName==="INPUT"&&(m==="checkbox"||m==="radio")){let q=f.hasAttribute("checked");f.checked!==q&&(f.checked=q);return}let A=f.tagName==="TEXTAREA"?f.getAttribute("data-value")??f.textContent:f.getAttribute("value")??"";if(f.value===A)return;let x=f===document.activeElement,j,O;try{j=f.selectionStart,O=f.selectionEnd}catch{}if(f.value=A,x&&j!=null)try{f.setSelectionRange(Math.min(j,A.length),Math.min(O,A.length))}catch{}})}var Tt=l=>{l?.ok&&($t(w.describe(l.entryId))||ke(),br(),l.caret&&w.pageHistory&&fr(l.caret))},Ot=({entryId:l,label:f,direction:m,code:A})=>{document.dispatchEvent(new CustomEvent("clay:undo-refused",{detail:{ok:!1,code:A,entryId:l,label:f,direction:m}})),zt({ok:!1,code:A,entryId:l,label:f,direction:m})},Lt=({entryId:l,label:f,direction:m,code:A,description:x})=>{document.dispatchEvent(new CustomEvent("clay:undo-skipped",{detail:{entryId:l,label:f,direction:m,code:A}})),!$t(x)&&zt({ok:!1,code:A,entryId:l,label:f,direction:m,description:x})},Ke=null;function Bt(){return Ke??=import("../c-MIQYK2VM.js").catch(l=>(Ke=null,console.error("clayjs: the undo recovery module could not be downloaded; a refused step stays in this tab only",l),null)),Ke}async function zt(l){let f={ok:!1,code:"unavailable"};try{let A=await Bt();A&&(f=await A.keepRefusal(w,l))}catch{f={ok:!1,code:"error"}}let m=f?.ok===!0?{ok:!0,entryId:l.entryId,direction:l.direction}:{ok:!1,code:f?.code||"error",entryId:l.entryId,direction:l.direction};document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:m}))}var ze=(l,f)=>(...m)=>Bt().then(A=>A?A[l](...m):f,()=>f),wr=ze("keep",{ok:!1,code:"unavailable"});w.addDurableForm=l=>($e.add(l),()=>{$e.delete(l)});w.ignoreAttribute=l=>{let f=String(l||"");return f?(qe.add(f),()=>{qe.delete(f)}):()=>{}};w.keep=async l=>{let f=await wr(l);return f?.ok===!0&&document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:{ok:!0,key:l?.key==null?null:`app:${l.key}`}})),f};w.kept=ze("kept",{ok:!1,code:"unavailable",records:[]});w.dismissKept=ze("dismissKept",{ok:!1,code:"unavailable"});var Be=new Set;w.reviewActions=l=>typeof l!="function"?()=>{}:(Be.add(l),()=>{Be.delete(l)});w.reviewActionsFor=l=>{let f=[];for(let m of Be){let A;try{A=m(l)}catch(x){console.error("clayjs: a review action could not describe itself; the copy stays reviewable",x);continue}for(let x of Array.isArray(A)?A:[])x&&typeof x.run=="function"&&x.label&&f.push(x)}return f};var vr=["commit","undo","redo","refused","skipped","discard","clear"],ue=new Set,Ft=l=>{for(let f=w;f;f=Object.getPrototypeOf(f)){let m=Object.getOwnPropertyDescriptor(f,l);if(m)return typeof m.get=="function"?()=>m.get.call(w):()=>!!m.value.call(w)}return()=>!1},kr=Ft("canUndo"),Ar=Ft("canRedo");Object.defineProperty(w,"canUndo",{get:()=>ue.size===0&&kr(),configurable:!0});Object.defineProperty(w,"canRedo",{get:()=>ue.size===0&&Ar(),configurable:!0});w.hold=()=>{let l=Symbol("hold");ue.add(l),ae();let f=!1;return()=>{f||(f=!0,ue.delete(l),ae())}};var ae=()=>{let l=!!Z?.started&&ue.size===0;document.dispatchEvent(new CustomEvent("clay:undo-change",{detail:{canUndo:l&&w.canUndo,canRedo:l&&w.canRedo,undo:l&&w.history.at(-1)||null,redo:l&&w.future?.[0]||null}}))},Z=null;Object.defineProperty(w,"pageHistory",{get:()=>!!Z?.started,configurable:!0});var Mt=()=>{typeof document>"u"||document.dispatchEvent(new CustomEvent("clay:undo-session",{detail:{started:!!Z?.started,pageHistory:w.pageHistory}}))};function Er(){return{started:!1,admitted:!1,subscriptions:[]}}var Sr=l=>l?l.signal?.aborted?!0:typeof l.isCurrent=="function"&&!l.isCurrent():!1;function Cr(){return typeof document>"u"||document.readyState!=="loading"?Promise.resolve():new Promise(l=>document.addEventListener("DOMContentLoaded",l,{once:!0}))}function Vr(l){return{enable(){if(!l.started){l.started=!0,l.admitted=!0,w.start(Kt({bindKeys:!0,editableKeys:"page",ownKeysIn:[".blockeditor-editor"],typingBreak:"sentence",refused:"skip",holdReplay:()=>ue.size>0,...fe?{recording:fe}:{}}));for(let f of["undo","redo"])w.on(f,Tt),l.subscriptions.push({type:f,handler:Tt});w.on("refused",Ot),l.subscriptions.push({type:"refused",handler:Ot}),w.on("skipped",Lt),l.subscriptions.push({type:"skipped",handler:Lt});for(let f of vr)w.on(f,ae),l.subscriptions.push({type:f,handler:ae});ae(),Mt()}},quiesce(){l.admitted&&(l.admitted=!1,w.pause())},resume(){l.admitted||(l.admitted=!0,w.resume())},dispose(){if(l.admitted=!1,Z===l&&(Z=null),!!l.started){l.started=!1;for(let{type:f,handler:m}of l.subscriptions.splice(0))w.off(f,m);w.stop(),ae(),Mt()}}}}function xr(){return{id:"clay:undo",order:350,async prepare(l={}){if(l.initial===!0)return Nr();if(await Cr(),Sr(l))throw Object.assign(new Error("clay:undo prepared for a stale generation"),{code:"stale-document"});return Vr(Z||(Z=Er()))}}}async function Nr(){let l=await Rr;return{enable(){},quiesce:()=>l?.quiesce(),resume:()=>l?.resume(),dispose:()=>l?.dispose()}}async function Pr(){if(!Ct()||typeof document>"u")return null;let l=await xr().prepare();return l.enable(),l}var Rr=Pr();var Br=w;export{Br as default,Pr as init,xr as modeParticipant,Rr as ready,br as restoreControls,w as undo,xr as undoParticipant};
@@ -1 +1 @@
1
- import{a as f,b as v}from"../c-3G2DGZUP.js";import"../c-VHNSBD2M.js";var $="hha:upgrade-check:",M=1440*60*1e3,S="upgrade-dismissed",P="A new version of this template is available.";function b(e,t){let n=e.querySelector(`meta[name="${t}"]`),r=n?n.getAttribute("content"):null;return r&&r.trim()?r.trim():null}function T(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function j(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function x(e){let t=globalThis.crypto&&globalThis.crypto.subtle;if(!t)return null;let n=await t.digest("SHA-256",e);return[...new Uint8Array(n)].map(r=>r.toString(16).padStart(2,"0")).join("")}async function L(e,t){try{let n=await e(t,{credentials:"omit"});return n.ok?n:null}catch{return null}}async function N(e,t,{fetchFn:n,now:r}){let o=new URL(e);o.pathname=o.pathname.replace(/\.html$/,".json");let a=`${$}${o.href}:${t}`,u=T(a);if(u&&typeof u.checkedAt=="number"&&r-u.checkedAt<M)return{latest:u.latest,latestUrl:o};let i=await L(n,o.href);if(!i)return{latest:null,latestUrl:o};let c=null;try{c=await i.json()}catch{return{latest:null,latestUrl:o}}return j(a,{checkedAt:r,latest:c}),{latest:c,latestUrl:o}}function A({doc:e,loc:t}){let n=typeof window<"u"&&window.clay||{};if(!n.canEdit||n.isDraftMode)return null;let r=b(e,"hyper-source"),o=b(e,"hyper-version");if(!r||!o)return null;let a;try{a=new URL(r,t?t.href:void 0)}catch{return null}return!a.pathname.endsWith(".html")||t&&a.origin===t.origin&&a.pathname===t.pathname?null:{source:a,currentVersion:o}}async function C({doc:e=document,loc:t=location,fetchFn:n=(o,a)=>fetch(o,a),now:r=Date.now()}={}){let o=A({doc:e,loc:t});if(!o)return{status:"none",version:null,update:null};let{source:a,currentVersion:u}=o,i=(R,V=null)=>({status:R,version:u,update:V}),c=new URL(a.href);c.pathname=c.pathname.replace(/\.html$/,".json");let{latest:s}=await N(a.href,u,{fetchFn:n,now:r});if(!s||typeof s!="object"||typeof s.version!="string"||!f(s.version)||!f(u))return i("unknown");if(!v(s.version,u))return i("current");let h=typeof window<"u"&&window.clay||{},w=h.storage&&h.storage.local;if(w&&w.get(S)===s.version||typeof s.html!="string"||!s.html)return i("unknown");let m=new URL(s.html,c).href,y=await L(n,m);if(!y)return i("unknown");let g;try{g=await y.arrayBuffer()}catch{return i("unknown")}let d=await x(g);return!d||d!==String(s.sha256||"").toLowerCase()?i("unknown"):i("update",{version:s.version,html:m,sha256:d,latestUrl:c.href})}async function H(e){return(await C(e)).update}async function k(e,t){let n=window.clay;if(await I(n),!p(n)||!t)return;let r=e==="current"?"File at latest version":`Version ${t}`;n.menu.addItem({id:"upgrade",label:r,text:!0})}function O(e){let t=window.clay,n=t&&t.storage&&t.storage.local;n&&n.set(S,e)}function D(e){return!!(e&&Array.isArray(e.plugins)&&e.plugins.includes("menu"))}function p(e){return!!(e&&e.menu&&typeof e.menu.addItem=="function")}function I(e){return p(e)||!D(e)?Promise.resolve():new Promise(t=>{let n=r=>{!r.detail||r.detail.plugin!=="menu"||(document.removeEventListener("clay:plugin-ready",n),document.removeEventListener("clay:plugin-failed",n),t())};document.addEventListener("clay:plugin-ready",n),document.addEventListener("clay:plugin-failed",n)})}async function q(e,t=typeof window<"u"?window.clay:null){let n=()=>document.dispatchEvent(new CustomEvent("clay:upgrade-requested",{detail:e}));return await I(t),p(t)?(t.menu.addItem({id:"upgrade",label:`Upgrade to version ${e.version}`,badge:!0,run:n}),"menu"):t&&typeof t.toastPersistent=="function"?(t.toastPersistent(P,"info",{actions:[{label:"Upgrade",onClick:n},{label:"Not now",onClick:()=>O(e.version)}]}),"notice"):null}var U=!1;async function E(e={}){if(U)return null;U=!0;let t=window.clay;await Promise.resolve(t&&t.loaded&&t.loaded.ui).catch(()=>{});let n=A({doc:e.doc||document,loc:e.loc||location});n&&k("checking",n.currentVersion);let{status:r,version:o,update:a}=await C(e).catch(()=>({status:"unknown",version:n&&n.currentVersion,update:null}));return a?(await q(a),a):(r!=="none"&&await k(r,o),null)}async function J(e,t){return(await import("../c-Y3MPVURA.js")).replace(e,t)}function B(e){import("../c-VU4WEWPH.js").then(t=>t.start(e.detail)).catch(t=>console.error("clayjs: the upgrade could not start:",t))}var l=typeof window<"u"?window.clay:null;if(l&&l.canEdit&&!l.isDraftMode){document.addEventListener("clay:upgrade-requested",B);let e=l.ready;e&&typeof e.then=="function"?e.then(()=>E(),()=>{}):E()}export{q as announce,C as checkUpdate,H as findUpdate,J as replace,E as start};
1
+ import{a as f,b as v}from"../c-3G2DGZUP.js";import"../c-VHNSBD2M.js";var $="hha:upgrade-check:",M=1440*60*1e3,S="upgrade-dismissed",P="A new version of this template is available.";function b(e,t){let n=e.querySelector(`meta[name="${t}"]`),r=n?n.getAttribute("content"):null;return r&&r.trim()?r.trim():null}function T(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function j(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function x(e){let t=globalThis.crypto&&globalThis.crypto.subtle;if(!t)return null;let n=await t.digest("SHA-256",e);return[...new Uint8Array(n)].map(r=>r.toString(16).padStart(2,"0")).join("")}async function L(e,t){try{let n=await e(t,{credentials:"omit"});return n.ok?n:null}catch{return null}}async function N(e,t,{fetchFn:n,now:r}){let o=new URL(e);o.pathname=o.pathname.replace(/\.html$/,".json");let a=`${$}${o.href}:${t}`,u=T(a);if(u&&typeof u.checkedAt=="number"&&r-u.checkedAt<M)return{latest:u.latest,latestUrl:o};let i=await L(n,o.href);if(!i)return{latest:null,latestUrl:o};let c=null;try{c=await i.json()}catch{return{latest:null,latestUrl:o}}return j(a,{checkedAt:r,latest:c}),{latest:c,latestUrl:o}}function A({doc:e,loc:t}){let n=typeof window<"u"&&window.clay||{};if(!n.canEdit||n.isDraftMode)return null;let r=b(e,"hyper-source"),o=b(e,"hyper-version");if(!r||!o)return null;let a;try{a=new URL(r,t?t.href:void 0)}catch{return null}return!a.pathname.endsWith(".html")||t&&a.origin===t.origin&&a.pathname===t.pathname?null:{source:a,currentVersion:o}}async function C({doc:e=document,loc:t=location,fetchFn:n=(o,a)=>fetch(o,a),now:r=Date.now()}={}){let o=A({doc:e,loc:t});if(!o)return{status:"none",version:null,update:null};let{source:a,currentVersion:u}=o,i=(R,V=null)=>({status:R,version:u,update:V}),c=new URL(a.href);c.pathname=c.pathname.replace(/\.html$/,".json");let{latest:s}=await N(a.href,u,{fetchFn:n,now:r});if(!s||typeof s!="object"||typeof s.version!="string"||!f(s.version)||!f(u))return i("unknown");if(!v(s.version,u))return i("current");let h=typeof window<"u"&&window.clay||{},w=h.storage&&h.storage.local;if(w&&w.get(S)===s.version||typeof s.html!="string"||!s.html)return i("unknown");let m=new URL(s.html,c).href,y=await L(n,m);if(!y)return i("unknown");let g;try{g=await y.arrayBuffer()}catch{return i("unknown")}let d=await x(g);return!d||d!==String(s.sha256||"").toLowerCase()?i("unknown"):i("update",{version:s.version,html:m,sha256:d,latestUrl:c.href})}async function H(e){return(await C(e)).update}async function k(e,t){let n=window.clay;if(await I(n),!p(n)||!t)return;let r=e==="current"?"File at latest version":`Version ${t}`;n.menu.addItem({id:"upgrade",label:r,text:!0})}function O(e){let t=window.clay,n=t&&t.storage&&t.storage.local;n&&n.set(S,e)}function D(e){return!!(e&&Array.isArray(e.plugins)&&e.plugins.includes("menu"))}function p(e){return!!(e&&e.menu&&typeof e.menu.addItem=="function")}function I(e){return p(e)||!D(e)?Promise.resolve():new Promise(t=>{let n=r=>{!r.detail||r.detail.plugin!=="menu"||(document.removeEventListener("clay:plugin-ready",n),document.removeEventListener("clay:plugin-failed",n),t())};document.addEventListener("clay:plugin-ready",n),document.addEventListener("clay:plugin-failed",n)})}async function q(e,t=typeof window<"u"?window.clay:null){let n=()=>document.dispatchEvent(new CustomEvent("clay:upgrade-requested",{detail:e}));return await I(t),p(t)?(t.menu.addItem({id:"upgrade",label:`Upgrade to version ${e.version}`,badge:!0,run:n}),"menu"):t&&typeof t.toastPersistent=="function"?(t.toastPersistent(P,"info",{actions:[{label:"Upgrade",onClick:n},{label:"Not now",onClick:()=>O(e.version)}]}),"notice"):null}var U=!1;async function E(e={}){if(U)return null;U=!0;let t=window.clay;await Promise.resolve(t&&t.loaded&&t.loaded.ui).catch(()=>{});let n=A({doc:e.doc||document,loc:e.loc||location});n&&k("checking",n.currentVersion);let{status:r,version:o,update:a}=await C(e).catch(()=>({status:"unknown",version:n&&n.currentVersion,update:null}));return a?(await q(a),a):(r!=="none"&&await k(r,o),null)}async function J(e,t){return(await import("../c-IJ4VUYDN.js")).replace(e,t)}function B(e){import("../c-H25R2UF3.js").then(t=>t.start(e.detail)).catch(t=>console.error("clayjs: the upgrade could not start:",t))}var l=typeof window<"u"?window.clay:null;if(l&&l.canEdit&&!l.isDraftMode){document.addEventListener("clay:upgrade-requested",B);let e=l.ready;e&&typeof e.then=="function"?e.then(()=>E(),()=>{}):E()}export{q as announce,C as checkUpdate,H as findUpdate,J as replace,E as start};
@@ -1 +1 @@
1
- import{b as r,c as p,d as n,e as u}from"../c-EAV7A6BT.js";import"../c-I2SCCUEW.js";import"../c-EQ5NBOGA.js";import"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function o(a,{requiredAccess:t,...i}={}){return r(t),p(a,{...i,requiredAccess:t})}o.mount=async(a,t)=>(await import("../c-HXGNH6GY.js")).mount(a,t);o.start=n;var c=o;export{c as default,u as modeParticipant,o as upload};
1
+ import{b as r,c as p,d as n,e as u}from"../c-MB5FZ2PD.js";import"../c-I2SCCUEW.js";import"../c-26W3BMWK.js";import"../c-JEWSJHMK.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function o(a,{requiredAccess:t,...i}={}){return r(t),p(a,{...i,requiredAccess:t})}o.mount=async(a,t)=>(await import("../c-IPCSVZAB.js")).mount(a,t);o.start=n;var c=o;export{c as default,u as modeParticipant,o as upload};