@panphora/clayjs 1.20.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) 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 +7865 -8022
  11. package/dist/m/{c-JOH753EJ.js → c-26KVJS6J.js} +1 -1
  12. package/dist/m/{c-ZE46QDIH.js → c-3TLG3OLG.js} +1 -1
  13. package/dist/m/{c-RT3C74GY.js → c-4OGEVKR3.js} +1 -1
  14. package/dist/m/{c-Y33LUUIQ.js → c-4PHDUV3H.js} +1 -1
  15. package/dist/m/{c-SJPD46ZO.js → c-4RFZROCF.js} +4 -4
  16. package/dist/m/{c-XQSXKIKM.js → c-4TWARTLS.js} +1 -1
  17. package/dist/m/{c-S5IEIZCN.js → c-5AQYL27I.js} +1 -1
  18. package/dist/m/{c-OJYM642Q.js → c-5FKRZNJV.js} +1 -1
  19. package/dist/m/{c-CJFDLD43.js → c-6KBKYLPO.js} +1 -1
  20. package/dist/m/{c-DHXPDLW6.js → c-6PBXRWDX.js} +1 -1
  21. package/dist/m/{c-BRLCTNMC.js → c-6RC66MYY.js} +1 -1
  22. package/dist/m/{c-PIVIYLTY.js → c-6UEFPHHE.js} +1 -1
  23. package/dist/m/{c-YQUJ74R3.js → c-BV6FQQXM.js} +1 -1
  24. package/dist/m/{c-YSB6JKV2.js → c-DEAFCHDO.js} +2 -2
  25. package/dist/m/{c-NLZ5AN4L.js → c-DKFSOJCV.js} +1 -1
  26. package/dist/m/c-DP4X4JID.js +1 -0
  27. package/dist/m/{c-LIBE4HPD.js → c-DZBZ57EE.js} +1 -1
  28. package/dist/m/c-ECY5AZMH.js +1 -0
  29. package/dist/m/{c-VAK7SG37.js → c-EUGJVHDD.js} +1 -1
  30. package/dist/m/{c-GPGYKER7.js → c-F5AER2ID.js} +1 -1
  31. package/dist/m/{c-RG6XUZFA.js → c-FAXQU7MQ.js} +1 -1
  32. package/dist/m/{c-XD5MOROJ.js → c-FLBUYV3P.js} +1 -1
  33. package/dist/m/{c-NFR673TL.js → c-FMCPQ4VT.js} +2 -2
  34. package/dist/m/{c-VBLFAQD2.js → c-FNIGX4FI.js} +1 -1
  35. package/dist/m/{c-BTLFLLML.js → c-FWFJUU3T.js} +1 -1
  36. package/dist/m/{c-2VB555FG.js → c-GPTKI7AQ.js} +1 -1
  37. package/dist/m/{c-EZ7B5AZT.js → c-GY4ODHO2.js} +1 -1
  38. package/dist/m/{c-5734MF2P.js → c-H6DXQEH2.js} +1 -1
  39. package/dist/m/{c-Z32V4MHK.js → c-HAVGDXAL.js} +1 -1
  40. package/dist/m/{c-D3E4WJ4M.js → c-HDWZEJHM.js} +49 -32
  41. package/dist/m/{c-W23KVGUO.js → c-HWR6GMGK.js} +1 -1
  42. package/dist/m/{c-BJ7YQ5QZ.js → c-IHUWUKIU.js} +1 -1
  43. package/dist/m/{c-AL4RBJF2.js → c-ILGQ3UXQ.js} +1 -1
  44. package/dist/m/{c-W3K23S72.js → c-IWTTOC2V.js} +1 -1
  45. package/dist/m/c-JFST6QE7.js +1 -0
  46. package/dist/m/{c-FNVQAACK.js → c-KE33W4RE.js} +1 -1
  47. package/dist/m/c-KV7R47FR.js +1 -0
  48. package/dist/m/{c-LPUJXRXW.js → c-L7K5EXU2.js} +1 -1
  49. package/dist/m/{c-3YH6JSIL.js → c-LF6HNVPU.js} +1 -1
  50. package/dist/m/{c-MIL4B2JQ.js → c-MRURHLKV.js} +1 -1
  51. package/dist/m/{c-LQU7TXIH.js → c-N33TPVTL.js} +1 -1
  52. package/dist/m/{c-EOCZ2YVL.js → c-NBNRLZXO.js} +1 -1
  53. package/dist/m/{c-JUE7B4OX.js → c-NLWEZYKJ.js} +1 -1
  54. package/dist/m/{c-DDDOKPI6.js → c-NNNR7OXA.js} +1 -1
  55. package/dist/m/{c-E4IBSAQM.js → c-OI2BYWVV.js} +1 -1
  56. package/dist/m/{c-SBSMJIPC.js → c-P3WATEDR.js} +1 -1
  57. package/dist/m/{c-ZJLU56DV.js → c-PCEMXY2K.js} +1 -1
  58. package/dist/m/{c-3GJ4XARY.js → c-PWBJVHA4.js} +1 -1
  59. package/dist/m/{c-67ILSNPR.js → c-Q5KAQJAG.js} +1 -1
  60. package/dist/m/{c-U5X57T4L.js → c-QHVCUTJV.js} +1 -1
  61. package/dist/m/{c-GKEATME6.js → c-QJFYVCJO.js} +1 -1
  62. package/dist/m/{c-VY6XRBOW.js → c-QTC6VGA4.js} +1 -1
  63. package/dist/m/{c-44B5ODN7.js → c-TMT5TL65.js} +2 -2
  64. package/dist/m/{c-OABVRYOT.js → c-TV7JHSRL.js} +1 -1
  65. package/dist/m/{c-SO63UGPQ.js → c-UWT4CXQ4.js} +1 -1
  66. package/dist/m/{c-EFD6QNTE.js → c-VFES2BP5.js} +1 -1
  67. package/dist/m/{c-UXEVJ63W.js → c-VIW5X35H.js} +1 -1
  68. package/dist/m/{c-EOCKLMKX.js → c-WWE67K5Y.js} +1 -1
  69. package/dist/m/{c-J3BXFTZS.js → c-XDVAZDUE.js} +1 -1
  70. package/dist/m/{c-K76AUL4I.js → c-XZJ5IK6Q.js} +1 -1
  71. package/dist/m/{c-2ZZBC45O.js → c-Z7RJANGO.js} +1 -1
  72. package/dist/m/{c-I2IFKJX2.js → c-ZAHTFCXQ.js} +1 -1
  73. package/dist/m/{c-GVPNDIKJ.js → c-ZKELCT4T.js} +1 -1
  74. package/dist/m/{c-7SXYQCN4.js → c-ZO6VL2SC.js} +1 -1
  75. package/dist/m/{c-M4FSPNQ2.js → c-ZYEJLZEY.js} +1 -1
  76. package/dist/m/core/{autosave-VPORYJSE.js → autosave-GI3WNJYN.js} +1 -1
  77. package/dist/m/core/{conflict-notice-JMAZLVRX.js → conflict-notice-CEI3XY6A.js} +1 -1
  78. package/dist/m/core/{save-AOJBDSOK.js → save-OJ5NSLS7.js} +1 -1
  79. package/dist/m/core/{save-core-IOCMXO5L.js → save-core-DX3RFVO3.js} +1 -1
  80. package/dist/m/core/{unsaved-warning-U5VUJFOE.js → unsaved-warning-HGYH7O4H.js} +1 -1
  81. package/dist/m/internals/{index-HDRANDWE.js → index-V4WC44FU.js} +1 -1
  82. package/dist/m/loader-V6VI46HU.js +1 -0
  83. package/dist/m/{manifest-3AEF5191.js → manifest-83C18DED.js} +1 -1
  84. package/dist/m/{manifest-edit-29A26F22.js → manifest-edit-B28C1985.js} +1 -1
  85. package/dist/m/manifest.json +567 -567
  86. package/dist/m/page/{editor-EY2WAAGB.js → editor-BQEPCJLG.js} +2 -2
  87. package/dist/m/plugins/ai-edit-45A2J6LC.js +6 -0
  88. package/dist/m/plugins/cms-IFTKWF4S.js +2235 -0
  89. package/dist/m/plugins/{derive-FRE5JJQE.js → derive-QVI3LI3A.js} +1 -1
  90. package/dist/m/plugins/{indicator-4VDXWYTD.js → indicator-IPZJ35K6.js} +1 -1
  91. package/dist/m/plugins/{live-5EZN2EYP.js → live-GPQXSXSM.js} +1 -1
  92. package/dist/m/plugins/menu-UN3KRCOF.js +1 -0
  93. package/dist/m/plugins/{page-LVW5DWA4.js → page-BAVLWCP6.js} +2 -2
  94. package/dist/m/plugins/{page-view-5KQ76IJB.js → page-view-P3UGJFDZ.js} +1 -1
  95. package/dist/m/plugins/{people-C7TVBBMR.js → people-Z4RGVQAV.js} +1 -1
  96. package/dist/m/plugins/{quickcrop-BQ5YYFCH.js → quickcrop-E34PUYA3.js} +2 -2
  97. package/dist/m/plugins/{richclay-KLGETK77.js → richclay-S4NVJYIK.js} +2 -2
  98. package/dist/m/plugins/{source-CCEUM3OR.js → source-KVN6YNTY.js} +1 -1
  99. package/dist/m/plugins/{upgrade-NW556WJD.js → upgrade-KTSICB22.js} +1 -1
  100. package/dist/m/plugins/{wire-VRYPY6EJ.js → wire-SYVIBNSE.js} +1 -1
  101. package/dist/m/{reader-core-2GXY7SHY.js → reader-core-RUIFH32Y.js} +2 -2
  102. package/dist/m/sync/{live-sync-SKPMFYOO.js → live-sync-RGQMMWK2.js} +1 -1
  103. package/dist/m/ui/{index-QNIPDHXQ.js → index-EZGLEM5P.js} +1 -1
  104. package/dist/m/vendor/{sap-core.vendor-RN4ZVY4X.js → sap-core.vendor-OA5SKL7Q.js} +1 -1
  105. package/dist/offline-manifest.json +463 -469
  106. package/docs/guide.md +16 -8
  107. package/entries/sap.js +1 -1
  108. package/package.json +2 -2
  109. package/src/loader-logic.js +4 -1
  110. package/src/plugins/ai-edit.js +6 -17
  111. package/src/plugins/cms.js +3 -6
  112. package/src/plugins/menu/style.js +59 -31
  113. package/src/plugins/menu.js +131 -28
  114. package/src/ui/bevel.js +1 -1
  115. package/src/ui/skins/cms.js +1 -1
  116. package/src/ui/skins/quickcrop.js +1 -1
  117. package/src/ui/skins/richclay.js +1 -1
  118. package/src/vendor/hypercms.vendor.js +16 -69
  119. package/src/vendor/sap-core.vendor.js +1 -1
  120. package/dist/m/c-FSWRGBVQ.js +0 -1
  121. package/dist/m/c-HMYWIHFG.js +0 -1
  122. package/dist/m/c-M6FNQCTQ.js +0 -1
  123. package/dist/m/c-WFMRX5RZ.js +0 -1
  124. package/dist/m/loader-DZZLUBVB.js +0 -1
  125. package/dist/m/plugins/ai-edit-J5VLSW5I.js +0 -6
  126. package/dist/m/plugins/cms-LRAOZHT7.js +0 -2293
  127. package/dist/m/plugins/menu-KGWKT6CS.js +0 -1
  128. package/src/ui/skins/cms-toggle.js +0 -15
  129. /package/dist/m/plugins/{quickcrop-BQ5YYFCH.js.LEGAL.txt → quickcrop-E34PUYA3.js.LEGAL.txt} +0 -0
  130. /package/dist/m/plugins/{richclay-KLGETK77.js.LEGAL.txt → richclay-S4NVJYIK.js.LEGAL.txt} +0 -0
@@ -1,3 +1,3 @@
1
- import{a as G}from"./c-S5IEIZCN.js";import{b as J}from"./c-3G2DGZUP.js";import{o as z,p as _}from"./c-GVPNDIKJ.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import{a as F}from"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var Ce=Object.defineProperty,Le=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},je=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Me=new Set(je),Ue=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Ie=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Y=new Set(["checked","selected","disabled","readOnly","paused"]);function Pe(e,t){return t==null?Y.has(e)?!1:"":Y.has(e)?t==="false"?!1:!!t:t}var De={};Le(De,{EmptyListInsert:()=>R,MAX_RULE_DEPTH:()=>j,MaxRuleDepthExceeded:()=>V,NoRulesTag:()=>We,RuleTargetReadOnly:()=>fe,RulesParseError:()=>se,ShapeMismatch:()=>ce,UnknownRulesVersion:()=>ue,WriteNotRoundTripped:()=>He,WriteRefused:()=>Be,WriteRejected:()=>Ve});var se=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},ue=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=e}},j=20,V=class extends Error{constructor(e){super(`rule depth exceeded ${j} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},ce=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},R=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},fe=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Be=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function qe(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var He=class extends Error{constructor(e){super(`write did not round-trip at "${qe(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},We=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},Ve=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}};function de(e){let t=0,r=null,l=-1;for(let n=0;n<e.length;n++){let o=e[n];o==="\\"?n++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(l=n)}return l}function pe(e){let t=0,r=null,l=-1,n=!1;for(let o=0;o<e.length;o++){let i=e[o];i==="\\"?o++:r?i===r&&(r=null):i==='"'||i==="'"?r=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?l=o:t===0&&i===","&&(n=!0)}return n||l===-1||!Fe(e,l+1)?null:e.slice(0,l).trim()||null}function Fe(e,t){let r=t,l=e.replace(/\s+$/,"").length;for(;r<l&&/\s/.test(e[r]);)r++;let n=0,o=null;for(;r<l;r++){let i=e[r];if(i==="\\")r++;else if(o)i===o&&(o=null);else if(i==='"'||i==="'")o=i;else if(i==="["||i==="(")n++;else if(i==="]"||i===")")n>0&&n--;else if(n===0&&(i==="+"||i==="~"||/\s/.test(i)))return!1}return!0}var ze=/^--[A-Za-z0-9_-]+$/;function he(e){return typeof e=="string"&&ze.test(e)}function me(e){let t=[],r=[],l=null,n=0;for(let o=0;o<e.length;o++){let i=e[o];if(l){i==="\\"?o++:i===l&&(l=null);continue}if(i==="/"&&e[o+1]==="*"){let a=e.indexOf("*/",o+2);o=a===-1?e.length:a+1;continue}i==='"'||i==="'"?l=i:i==="("?r.push(")"):i==="["?r.push("]"):i==="{"?r.push("}"):(i===")"||i==="]"||i==="}")&&r[r.length-1]===i?r.pop():i===";"&&r.length===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t}function _e(e){let t="",r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){t+=n,n==="\\"&&l+1<e.length?t+=e[++l]:n===r&&(r=null);continue}if(n==="/"&&e[l+1]==="*"){let o=e.indexOf("*/",l+2);l=o===-1?e.length:o+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function ye(e){e=_e(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),l=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(l);return n&&(l=l.slice(0,n.index).trim()),{name:r,value:l,important:!!n}}function ge(e,t){if(e==null)return null;let r=null;for(let l of me(String(e))){let n=ye(l);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function Je(e,t,r){let l=e==null?"":String(e),n=r==null||r==="",o=me(l),i=o.map(ye),a=i.some(f=>f&&f.name===t&&f.important),s=[],u=!1;o.forEach((f,d)=>{let h=i[d];if(!h||h.name!==t){s.push(f);return}if(n||u)return;let m=/^\s*/.exec(f)[0];s.push(`${m}${t}: ${r}${a?" !important":""}`),u=!0});let c=s.join(";");if(!n&&!u){let f=c.trimEnd();c=f===""?`${t}: ${r}`:`${f}${f.endsWith(";")?" ":"; "}${t}: ${r}`}return c.trim()===""?null:c}function Ge(e,t,r,l){let n=e.attr(t,"style");if((ge(n,r)??"")===l)return;let o=Je(n,r,l);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}function we(e,t,r,l={}){if(Object.prototype.hasOwnProperty.call(l,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return P(e,t,r,{depth:0,path:[]},l)}function P(e,t,r,l,n){if(l.depth>j)throw new V(l.path);if(typeof r=="string")return Ye(e,t,r,l,n);if(Array.isArray(r)){let[o,i]=r,a=e.find(t,o,n);return ve(n,l,a),a.map((s,u)=>P(e,s,i,{depth:l.depth+1,path:[...l.path,u]},n))}if(typeof r=="object"&&r!==null){let o={};for(let[i,a]of Object.entries(r))o[i]=P(e,t,a,{depth:l.depth+1,path:[...l.path,i]},n);return o}return null}function Ye(e,t,r,l,n){if(r.endsWith("[]")){let a=r.slice(0,-2),s=e.find(t,a,n);return ve(n,l,s),s.map(u=>e.text(u))}if(r.startsWith("@"))return X(e,t,r.slice(1));let o=de(r);if(o!==-1){let a=r.slice(0,o),s=r.slice(o+1),u=a?e.find(t,a,n):[t];return u.length===0?null:X(e,u[0],s)}if(r===".")return e.text(t);let i=e.find(t,r,n);return i.length===0?null:e.text(i[0])}function ve(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(l){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,l)}}function X(e,t,r){if(he(r))return ge(e.attr(t,"style"),r);if(Me.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function Xe(e,t,r,l){let n=e.length,o=t.length,i=new Array(n).fill(-1);if(l){let p=new Set;for(let y=0;y<n;y++){let g=l[y];!(g>=0&&g<o)||p.has(g)||(i[y]=g,p.add(g))}}if(n===0||o===0)return i;let a=e.map(p=>K(p,r)),s=t.map(p=>K(p,r)),u=new Array(o).fill(!1);for(let p of i)p>=0&&(u[p]=!0);let c=new Map;s.forEach((p,y)=>{u[y]||c.set(p,c.has(p)?-1:y)});let f=new Map;a.forEach((p,y)=>{i[y]>=0||f.set(p,(f.get(p)||0)+1)}),a.forEach((p,y)=>{if(i[y]>=0||f.get(p)!==1)return;let g=c.get(p);g===void 0||g===-1||u[g]||(i[y]=g,u[g]=!0)});let d=[];for(let p=0;p<n;p++)i[p]<0&&d.push(p);let h=[];for(let p=0;p<o;p++)u[p]||h.push(p);if(d.length===0||h.length===0)return i;let m=n*o+1,w=Ke(e,t,r),v=(p,y)=>w(p,y)*m+Math.abs(p-y);for(let[p,y]of Ze(d,h,v))i[p]=y;return i}var be=e=>typeof e=="object"&&e!==null;function K(e,t){if(!be(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(l=>{let n=JSON.stringify(e?.[l]);return n===void 0?" undef":n}))}function Ke(e,t,r){if(!be(r))return(a,s)=>e[a]===t[s]?0:1;let l=Object.keys(r),n=a=>l.map(s=>JSON.stringify(a?.[s])),o=e.map(n),i=t.map(n);return(a,s)=>{let u=o[a],c=i[s],f=0;for(let d=0;d<l.length;d++)u[d]!==c[d]&&f++;return f}}function Ze(e,t,r){return e.length<=t.length?Z(e,t,r,!1):Z(t,e,(l,n)=>r(n,l),!0)}function Z(e,t,r,l){let n=e.length,o=t.length,i=[];for(let f=0;f<=n;f++)i.push(new Float64Array(o+1).fill(1/0));let a=[];for(let f=0;f<=n;f++)a.push(new Uint8Array(o+1));for(let f=0;f<=o;f++)i[n][f]=0;for(let f=n-1;f>=0;f--)for(let d=o-1;d>=0;d--){let h=r(e[f],t[d])+i[f+1][d+1],m=i[f][d+1];h<=m?(i[f][d]=h,a[f][d]=1):i[f][d]=m}let s=[],u=0,c=0;for(;u<n&&c<o;)a[u][c]&&(s.push(l?[t[c],e[u]]:[e[u],t[c]]),u++),c++;return s}function xe(e,t,r,l,n,o,i,a={}){let s=e.find(t,r,a);if(n.length===0){s.forEach(b=>e.remove(b)),D(a,"onRowsApplied",o.path,[]);return}let u=n.length>s.length,c=s[0]||null;if(u&&!c&&(c=rt(e,t,r,a),!c))throw new R(o.path);let f=s.map(b=>tt(e,b,l,a)),d=null;if(u&&c){d=e.clone(c),a.templateAttr&&e.removeAttr(d,a.templateAttr);let b=e.stripIds(d);b>0&&console.warn(`[hyper-html-api] stripped ${b} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let h=Xe(n,f,l,Qe(e,s,n,o,a)),m=s.length>0?e.parent(s[0]):it(e,t,r,c,o,a),w=s.length>0?Ae(e,m,s[0]):0,v=ut(e,s),p=new Set,y=[],g=n.map((b,E)=>{let N=h[E];if(N>=0)return p.add(N),y.push(!1),s[N];y.push(!0);let T=e.clone(d);return e.stripIds(T),T});s.forEach((b,E)=>{p.has(E)||e.remove(b)}),v?st(e,m,w,g,y):ct(e,g,y,m,w),et(e,g,l,n,o,i,a),D(a,"onRowsApplied",o.path,g)}function D(e,t,r,l){if(typeof e[t]=="function")try{return e[t](r.slice(),l)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function Qe(e,t,r,l,n){let o=D(n,"identifyRows",l.path,r);if(!Array.isArray(o))return null;let i=new Array(r.length).fill(-1),a=new Set,s=new Map(t.map((u,c)=>[e.identity(u),c]));for(let u=0;u<r.length;u++){if(!o[u])continue;let c=s.get(e.identity(o[u]));c===void 0||a.has(c)||(i[u]=c,a.add(c))}return i}function et(e,t,r,l,n,o,i){t.forEach((a,s)=>{if(r===null){let u=l[s],c=u==null?"":String(u);e.text(a)!==c&&e.text(a,c)}else{let u=o(e,a,r,l[s],{depth:n.depth+1,path:[...n.path,s]},i);u&&u!==a&&(t[s]=u)}})}function tt(e,t,r,l){return r===null?e.text(t):we(e,t,r,l.onRowsRead?{...l,onRowsRead:void 0}:l)}function Ae(e,t,r){let l=e.children(t);for(let n=0;n<l.length;n++)if(e.sameNode(l[n],r))return n;return-1}function rt(e,t,r,l){if(!l.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),o=new RegExp(":not\\(\\["+l.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=r.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),a=n?nt(i):0,s=pe(i),u=t;for(;u;){let c=e.find(u,i,{includeRulesTag:!1,templateAttr:null});for(let f of c)if(e.attr(f,l.templateAttr)!=null&&!(n&&!ot(e,t,f,a))&&!(s&&!e.matches(e.parent(f),s)))return f;u=e.parent(u)}return null}function nt(e){let t=0,r=null,l=1;for(let n=0;n<e.length;n++){let o=e[n];if(o==="\\")n++;else if(r)o===r&&(r=null);else if(o==='"'||o==="'")r=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")l++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!lt(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return l}function lt(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let l=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return Q(l)||Q(n)}function Q(e){return e===">"||e==="+"||e==="~"}function ot(e,t,r,l){if(l===null)return!0;let n=r;for(let s=0;s<l;s++)if(n=e.parent(n),!n)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let i=e.prop(n,"tagName");if(!i||String(i).toLowerCase()!==String(o).toLowerCase())return!1;let a=new Set(ee(e,n));return ee(e,t).every(s=>a.has(s))}function ee(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function it(e,t,r,l,n,o){let i=e.parent(l);if(i&&at(e,t,i)&&!re(e,i,o))return i;let a=pe(r);if(!a)throw new R(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let s=(a===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,a,o)).filter(u=>!re(e,u,o));if(s.length===0)throw new R(n.path,`no container matching "${a}" inside this context to hold the new rows`);if(s.length>1)throw new R(n.path,`"${a}" matches ${s.length} containers inside this context, so the new rows have no single destination`);return s[0]}function at(e,t,r){let l=r;for(;l;){if(e.sameNode(l,t))return!0;l=e.parent(l)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var te=["no-data","editor-ui"];function re(e,t,r){let l=t;for(;l;){if(r.templateAttr&&e.attr(l,r.templateAttr)!=null||te.some(o=>e.attr(l,o)!=null))return!0;let n=e.attr(l,"clay");if(n&&n.split(/\s+/).some(o=>te.includes(o)))return!0;l=e.parent(l)}return!1}function st(e,t,r,l,n){let o=e.children(t),i=o.map(s=>e.identity(s)),a=!1;l.forEach((s,u)=>{let c=e.identity(s),f=r+u;if(i[f]===c)return;if(!n[u]){let h=i.indexOf(c);h!==-1&&(i.splice(h,1),o.splice(h,1))}let d=Math.min(f,o.length);d<o.length?e.insertBefore(o[d],s):o.length?a?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,f),a=!0):e.insertAt(t,s,0),i.splice(d,0,c),o.splice(d,0,s)})}function ut(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let l=new Map(e.children(r).map((o,i)=>[e.identity(o),i])),n=[];for(let o of t){let i=l.get(e.identity(o));if(i===void 0)return!1;n.push(i)}return n.sort((o,i)=>o-i),n[n.length-1]-n[0]===n.length-1}function ct(e,t,r,l,n){let o=null,i=n;for(let a=0;a<t.length;a++){if(!r[a]){o=t[a];continue}let s=o?e.parent(o):l;if(!s)continue;let u=o?Ae(e,s,o)+1:i++;e.insertAt(s,t[a],u),o=t[a]}}function ft(e,t,r,l,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let o=[];if(B(r,l,[],o),o.length)throw new ce(o);L(e,t,r,l,{depth:0,path:[]},n)}function L(e,t,r,l,n,o={}){if(n.depth>j)throw new V(n.path);if(l===void 0)return t;if(typeof r=="string")return dt(e,t,r,l,n,o);if(Array.isArray(r)){let[i,a]=r;return xe(e,t,i,a,l,n,L,o),t}if(typeof r=="object"&&r!==null){for(let[i,a]of Object.entries(r)){let s=L(e,t,a,l==null?l:l[i],{depth:n.depth+1,path:[...n.path,i]},o);s&&s!==t&&(t=s)}return t}return t}function dt(e,t,r,l,n,o){if(r.endsWith("[]")){let s=r.slice(0,-2);return xe(e,t,s,null,l,n,L,o),t}if(r.startsWith("@"))return le(e,t,r.slice(1),l);let i=de(r);if(i!==-1){let s=r.slice(0,i),u=r.slice(i+1),c=s?e.find(t,s,o):[t];return c.length===0||le(e,c[0],u,l),t}if(r===".")return ne(e,t,l),t;let a=e.find(t,r,o);return a.length===0||ne(e,a[0],l),t}function ne(e,t,r){let l=r==null?"":String(r);e.text(t)!==l&&e.text(t,l)}function pt(e,t,r,l){if(e.styleVar){e.styleVar(t,r,l);return}Ge(e,t,r,l)}function le(e,t,r,l){if(he(r))return pt(e,t,r,l==null?"":String(l).trim()),t;if(Ie.has(r)){let n=e.prop(t,r);if(n===l||n!=null&&l!=null&&String(n)===String(l))return t;throw new fe(r)}if(r==="outerHTML"){let n=l==null?"":String(l);return e.replaceWith(t,n)}if(Ue.has(r)){let n=Pe(r,l);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(l==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(l);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function B(e,t,r,l){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,o)=>{typeof n=="object"&&n!==null&&l.push({path:S([...r,o]),expected:"scalar",got:k(n)})}):l.push({path:S(r),expected:"array",got:k(t)});return}t!==null&&typeof t=="object"&&l.push({path:S(r),expected:"scalar",got:k(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){l.push({path:S(r),expected:"array",got:k(t)});return}let n=e[1];t.forEach((o,i)=>B(n,o,[...r,i],l));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){l.push({path:S(r),expected:"object",got:k(t)});return}for(let[n,o]of Object.entries(e))B(o,t[n],[...r,n],l)}}}function k(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function S(e){return e.join(".")}function ht(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let o=[],i=0;for(;i<n.length;){let a=n[i];if(/\s/.test(a)){i++;continue}if("{}".includes(a)){o.push({type:a,value:a}),i++;continue}if(a==="["){let f=!1,d=i+1;for(;d<n.length&&/\s/.test(n[d]);)d++;if(d<n.length&&/[a-zA-Z_]/.test(n[d])&&(f=!0),!f){o.push({type:a,value:a}),i++;continue}}if(a==="]"){o.push({type:a,value:a}),i++;continue}if(a===":"){o.push({type:t.COLON,value:a}),i++;continue}if(a===","){o.push({type:t.COMMA,value:a}),i++;continue}if(a==='"'||a==="'"){let f=a,d=i+1;for(;d<n.length&&n[d]!==f;)n[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:n.substring(i+1,d),quoted:!0,sourceQuote:f}),i=d+1;continue}let s=i,u;for(;s<n.length&&!/[{},]/.test(n[s]);)if(n[s]===":"){let f=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let h of f){let m=h.substring(1);if(n.substring(s+1,s+1+m.length)===m){d=!0,s+=m.length;break}}if(!d)break}else if(n[s]==="["){for(s++;s<n.length&&n[s]!=="]";){if(n[s]==='"'||n[s]==="'"){let f=n[s];for(s++;s<n.length&&n[s]!==f;)n[s]==="\\"&&s++,s++}s++}s<n.length&&n[s]==="]"&&s++}else s++;u=n.substring(i,s);let c=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?c=t.NUMBER:u==="true"||u==="false"||u==="null"?c=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(c=t.SELECTOR),o.push({type:c,value:u,quoted:!1}),i=s}return o}function l(n){let o="";for(let i=0;i<n.length;i++){let a=n[i];if("{}".includes(a.type)||"[]".includes(a.type)){o+=a.value;continue}if(a.type===t.COLON){o+=a.value;continue}if(a.type===t.COMMA){let s=n[i+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=a.value;continue}if(a.type===t.STRING&&a.quoted){let s=a.value;a.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(u,c)=>c.length%2===0?c+'\\"':u)),o+=`"${s}"`;continue}if(a.type===t.NUMBER||a.type===t.BOOLEAN){o+=a.value;continue}if(a.type===t.SELECTOR||a.type===t.IDENTIFIER){o+=`"${a.value}"`;continue}o+=`"${a.value}"`}return o}try{let n=r(e),o=l(n);return JSON.parse(o)}catch(n){throw new se("Invalid extraction rules syntax: "+n.message,n)}}var mt="1";var or=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"]})}),ir=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),yt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);var ar=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...yt],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function gt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function wt(e){return e?(e.nodeType===9||e.nodeType,e):null}function oe(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function vt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function bt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let l=r.type;l!=="file"&&l!=="checkbox"&&l!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var xt={semanticExclude:!0,find(e,t,r={}){let l=wt(e);if(!l||!l.querySelectorAll)return[];let n=Array.from(l.querySelectorAll(t));r.includeRulesTag||(n=n.filter(a=>!gt(a)));let o=[];r.skip&&o.push(r.skip);let i=r.templateAttr===null?null:r.templateAttr||"cms-template";if(i&&o.push("["+i+"]"),o.length){let a=o.join(", ");n=n.filter(s=>!s.closest||!s.closest(a))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,vt(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),oe(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),oe(e,t,null)},prop(e,t,r){if(r===void 0){let l=e?e[t]:void 0;return l!==void 0?l:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return bt(t),t},insertAt(e,t,r){let l=e.children[r]||null;e.insertBefore(t,l)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let l=r.content.firstElementChild;if(!l)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(l,e),l},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};var C=xt;var At="hha:upgrade-check:";function x(e,t){let r=e.querySelector(`meta[name="${t}"]`),l=r?r.getAttribute("content"):null;return l&&l.trim()?l.trim():null}function ie(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Tt(e,t){let r=ie(e),l=ie(t);if(!r||!l)return!1;let n=Math.max(r.length,l.length);for(let o=0;o<n;o++){let i=r[o]||0,a=l[o]||0;if(i!==a)return i>a}return!1}function Ot(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Et(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Nt({force:e=!1,doc:t,loc:r,fetchFn:l,now:n,ttlMs:o=864e5}={}){if(t=t||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),l=l||(d=>fetch(d)),n=n??Date.now(),!t)return null;let i=x(t,"hyper-source");if(!i)return null;let a=x(t,"hyper-version"),s;try{s=new URL(i,r?r.href:void 0)}catch{return null}if(r&&s.origin===r.origin&&s.pathname===r.pathname)return null;let u=`${At}${s.href}:${a||"none"}`,c,f=e?null:Ot(u);if(f&&typeof f.checkedAt=="number"&&n-f.checkedAt<o)c=f.sourceVersion;else{try{let d=await l(s.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let h=await d.text(),m=new DOMParser().parseFromString(h,"text/html");c=x(m,"hyper-version")}catch{c=null}Et(u,{checkedAt:n,sourceVersion:c})}return c?{available:Tt(c,a||"0.0.0"),currentVersion:a,sourceVersion:c,sourceUrl:s.href}:null}var kt="script[data-rules-name]";function St(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function Te(e,t){let r=e.find(t,kt,{includeRulesTag:!0}),l=new Set,n=[];for(let o of r){let i=St(e.attr(o,"data-rules-name"));if(!i)continue;if(l.has(i)){console.warn(`hyper-html-api: duplicate rules tag name "${i}"; using the first.`);continue}let a=e.attr(o,"data-rules-version");if(a!==mt)throw new ue(a);l.add(i),n.push({name:i,rules:ht(e.text(o))})}return n}function Oe(e,t){let r={};for(let{name:l,rules:n}of Te(e,t))r[l]=we(e,t,n);return r}function Rt(e){let t=e||document,r=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Oe(C,t),version:x(r,"hyper-version")}}var ae=class extends Error{constructor(e,t){super(`could not fetch upgrade source: ${e}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=e,this.cause=t}},$t=class extends Error{constructor(e){super(`upgrade source has no rules tags; refusing to drop all existing data: ${e}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=e}},q=class extends Error{constructor(e,t){super(e),this.name="UpgradeTransformInvalid",this.cause=t}},Ct=class extends Error{constructor(e){super(`found ${e} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=e}},Lt="text/hyper-upgrade";function jt(e,t){let r=e.find(t,`script[type="${Lt}"]`);if(r.length===0)return null;if(r.length>1)throw new Ct(r.length);return e.text(r[0])||null}var Mt=new Function("url","return import(url)");async function Ut(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),l;try{l=await Mt(r)}catch(n){throw new q(`transform failed to load: ${n&&n.message?n.message:n}`,n)}finally{URL.revokeObjectURL(r)}if(typeof l.default!="function")throw new q("transform must `export default` a function");return l.default}function Ee(e,t){let r={carriedOver:0,discarded:0,listItems:0},l=H(t,e,r);return W(t,e,r),{data:l,summary:r}}function H(e,t,r){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(r.listItems+=t.length,r.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,l]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(n=>H(l,n,r))):void 0}if(typeof e=="object"&&e!==null){let l={};for(let[n,o]of Object.entries(e)){let i=H(o,t?.[n],r);i!==void 0&&(l[n]=i)}return l}}function W(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let l=new Set(Object.keys(e));for(let n of Object.keys(t))l.has(n)?W(e[n],t[n],r):r.discarded+=$(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let l=e[1];t.forEach(n=>W(l,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=$(t))}}function $(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+$(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+$(r),0):1}function It(e,t,r){let l=Te(e,t),n={carriedOver:0,discarded:0,listItems:0},o={},i=new Set;for(let{name:a,rules:s}of l){if(i.add(a),!Object.prototype.hasOwnProperty.call(r,a)){o[a]={carriedOver:0,discarded:0,listItems:0};continue}let{data:u,summary:c}=Ee(r[a],s);ft(e,t,s,u),o[a]=c,n.carriedOver+=c.carriedOver,n.discarded+=c.discarded,n.listItems+=c.listItems}for(let a of Object.keys(r))i.has(a)||(n.discarded+=$(r[a]));return{totals:n,byName:o,rulesTagCount:l.length}}async function Pt({sourceUrl:e,dataByName:t,fromVersion:r,doc:l,loc:n,fetchFn:o}={}){if(l=l||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(p=>fetch(p)),!l)throw new Error("upgrade.run requires a document context");if(e=e||x(l,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let i=new URL(e,n?n.href:void 0);r=r!==void 0?r:x(l,"hyper-version"),t=t||Oe(C,l);let a;try{a=await o(i.href)}catch(p){throw new ae(i.href,p)}if(!a.ok)throw new ae(i.href,new Error(`HTTP ${a.status}`));let s=await a.text(),u=new DOMParser().parseFromString(s,"text/html"),c=x(u,"hyper-version"),f=t,d=!1,h=jt(C,u);if(h){let p=await(await Ut(h))(f,{fromVersion:r,toVersion:c});if(!p||typeof p!="object"||Array.isArray(p))throw new q("transform must return a plain object map of { rulesName: data }");f=p,d=!0}let{totals:m,byName:w,rulesTagCount:v}=It(C,u,f);if(v===0&&Object.keys(f).length>0)throw new $t(i.href);return{html:Bt(u),fromVersion:r,toVersion:c,summary:{transformApplied:d,totals:m,byName:w}}}function Dt(e){for(let t of e.querySelectorAll("input")){let r=(t.getAttribute("type")||"").toLowerCase();r!=="file"&&(r==="checkbox"||r==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let r=[...t.options];if(!t.multiple){let l=r.findIndex(n=>n.hasAttribute("selected"));if(t.selectedIndex===l||l===-1&&t.selectedIndex<=0)continue}for(let l of r)l.selected!==l.hasAttribute("selected")&&l.toggleAttribute("selected",l.selected)}}function Bt(e){return Dt(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
1
+ import{a as G}from"./c-5AQYL27I.js";import{b as J}from"./c-3G2DGZUP.js";import{o as z,p as _}from"./c-ZKELCT4T.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import{a as F}from"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var Ce=Object.defineProperty,Le=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},je=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Me=new Set(je),Ue=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Ie=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Y=new Set(["checked","selected","disabled","readOnly","paused"]);function Pe(e,t){return t==null?Y.has(e)?!1:"":Y.has(e)?t==="false"?!1:!!t:t}var De={};Le(De,{EmptyListInsert:()=>R,MAX_RULE_DEPTH:()=>j,MaxRuleDepthExceeded:()=>V,NoRulesTag:()=>We,RuleTargetReadOnly:()=>fe,RulesParseError:()=>se,ShapeMismatch:()=>ce,UnknownRulesVersion:()=>ue,WriteNotRoundTripped:()=>He,WriteRefused:()=>Be,WriteRejected:()=>Ve});var se=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},ue=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=e}},j=20,V=class extends Error{constructor(e){super(`rule depth exceeded ${j} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},ce=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},R=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},fe=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Be=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function qe(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var He=class extends Error{constructor(e){super(`write did not round-trip at "${qe(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},We=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},Ve=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}};function de(e){let t=0,r=null,l=-1;for(let n=0;n<e.length;n++){let o=e[n];o==="\\"?n++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(l=n)}return l}function pe(e){let t=0,r=null,l=-1,n=!1;for(let o=0;o<e.length;o++){let i=e[o];i==="\\"?o++:r?i===r&&(r=null):i==='"'||i==="'"?r=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?l=o:t===0&&i===","&&(n=!0)}return n||l===-1||!Fe(e,l+1)?null:e.slice(0,l).trim()||null}function Fe(e,t){let r=t,l=e.replace(/\s+$/,"").length;for(;r<l&&/\s/.test(e[r]);)r++;let n=0,o=null;for(;r<l;r++){let i=e[r];if(i==="\\")r++;else if(o)i===o&&(o=null);else if(i==='"'||i==="'")o=i;else if(i==="["||i==="(")n++;else if(i==="]"||i===")")n>0&&n--;else if(n===0&&(i==="+"||i==="~"||/\s/.test(i)))return!1}return!0}var ze=/^--[A-Za-z0-9_-]+$/;function he(e){return typeof e=="string"&&ze.test(e)}function me(e){let t=[],r=[],l=null,n=0;for(let o=0;o<e.length;o++){let i=e[o];if(l){i==="\\"?o++:i===l&&(l=null);continue}if(i==="/"&&e[o+1]==="*"){let a=e.indexOf("*/",o+2);o=a===-1?e.length:a+1;continue}i==='"'||i==="'"?l=i:i==="("?r.push(")"):i==="["?r.push("]"):i==="{"?r.push("}"):(i===")"||i==="]"||i==="}")&&r[r.length-1]===i?r.pop():i===";"&&r.length===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t}function _e(e){let t="",r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){t+=n,n==="\\"&&l+1<e.length?t+=e[++l]:n===r&&(r=null);continue}if(n==="/"&&e[l+1]==="*"){let o=e.indexOf("*/",l+2);l=o===-1?e.length:o+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function ye(e){e=_e(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),l=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(l);return n&&(l=l.slice(0,n.index).trim()),{name:r,value:l,important:!!n}}function ge(e,t){if(e==null)return null;let r=null;for(let l of me(String(e))){let n=ye(l);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function Je(e,t,r){let l=e==null?"":String(e),n=r==null||r==="",o=me(l),i=o.map(ye),a=i.some(f=>f&&f.name===t&&f.important),s=[],u=!1;o.forEach((f,d)=>{let h=i[d];if(!h||h.name!==t){s.push(f);return}if(n||u)return;let m=/^\s*/.exec(f)[0];s.push(`${m}${t}: ${r}${a?" !important":""}`),u=!0});let c=s.join(";");if(!n&&!u){let f=c.trimEnd();c=f===""?`${t}: ${r}`:`${f}${f.endsWith(";")?" ":"; "}${t}: ${r}`}return c.trim()===""?null:c}function Ge(e,t,r,l){let n=e.attr(t,"style");if((ge(n,r)??"")===l)return;let o=Je(n,r,l);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}function we(e,t,r,l={}){if(Object.prototype.hasOwnProperty.call(l,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return P(e,t,r,{depth:0,path:[]},l)}function P(e,t,r,l,n){if(l.depth>j)throw new V(l.path);if(typeof r=="string")return Ye(e,t,r,l,n);if(Array.isArray(r)){let[o,i]=r,a=e.find(t,o,n);return ve(n,l,a),a.map((s,u)=>P(e,s,i,{depth:l.depth+1,path:[...l.path,u]},n))}if(typeof r=="object"&&r!==null){let o={};for(let[i,a]of Object.entries(r))o[i]=P(e,t,a,{depth:l.depth+1,path:[...l.path,i]},n);return o}return null}function Ye(e,t,r,l,n){if(r.endsWith("[]")){let a=r.slice(0,-2),s=e.find(t,a,n);return ve(n,l,s),s.map(u=>e.text(u))}if(r.startsWith("@"))return X(e,t,r.slice(1));let o=de(r);if(o!==-1){let a=r.slice(0,o),s=r.slice(o+1),u=a?e.find(t,a,n):[t];return u.length===0?null:X(e,u[0],s)}if(r===".")return e.text(t);let i=e.find(t,r,n);return i.length===0?null:e.text(i[0])}function ve(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(l){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,l)}}function X(e,t,r){if(he(r))return ge(e.attr(t,"style"),r);if(Me.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function Xe(e,t,r,l){let n=e.length,o=t.length,i=new Array(n).fill(-1);if(l){let p=new Set;for(let y=0;y<n;y++){let g=l[y];!(g>=0&&g<o)||p.has(g)||(i[y]=g,p.add(g))}}if(n===0||o===0)return i;let a=e.map(p=>K(p,r)),s=t.map(p=>K(p,r)),u=new Array(o).fill(!1);for(let p of i)p>=0&&(u[p]=!0);let c=new Map;s.forEach((p,y)=>{u[y]||c.set(p,c.has(p)?-1:y)});let f=new Map;a.forEach((p,y)=>{i[y]>=0||f.set(p,(f.get(p)||0)+1)}),a.forEach((p,y)=>{if(i[y]>=0||f.get(p)!==1)return;let g=c.get(p);g===void 0||g===-1||u[g]||(i[y]=g,u[g]=!0)});let d=[];for(let p=0;p<n;p++)i[p]<0&&d.push(p);let h=[];for(let p=0;p<o;p++)u[p]||h.push(p);if(d.length===0||h.length===0)return i;let m=n*o+1,w=Ke(e,t,r),v=(p,y)=>w(p,y)*m+Math.abs(p-y);for(let[p,y]of Ze(d,h,v))i[p]=y;return i}var be=e=>typeof e=="object"&&e!==null;function K(e,t){if(!be(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(l=>{let n=JSON.stringify(e?.[l]);return n===void 0?" undef":n}))}function Ke(e,t,r){if(!be(r))return(a,s)=>e[a]===t[s]?0:1;let l=Object.keys(r),n=a=>l.map(s=>JSON.stringify(a?.[s])),o=e.map(n),i=t.map(n);return(a,s)=>{let u=o[a],c=i[s],f=0;for(let d=0;d<l.length;d++)u[d]!==c[d]&&f++;return f}}function Ze(e,t,r){return e.length<=t.length?Z(e,t,r,!1):Z(t,e,(l,n)=>r(n,l),!0)}function Z(e,t,r,l){let n=e.length,o=t.length,i=[];for(let f=0;f<=n;f++)i.push(new Float64Array(o+1).fill(1/0));let a=[];for(let f=0;f<=n;f++)a.push(new Uint8Array(o+1));for(let f=0;f<=o;f++)i[n][f]=0;for(let f=n-1;f>=0;f--)for(let d=o-1;d>=0;d--){let h=r(e[f],t[d])+i[f+1][d+1],m=i[f][d+1];h<=m?(i[f][d]=h,a[f][d]=1):i[f][d]=m}let s=[],u=0,c=0;for(;u<n&&c<o;)a[u][c]&&(s.push(l?[t[c],e[u]]:[e[u],t[c]]),u++),c++;return s}function xe(e,t,r,l,n,o,i,a={}){let s=e.find(t,r,a);if(n.length===0){s.forEach(b=>e.remove(b)),D(a,"onRowsApplied",o.path,[]);return}let u=n.length>s.length,c=s[0]||null;if(u&&!c&&(c=rt(e,t,r,a),!c))throw new R(o.path);let f=s.map(b=>tt(e,b,l,a)),d=null;if(u&&c){d=e.clone(c),a.templateAttr&&e.removeAttr(d,a.templateAttr);let b=e.stripIds(d);b>0&&console.warn(`[hyper-html-api] stripped ${b} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let h=Xe(n,f,l,Qe(e,s,n,o,a)),m=s.length>0?e.parent(s[0]):it(e,t,r,c,o,a),w=s.length>0?Ae(e,m,s[0]):0,v=ut(e,s),p=new Set,y=[],g=n.map((b,E)=>{let N=h[E];if(N>=0)return p.add(N),y.push(!1),s[N];y.push(!0);let T=e.clone(d);return e.stripIds(T),T});s.forEach((b,E)=>{p.has(E)||e.remove(b)}),v?st(e,m,w,g,y):ct(e,g,y,m,w),et(e,g,l,n,o,i,a),D(a,"onRowsApplied",o.path,g)}function D(e,t,r,l){if(typeof e[t]=="function")try{return e[t](r.slice(),l)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function Qe(e,t,r,l,n){let o=D(n,"identifyRows",l.path,r);if(!Array.isArray(o))return null;let i=new Array(r.length).fill(-1),a=new Set,s=new Map(t.map((u,c)=>[e.identity(u),c]));for(let u=0;u<r.length;u++){if(!o[u])continue;let c=s.get(e.identity(o[u]));c===void 0||a.has(c)||(i[u]=c,a.add(c))}return i}function et(e,t,r,l,n,o,i){t.forEach((a,s)=>{if(r===null){let u=l[s],c=u==null?"":String(u);e.text(a)!==c&&e.text(a,c)}else{let u=o(e,a,r,l[s],{depth:n.depth+1,path:[...n.path,s]},i);u&&u!==a&&(t[s]=u)}})}function tt(e,t,r,l){return r===null?e.text(t):we(e,t,r,l.onRowsRead?{...l,onRowsRead:void 0}:l)}function Ae(e,t,r){let l=e.children(t);for(let n=0;n<l.length;n++)if(e.sameNode(l[n],r))return n;return-1}function rt(e,t,r,l){if(!l.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),o=new RegExp(":not\\(\\["+l.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=r.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),a=n?nt(i):0,s=pe(i),u=t;for(;u;){let c=e.find(u,i,{includeRulesTag:!1,templateAttr:null});for(let f of c)if(e.attr(f,l.templateAttr)!=null&&!(n&&!ot(e,t,f,a))&&!(s&&!e.matches(e.parent(f),s)))return f;u=e.parent(u)}return null}function nt(e){let t=0,r=null,l=1;for(let n=0;n<e.length;n++){let o=e[n];if(o==="\\")n++;else if(r)o===r&&(r=null);else if(o==='"'||o==="'")r=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")l++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!lt(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return l}function lt(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let l=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return Q(l)||Q(n)}function Q(e){return e===">"||e==="+"||e==="~"}function ot(e,t,r,l){if(l===null)return!0;let n=r;for(let s=0;s<l;s++)if(n=e.parent(n),!n)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let i=e.prop(n,"tagName");if(!i||String(i).toLowerCase()!==String(o).toLowerCase())return!1;let a=new Set(ee(e,n));return ee(e,t).every(s=>a.has(s))}function ee(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function it(e,t,r,l,n,o){let i=e.parent(l);if(i&&at(e,t,i)&&!re(e,i,o))return i;let a=pe(r);if(!a)throw new R(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let s=(a===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,a,o)).filter(u=>!re(e,u,o));if(s.length===0)throw new R(n.path,`no container matching "${a}" inside this context to hold the new rows`);if(s.length>1)throw new R(n.path,`"${a}" matches ${s.length} containers inside this context, so the new rows have no single destination`);return s[0]}function at(e,t,r){let l=r;for(;l;){if(e.sameNode(l,t))return!0;l=e.parent(l)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var te=["no-data","editor-ui"];function re(e,t,r){let l=t;for(;l;){if(r.templateAttr&&e.attr(l,r.templateAttr)!=null||te.some(o=>e.attr(l,o)!=null))return!0;let n=e.attr(l,"clay");if(n&&n.split(/\s+/).some(o=>te.includes(o)))return!0;l=e.parent(l)}return!1}function st(e,t,r,l,n){let o=e.children(t),i=o.map(s=>e.identity(s)),a=!1;l.forEach((s,u)=>{let c=e.identity(s),f=r+u;if(i[f]===c)return;if(!n[u]){let h=i.indexOf(c);h!==-1&&(i.splice(h,1),o.splice(h,1))}let d=Math.min(f,o.length);d<o.length?e.insertBefore(o[d],s):o.length?a?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,f),a=!0):e.insertAt(t,s,0),i.splice(d,0,c),o.splice(d,0,s)})}function ut(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let l=new Map(e.children(r).map((o,i)=>[e.identity(o),i])),n=[];for(let o of t){let i=l.get(e.identity(o));if(i===void 0)return!1;n.push(i)}return n.sort((o,i)=>o-i),n[n.length-1]-n[0]===n.length-1}function ct(e,t,r,l,n){let o=null,i=n;for(let a=0;a<t.length;a++){if(!r[a]){o=t[a];continue}let s=o?e.parent(o):l;if(!s)continue;let u=o?Ae(e,s,o)+1:i++;e.insertAt(s,t[a],u),o=t[a]}}function ft(e,t,r,l,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let o=[];if(B(r,l,[],o),o.length)throw new ce(o);L(e,t,r,l,{depth:0,path:[]},n)}function L(e,t,r,l,n,o={}){if(n.depth>j)throw new V(n.path);if(l===void 0)return t;if(typeof r=="string")return dt(e,t,r,l,n,o);if(Array.isArray(r)){let[i,a]=r;return xe(e,t,i,a,l,n,L,o),t}if(typeof r=="object"&&r!==null){for(let[i,a]of Object.entries(r)){let s=L(e,t,a,l==null?l:l[i],{depth:n.depth+1,path:[...n.path,i]},o);s&&s!==t&&(t=s)}return t}return t}function dt(e,t,r,l,n,o){if(r.endsWith("[]")){let s=r.slice(0,-2);return xe(e,t,s,null,l,n,L,o),t}if(r.startsWith("@"))return le(e,t,r.slice(1),l);let i=de(r);if(i!==-1){let s=r.slice(0,i),u=r.slice(i+1),c=s?e.find(t,s,o):[t];return c.length===0||le(e,c[0],u,l),t}if(r===".")return ne(e,t,l),t;let a=e.find(t,r,o);return a.length===0||ne(e,a[0],l),t}function ne(e,t,r){let l=r==null?"":String(r);e.text(t)!==l&&e.text(t,l)}function pt(e,t,r,l){if(e.styleVar){e.styleVar(t,r,l);return}Ge(e,t,r,l)}function le(e,t,r,l){if(he(r))return pt(e,t,r,l==null?"":String(l).trim()),t;if(Ie.has(r)){let n=e.prop(t,r);if(n===l||n!=null&&l!=null&&String(n)===String(l))return t;throw new fe(r)}if(r==="outerHTML"){let n=l==null?"":String(l);return e.replaceWith(t,n)}if(Ue.has(r)){let n=Pe(r,l);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(l==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(l);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function B(e,t,r,l){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,o)=>{typeof n=="object"&&n!==null&&l.push({path:S([...r,o]),expected:"scalar",got:k(n)})}):l.push({path:S(r),expected:"array",got:k(t)});return}t!==null&&typeof t=="object"&&l.push({path:S(r),expected:"scalar",got:k(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){l.push({path:S(r),expected:"array",got:k(t)});return}let n=e[1];t.forEach((o,i)=>B(n,o,[...r,i],l));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){l.push({path:S(r),expected:"object",got:k(t)});return}for(let[n,o]of Object.entries(e))B(o,t[n],[...r,n],l)}}}function k(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function S(e){return e.join(".")}function ht(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let o=[],i=0;for(;i<n.length;){let a=n[i];if(/\s/.test(a)){i++;continue}if("{}".includes(a)){o.push({type:a,value:a}),i++;continue}if(a==="["){let f=!1,d=i+1;for(;d<n.length&&/\s/.test(n[d]);)d++;if(d<n.length&&/[a-zA-Z_]/.test(n[d])&&(f=!0),!f){o.push({type:a,value:a}),i++;continue}}if(a==="]"){o.push({type:a,value:a}),i++;continue}if(a===":"){o.push({type:t.COLON,value:a}),i++;continue}if(a===","){o.push({type:t.COMMA,value:a}),i++;continue}if(a==='"'||a==="'"){let f=a,d=i+1;for(;d<n.length&&n[d]!==f;)n[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:n.substring(i+1,d),quoted:!0,sourceQuote:f}),i=d+1;continue}let s=i,u;for(;s<n.length&&!/[{},]/.test(n[s]);)if(n[s]===":"){let f=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let h of f){let m=h.substring(1);if(n.substring(s+1,s+1+m.length)===m){d=!0,s+=m.length;break}}if(!d)break}else if(n[s]==="["){for(s++;s<n.length&&n[s]!=="]";){if(n[s]==='"'||n[s]==="'"){let f=n[s];for(s++;s<n.length&&n[s]!==f;)n[s]==="\\"&&s++,s++}s++}s<n.length&&n[s]==="]"&&s++}else s++;u=n.substring(i,s);let c=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?c=t.NUMBER:u==="true"||u==="false"||u==="null"?c=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(c=t.SELECTOR),o.push({type:c,value:u,quoted:!1}),i=s}return o}function l(n){let o="";for(let i=0;i<n.length;i++){let a=n[i];if("{}".includes(a.type)||"[]".includes(a.type)){o+=a.value;continue}if(a.type===t.COLON){o+=a.value;continue}if(a.type===t.COMMA){let s=n[i+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=a.value;continue}if(a.type===t.STRING&&a.quoted){let s=a.value;a.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(u,c)=>c.length%2===0?c+'\\"':u)),o+=`"${s}"`;continue}if(a.type===t.NUMBER||a.type===t.BOOLEAN){o+=a.value;continue}if(a.type===t.SELECTOR||a.type===t.IDENTIFIER){o+=`"${a.value}"`;continue}o+=`"${a.value}"`}return o}try{let n=r(e),o=l(n);return JSON.parse(o)}catch(n){throw new se("Invalid extraction rules syntax: "+n.message,n)}}var mt="1";var or=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"]})}),ir=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),yt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);var ar=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...yt],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function gt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function wt(e){return e?(e.nodeType===9||e.nodeType,e):null}function oe(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function vt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function bt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let l=r.type;l!=="file"&&l!=="checkbox"&&l!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var xt={semanticExclude:!0,find(e,t,r={}){let l=wt(e);if(!l||!l.querySelectorAll)return[];let n=Array.from(l.querySelectorAll(t));r.includeRulesTag||(n=n.filter(a=>!gt(a)));let o=[];r.skip&&o.push(r.skip);let i=r.templateAttr===null?null:r.templateAttr||"cms-template";if(i&&o.push("["+i+"]"),o.length){let a=o.join(", ");n=n.filter(s=>!s.closest||!s.closest(a))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,vt(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),oe(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),oe(e,t,null)},prop(e,t,r){if(r===void 0){let l=e?e[t]:void 0;return l!==void 0?l:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return bt(t),t},insertAt(e,t,r){let l=e.children[r]||null;e.insertBefore(t,l)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let l=r.content.firstElementChild;if(!l)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(l,e),l},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};var C=xt;var At="hha:upgrade-check:";function x(e,t){let r=e.querySelector(`meta[name="${t}"]`),l=r?r.getAttribute("content"):null;return l&&l.trim()?l.trim():null}function ie(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Tt(e,t){let r=ie(e),l=ie(t);if(!r||!l)return!1;let n=Math.max(r.length,l.length);for(let o=0;o<n;o++){let i=r[o]||0,a=l[o]||0;if(i!==a)return i>a}return!1}function Ot(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Et(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Nt({force:e=!1,doc:t,loc:r,fetchFn:l,now:n,ttlMs:o=864e5}={}){if(t=t||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),l=l||(d=>fetch(d)),n=n??Date.now(),!t)return null;let i=x(t,"hyper-source");if(!i)return null;let a=x(t,"hyper-version"),s;try{s=new URL(i,r?r.href:void 0)}catch{return null}if(r&&s.origin===r.origin&&s.pathname===r.pathname)return null;let u=`${At}${s.href}:${a||"none"}`,c,f=e?null:Ot(u);if(f&&typeof f.checkedAt=="number"&&n-f.checkedAt<o)c=f.sourceVersion;else{try{let d=await l(s.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let h=await d.text(),m=new DOMParser().parseFromString(h,"text/html");c=x(m,"hyper-version")}catch{c=null}Et(u,{checkedAt:n,sourceVersion:c})}return c?{available:Tt(c,a||"0.0.0"),currentVersion:a,sourceVersion:c,sourceUrl:s.href}:null}var kt="script[data-rules-name]";function St(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function Te(e,t){let r=e.find(t,kt,{includeRulesTag:!0}),l=new Set,n=[];for(let o of r){let i=St(e.attr(o,"data-rules-name"));if(!i)continue;if(l.has(i)){console.warn(`hyper-html-api: duplicate rules tag name "${i}"; using the first.`);continue}let a=e.attr(o,"data-rules-version");if(a!==mt)throw new ue(a);l.add(i),n.push({name:i,rules:ht(e.text(o))})}return n}function Oe(e,t){let r={};for(let{name:l,rules:n}of Te(e,t))r[l]=we(e,t,n);return r}function Rt(e){let t=e||document,r=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Oe(C,t),version:x(r,"hyper-version")}}var ae=class extends Error{constructor(e,t){super(`could not fetch upgrade source: ${e}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=e,this.cause=t}},$t=class extends Error{constructor(e){super(`upgrade source has no rules tags; refusing to drop all existing data: ${e}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=e}},q=class extends Error{constructor(e,t){super(e),this.name="UpgradeTransformInvalid",this.cause=t}},Ct=class extends Error{constructor(e){super(`found ${e} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=e}},Lt="text/hyper-upgrade";function jt(e,t){let r=e.find(t,`script[type="${Lt}"]`);if(r.length===0)return null;if(r.length>1)throw new Ct(r.length);return e.text(r[0])||null}var Mt=new Function("url","return import(url)");async function Ut(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),l;try{l=await Mt(r)}catch(n){throw new q(`transform failed to load: ${n&&n.message?n.message:n}`,n)}finally{URL.revokeObjectURL(r)}if(typeof l.default!="function")throw new q("transform must `export default` a function");return l.default}function Ee(e,t){let r={carriedOver:0,discarded:0,listItems:0},l=H(t,e,r);return W(t,e,r),{data:l,summary:r}}function H(e,t,r){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(r.listItems+=t.length,r.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,l]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(n=>H(l,n,r))):void 0}if(typeof e=="object"&&e!==null){let l={};for(let[n,o]of Object.entries(e)){let i=H(o,t?.[n],r);i!==void 0&&(l[n]=i)}return l}}function W(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let l=new Set(Object.keys(e));for(let n of Object.keys(t))l.has(n)?W(e[n],t[n],r):r.discarded+=$(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let l=e[1];t.forEach(n=>W(l,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=$(t))}}function $(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+$(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+$(r),0):1}function It(e,t,r){let l=Te(e,t),n={carriedOver:0,discarded:0,listItems:0},o={},i=new Set;for(let{name:a,rules:s}of l){if(i.add(a),!Object.prototype.hasOwnProperty.call(r,a)){o[a]={carriedOver:0,discarded:0,listItems:0};continue}let{data:u,summary:c}=Ee(r[a],s);ft(e,t,s,u),o[a]=c,n.carriedOver+=c.carriedOver,n.discarded+=c.discarded,n.listItems+=c.listItems}for(let a of Object.keys(r))i.has(a)||(n.discarded+=$(r[a]));return{totals:n,byName:o,rulesTagCount:l.length}}async function Pt({sourceUrl:e,dataByName:t,fromVersion:r,doc:l,loc:n,fetchFn:o}={}){if(l=l||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(p=>fetch(p)),!l)throw new Error("upgrade.run requires a document context");if(e=e||x(l,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let i=new URL(e,n?n.href:void 0);r=r!==void 0?r:x(l,"hyper-version"),t=t||Oe(C,l);let a;try{a=await o(i.href)}catch(p){throw new ae(i.href,p)}if(!a.ok)throw new ae(i.href,new Error(`HTTP ${a.status}`));let s=await a.text(),u=new DOMParser().parseFromString(s,"text/html"),c=x(u,"hyper-version"),f=t,d=!1,h=jt(C,u);if(h){let p=await(await Ut(h))(f,{fromVersion:r,toVersion:c});if(!p||typeof p!="object"||Array.isArray(p))throw new q("transform must return a plain object map of { rulesName: data }");f=p,d=!0}let{totals:m,byName:w,rulesTagCount:v}=It(C,u,f);if(v===0&&Object.keys(f).length>0)throw new $t(i.href);return{html:Bt(u),fromVersion:r,toVersion:c,summary:{transformApplied:d,totals:m,byName:w}}}function Dt(e){for(let t of e.querySelectorAll("input")){let r=(t.getAttribute("type")||"").toLowerCase();r!=="file"&&(r==="checkbox"||r==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let r=[...t.options];if(!t.multiple){let l=r.findIndex(n=>n.hasAttribute("selected"));if(t.selectedIndex===l||l===-1&&t.selectedIndex<=0)continue}for(let l of r)l.selected!==l.hasAttribute("selected")&&l.toggleAttribute("selected",l.selected)}}function Bt(e){return Dt(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
2
2
  `+e.documentElement.outerHTML}var M={checkForUpdate:Nt,run:Pt,extractAll:Rt,shapeMatch:Ee};var A="The new version could not be downloaded. Nothing was changed.",U="The upgrade could not be saved. Nothing was changed.",Se="This document changed somewhere else. Reload and try again.",qt="Something else is changing this document. Nothing was changed.",Ht="This document does not say which parts are its data, so it cannot be upgraded safely. Nothing was changed.",Wt="The new version has no place for this page's content. Nothing was changed.";async function Vt(e){let t=globalThis.crypto&&globalThis.crypto.subtle;if(!t)return null;let r=await t.digest("SHA-256",e);return[...new Uint8Array(r)].map(l=>l.toString(16).padStart(2,"0")).join("")}async function Ne(e,t){try{let r=await e(t,{credentials:"omit"});return!r||!r.ok?null:r}catch{return null}}function Ft(e,t,r){if(e&&typeof e.latestUrl=="string"&&e.latestUrl)return e.latestUrl;let l=x(t,"hyper-source");if(!l)return null;try{let n=new URL(l,r?r.href:void 0);return n.pathname=n.pathname.replace(/\.html$/,".json"),n.href}catch{return null}}function zt(e){let t=x(e,"clay-template");if(!t)return null;let[r,l]=t.split(/\s+/);return r&&l?{id:r,variant:l}:null}function I(e,t="",r=[]){if(Array.isArray(e)){for(let l of e)I(l,`${t}[]`,r);return r}if(e&&typeof e=="object"){for(let[l,n]of Object.entries(e))I(n,t?`${t}.${l}`:l,r);return r}return e!=null&&r.push({path:t,value:e}),r}function _t(e,t){let r=[e];for(let l of String(t).split(".")){let n=l.endsWith("[]"),o=n?l.slice(0,-2):l,i=[];for(let a of r){let s=o?a?.[o]:a;n?Array.isArray(s)&&i.push(...s):i.push(s)}r=i}return r}function Jt(e,t,r={}){let l=new Map;for(let{path:o,value:i}of I(t)){let a=`${o}\0${String(i)}`;l.set(a,(l.get(a)||0)+1)}let n=[];for(let{path:o,value:i}of I(e)){let a=`${o}\0${String(i)}`;if(l.get(a)>0){l.set(a,l.get(a)-1);continue}let s=r[o];typeof s=="string"&&_t(t,s).some(u=>u===i)||n.push({path:o,value:i})}return n}async function Gt(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t);try{return await new Function("url","return import(url)")(r)}finally{URL.revokeObjectURL(r)}}async function Yt(e){let r=new DOMParser().parseFromString(e,"text/html").querySelector('script[type="text/hyper-upgrade"]');if(!r)return{};let l=await Gt(r.textContent||"");return l&&l.renames&&typeof l.renames=="object"?l.renames:{}}var ke='script[clay~="live"][merge]';function Xt(e,t,r){let l=t.querySelector("article[data-page]");if(!l)return null;l.replaceWith(t.importNode(r,!0));for(let o of e.querySelectorAll(ke)){let i=o.getAttribute("merge");if(i!=="page"&&!i.startsWith("page."))continue;let a=t.importNode(o,!0),s=[...t.querySelectorAll(ke)].find(u=>u.getAttribute("merge")===i);s?s.replaceWith(a):t.querySelector("article[data-page]").after(a)}return(t.doctype?`<!DOCTYPE ${t.doctype.name}>
3
3
  `:"")+t.documentElement.outerHTML}async function Re(e,{doc:t=document,loc:r=location,fetchFn:l=(n,o)=>fetch(n,o)}={}){if((typeof window<"u"&&window.clay||{}).isDraftMode)return{ok:!1,code:"draft"};if(!e||typeof e.version!="string")return{ok:!1,code:"unavailable",message:A};let o=Ft(e,t,r);if(!o)return{ok:!1,code:"unavailable",message:A};let i=await Ne(l,o);if(!i)return{ok:!1,code:"unavailable",message:A};let a;try{a=await i.json()}catch{return{ok:!1,code:"unavailable",message:A}}if(!a||typeof a!="object")return{ok:!1,code:"unavailable",message:A};let s=zt(t);if(!s||a.id!==s.id||a.variant!==s.variant)return{ok:!1,code:"template",message:"This upgrade is for a different document."};let u=x(t,"hyper-version");if(!u||typeof a.version!="string"||!J(a.version,u))return{ok:!1,code:"not-newer",message:"There is no newer version to install."};if(typeof a.html!="string"||!a.html)return{ok:!1,code:"unavailable",message:A};let c;try{c=new URL(a.html,o).href}catch{return{ok:!1,code:"unavailable",message:A}}if(!/^https:\/\/hyperclay\.com\/templates\//.test(c))return{ok:!1,code:"source",message:"This upgrade is not from the template host."};let f=await Ne(l,c);if(!f)return{ok:!1,code:"unavailable",message:A};let d;try{d=await f.text()}catch{return{ok:!1,code:"unavailable",message:A}}let h=await Vt(new TextEncoder().encode(d));if(!h||h!==String(a.sha256||"").toLowerCase())return{ok:!1,code:"unavailable",message:A};let m,w;try{w=await Yt(d),m=await M.run({sourceUrl:c,doc:t,loc:r,fromVersion:u,fetchFn:async()=>({ok:!0,status:200,text:async()=>d})})}catch(T){return{ok:!1,code:"transform",message:T&&T.message?T.message:A}}let v=new DOMParser().parseFromString(m.html,"text/html"),p=M.extractAll(t).dataByName,y=t.querySelector("article[data-page]");if(!y&&!Object.keys(p||{}).length)return{ok:!1,code:"undeclared",message:Ht};let g=m.html;if(y){let T=Xt(t,v,y);if(!T)return{ok:!1,code:"lost",lost:[],discarded:0,message:Wt};g=T}let b=M.extractAll(v).dataByName,E=Jt(p,b,w),N=m.summary&&m.summary.totals&&m.summary.totals.discarded||0;return E.length||N>0?{ok:!1,code:"lost",lost:E,discarded:N,message:Kt(E,N)}:{ok:!0,html:g,version:m.toVersion||a.version}}function Kt(e,t){let r=e.slice(0,5).map(({path:n})=>n),l=e.length>r.length?` and ${e.length-r.length} more`:"";return r.length?`This upgrade would lose data: ${r.join(", ")}${l}. Nothing was changed.`:`This upgrade would lose ${t} value${t===1?"":"s"}. Nothing was changed.`}function Zt(e){let t=e&&e.state;if(t==="conflict")return{ok:!1,code:"conflict",message:Se};let r=e&&e.message?e.message:"The document could not be saved.";return{ok:!1,code:"flush",state:t||"failed",message:r}}async function $e(e,{doc:t=document,loc:r=location,fetchFn:l=(s,u)=>fetch(s,u),clay:n=typeof window<"u"?window.clay:null,reload:o=()=>window.location.reload(),replace:i=null,etag:a}={}){if((n||{}).isDraftMode)return{ok:!1,code:"draft"};let u=z("upgrade");if(!u)return{ok:!1,code:"busy",message:qt};try{return await Qt(e,{doc:t,loc:r,fetchFn:l,clay:n,reload:o,replace:i,etag:a})}finally{_(u)}}async function Qt(e,{doc:t,loc:r,fetchFn:l,clay:n,reload:o,replace:i,etag:a}){let s=n||{};if(s.isEditMode&&s.save&&typeof s.save.flush=="function"){let h;try{h=await s.save.flush()}catch(m){return Zt(m)}if(h&&typeof h.state=="string"&&h.state!=="saved"&&h.state!=="clean"&&h.state!=="view")return{ok:!1,code:"flush",state:h.state,message:"This document has changes that could not be saved. Nothing was changed."}}let u=t;if(s.isEditMode&&typeof s.getHTML=="function")try{u=new DOMParser().parseFromString(await s.getHTML(),"text/html")}catch{return{ok:!1,code:"failed",message:U}}let c=await Re(e,{doc:u,loc:r,fetchFn:l});if(!c.ok)return c;let f=typeof i=="function"?i:s.save&&typeof s.save.replace=="function"?s.save.replace:G,d;try{d=await f(c.html,{etag:a!==void 0?a:F()})}catch{return{ok:!1,code:"failed",message:U}}if(!d||!d.ok){let h=d&&d.code?d.code:"failed";return h==="conflict"?{ok:!1,code:h,message:Se}:h==="forbidden"?{ok:!1,code:h,message:"You are not allowed to save this document."}:h==="unsupported"?{ok:!1,code:h,message:"This host cannot save the upgrade."}:{ok:!1,code:h,message:U}}return o(),{ok:!0,html:c.html,version:c.version,etag:d.etag}}function O(e,t,r={}){let l=e.createElement(t);l.setAttribute("clay","editor-ui");for(let[n,o]of Object.entries(r))n==="style"?l.setAttribute("style",o):n==="text"?l.textContent=o:l.setAttribute(n,o);return l}function er(e){let r=(e&&e.pathname?e.pathname:"/").split("/").filter(Boolean).pop()||"page.html";try{r=decodeURIComponent(r)}catch{}return/\.html?$/i.test(r)?r:`${r}.html`}async function tr(e,{loc:t=location,fetchFn:r=(l,n)=>fetch(l,n)}={}){if(typeof e.getHTML=="function")return e.getHTML();let l=await r(t.href,{cache:"no-store",credentials:"same-origin"});if(!l.ok)throw new Error(`copy fetch ${l.status}`);return l.text()}async function rr({clay:e,doc:t=document,loc:r=location,fetchFn:l}={}){if(typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;try{let n=await tr(e,{loc:r,fetchFn:l});if(typeof n=="string"&&/clay|data-paid-only/i.test(n)){let{stripCopyContent:a}=await import("./c-C4IIQZGJ.js");n=a(n)}let o=URL.createObjectURL(new Blob([n],{type:"text/html"})),i=t.createElement("a");return i.setAttribute("clay","editor-ui"),i.href=o,i.download=er(r),i.style.setProperty("display","none","important"),t.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(o),4e4),!0}catch{return!1}}async function nr(e){let t=e&&e.host;if(!t||!t.versions)return!1;try{return await t.versions===!0}catch{return!1}}async function lr(e,t={}){let r=t.doc||document,l=t.clay||(typeof window<"u"?window.clay:null)||{};if(l.isDraftMode||!e||typeof e.version!="string")return null;let n=await nr(l),o=O(r,"div",{role:"dialog","aria-modal":"true","data-clay-upgrade":"",style:"position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(15,17,21,.42);font-family:system-ui,-apple-system,'Segoe UI',sans-serif;"}),i=O(r,"div",{style:"width:min(460px,100%);padding:20px;border-radius:14px;background:var(--clay-ui-bg,#fff);color:var(--clay-ui-fg,#1f2328);box-shadow:0 18px 48px -16px rgba(0,0,0,.55);font-size:14px;line-height:1.5;"}),a=O(r,"h2",{text:`Upgrade to version ${e.version}`,style:"margin:0 0 8px;font-size:16px;"}),s=O(r,"p",{text:`Your data moves into version ${e.version}. The page's layout and code are replaced; your current version stays in this document's history.`,style:"margin:0 0 16px;"}),u=O(r,"p",{role:"status",style:"margin:0 0 12px;min-height:1.5em;"}),c=O(r,"div",{style:"display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;"}),f="padding:7px 12px;border-radius:8px;border:1px solid rgba(23,28,36,.2);background:transparent;color:inherit;font:inherit;cursor:pointer;",d=O(r,"button",{type:"button",text:"Cancel",style:f}),h=n?null:O(r,"button",{type:"button",text:"Download a copy first",style:f}),m=O(r,"button",{type:"button",text:"Upgrade",style:`${f}border-color:transparent;background:#2f6fed;color:#fff;font-weight:600;`});n||(m.disabled=!0),h&&c.append(h),c.append(d,m),i.append(a,s,u,c),o.append(i),r.body.appendChild(o);let w=!1,v=()=>{w||(w=!0,o.remove())};h&&h.addEventListener("click",async()=>{await rr({clay:l,doc:r,loc:t.loc,fetchFn:t.fetchFn})?(m.disabled=!1,u.textContent="Your copy was downloaded."):u.textContent="The copy could not be downloaded. Nothing was changed."}),d.addEventListener("click",v);let p,y=new Promise(g=>{p=g});return m.addEventListener("click",async()=>{m.disabled=!0,h&&(h.disabled=!0),u.textContent=`Upgrading to version ${e.version}\u2026`;let g=await $e(e,t);if(g.ok){v(),p(g);return}u.textContent=g.message||U,m.disabled=!1,h&&(h.disabled=!1),p(g)}),{root:o,title:a,body:s,status:u,cancel:d,download:h,upgrade:m,close:v,done:y}}export{$e as apply,Re as prepare,lr as start};
@@ -1 +1 @@
1
- var o=null,n=()=>o??=import("./c-MIL4B2JQ.js"),s=t=>(...i)=>{n().then(e=>(t?e[t]:e.default)(...i))},l=s(null),r=s("toastPersistent"),a=(...t)=>{o&&s("dismissPersistent")(...t)};export{l as a,r as b,a as c};
1
+ var o=null,n=()=>o??=import("./c-MRURHLKV.js"),s=t=>(...i)=>{n().then(e=>(t?e[t]:e.default)(...i))},l=s(null),r=s("toastPersistent"),a=(...t)=>{o&&s("dismissPersistent")(...t)};export{l as a,r as b,a as c};
@@ -1 +1 @@
1
- import{c as z}from"./c-W4JCVLAB.js";import{B as J}from"./c-44B5ODN7.js";import{d as _,m as F}from"./c-QIXT3Q7C.js";import"./c-VHNSBD2M.js";var{Decoration:ee,DecorationSet:te}=_,c=(t,n,a,e={},o=null)=>{let l=t.createElement(n);a&&(l.className=a);for(let[s,i]of Object.entries(e))i!=null&&i!==!1&&l.setAttribute(s,i===!0?"":String(i));return o!==null&&(l.textContent=o),l},ne=(t,n)=>c(t,"span","page-board-face",{"aria-hidden":"true"},([...String(n).trim()][0]??"?").toUpperCase());function I(t,n){let a=null;return t.state.doc.forEach((e,o)=>{e.attrs.id===n&&e.type===F.nodes.list_item&&e.attrs.kind==="check"&&(a={node:e,pos:o})}),a}function X(t,n,a,e){let o=I(t,n);o&&t.dispatch(J(t.state.tr.setNodeMarkup(o.pos,null,{...o.node.attrs,[a]:e||null})))}var L={person:'<circle cx="8" cy="5.4" r="2.3"/><path d="M3.6 13.2c.6-2.1 2.2-3.3 4.4-3.3s3.8 1.2 4.4 3.3"/>',calendar:'<rect x="2.5" y="3.5" width="11" height="10"/><path d="M2.5 6.8h11M5.5 2v2.4M10.5 2v2.4"/>',clock:'<circle cx="8" cy="8" r="5.5"/><path d="M8 4.8v3.4l2.3 1.4"/>',tick:'<path d="M3.5 8.3l3 3 6-6.2"/>',plus:'<path d="M8 3.5v9M3.5 8h9"/>',clear:'<path d="M4.8 4.8l6.4 6.4M11.2 4.8l-6.4 6.4"/>',"chevron-left":'<path d="M9.8 3.6L5.4 8l4.4 4.4"/>',"chevron-right":'<path d="M6.2 3.6L10.6 8l-4.4 4.4"/>'};function q(t,n){let a=t.createElementNS("http://www.w3.org/2000/svg","svg");return a.setAttribute("viewBox","0 0 16 16"),a.setAttribute("width","14"),a.setAttribute("height","14"),a.setAttribute("fill","none"),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("aria-hidden","true"),a.innerHTML=n,a}var Z=t=>String(t).padStart(2,"0"),B=/^\d{4}-\d{2}-\d{2}$/,S=(t=new Date)=>`${t.getFullYear()}-${Z(t.getMonth()+1)}-${Z(t.getDate())}`,ae=t=>{let n=new Date(`${t}T00:00:00Z`);return n.setUTCDate(n.getUTCDate()+1),n.toISOString().slice(0,10)};function oe(t,n){if(!t)return"No date";if(!B.test(t))return t;if(t===n)return"Today";if(t===ae(n))return"Tomorrow";let a=t.slice(0,4)===n.slice(0,4);return new Date(`${t}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",...a?{}:{year:"numeric"},timeZone:"UTC"})}function j(t,{name:n,paths:a,label:e,aria:o,filled:l,overdue:s=!1}){let i=c(t,"button","page-check-chip",{type:"button","data-check":n,"data-filled":String(l),"data-overdue":s?"true":null,"aria-expanded":"false","aria-label":o});return i.append(q(t,a),c(t,"span","page-check-chip-label",{},e)),i}var N=null;function G(t,n,{className:a,label:e,check:o,onKey:l=null}){let s=n.ownerDocument,i=s.defaultView;N&&N.close();for(let d of s.querySelectorAll(".page-check-popup"))d.remove();let y=t.dom.parentNode,h=["relative","absolute","fixed","sticky"].includes(i?.getComputedStyle?.(y)?.position??""),g=y&&h?y:s.body,f=c(s,"div",`page-check-popup ${a}`,{role:"dialog","aria-label":e,"data-check":o}),A=!1,E=()=>{let d=n.getBoundingClientRect(),r=g===s.body?{top:-(i?.scrollY??0),left:-(i?.scrollX??0)}:g.getBoundingClientRect(),u=f.getBoundingClientRect(),p=u.width||Math.min(264,(i?.innerWidth||292)-28),k=(i?.innerHeight??0)-d.bottom-2,b=u.height>0&&k<u.height;f.style.left=`${Math.round(d.right-p-r.left)}px`,f.style.top=`${Math.round((b?d.top-u.height-2:d.bottom+2)-r.top)}px`},C=d=>{if(!f.isConnected)return w();f.contains(d.target)||n.contains(d.target)||w()},w=({focusAnchor:d=!1}={})=>{if(A)return;A=!0,s.removeEventListener("mousedown",C,!0),i?.removeEventListener("resize",E),i?.removeEventListener("scroll",E,!0),N?.panel===f&&(N=null),f.remove(),n.setAttribute("aria-expanded","false");let r=n.dataset.fromKeys==="true";delete n.dataset.fromKeys,d&&r?t.focus():d&&n.focus()};return f.addEventListener("keydown",d=>{if(d.stopPropagation(),d.key==="Escape"){d.preventDefault(),w({focusAnchor:!0});return}l?.(d,f)}),g.append(f),n.setAttribute("aria-expanded","true"),N={panel:f,close:()=>w()},s.addEventListener("mousedown",C,!0),i?.addEventListener("resize",E),i?.addEventListener("scroll",E,!0),{panel:f,close:w,place:E}}function re(t,n){let a=new Map;t.state.doc.forEach(e=>{if(e.type!==F.nodes.list_item||e.attrs.kind!=="check")return;let o=String(e.attrs.owner??"").trim();if(!o)return;let l=o.toLowerCase(),s=a.get(l)??{name:o,count:0};s.count+=1,a.set(l,s)});for(let e of n??[]){let o=String((typeof e=="string"?e:e?.name)??"").trim();o&&!a.has(o.toLowerCase())&&a.set(o.toLowerCase(),{name:o,count:0})}return[...a.values()].sort((e,o)=>e.name.localeCompare(o.name))}function ce(t,n,a){let e=a.ownerDocument,o=I(t,n)?.node.attrs.owner||"",{panel:l,close:s,place:i}=G(t,a,{className:"page-check-owner",label:"Assignee",check:"owner-panel",onKey:(r,u)=>{if(r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;r.preventDefault();let p=[...u.querySelectorAll("input, button:not([disabled])")],k=p.indexOf(e.activeElement),b=r.key==="ArrowDown"?1:-1;(k<0?b>0?p[0]:p[p.length-1]:p[(k+b+p.length)%p.length])?.focus()}}),y=c(e,"input","page-check-search",{type:"text",placeholder:"Find or type a name","aria-label":"Find or type a name"}),h=c(e,"div","page-check-people"),g=c(e,"button","page-check-person page-check-danger",{type:"button","data-check":"clear-owner"});g.append(q(e,L.clear),c(e,"span","page-check-person-name",{},"Remove assignee")),g.disabled=!o,g.addEventListener("click",()=>A(null)),l.append(y,c(e,"div","page-check-subhead",{},"People in this document"),h,c(e,"div","page-check-divider"),g);let f=[],A=r=>{s(),X(t,n,"owner",r)},E=(r,u)=>{let p=r.toLowerCase()===String(o).toLowerCase(),k=c(e,"button","page-check-person",{type:"button","data-check":"owner-option","data-name":r,"aria-pressed":String(p)});return k.append(ne(e,r),c(e,"span","page-check-person-name",{},r),c(e,"span","page-check-person-meta",{},`${u} ${u===1?"item":"items"}`)),p&&k.append(q(e,L.tick)),k.addEventListener("click",()=>A(r)),k},C=r=>{let u=c(e,"button","page-check-person",{type:"button","data-check":"owner-new","data-name":r}),p=c(e,"span","page-check-person-name",{},"Assign to ");return p.append(c(e,"strong",null,{},r)),u.append(q(e,L.plus),p,c(e,"span","page-check-person-meta",{},"New")),u.addEventListener("click",()=>A(r)),u},w=()=>{let r=y.value.trim(),u=r.toLowerCase(),p=re(t,f),k=[];r&&!p.some(b=>b.name.toLowerCase()===u)&&k.push(C(r));for(let b of p)u&&!b.name.toLowerCase().includes(u)||k.push(E(b.name,b.count));h.replaceChildren(...k)};y.addEventListener("keydown",r=>{if(r.stopPropagation(),r.key==="Escape"){r.preventDefault(),s({focusAnchor:!0});return}r.key==="Enter"&&(r.preventDefault(),h.querySelector("button[data-check]")?.click())}),y.addEventListener("input",w),w(),i(),y.focus();let d=globalThis.clay?.people?.available;d&&Promise.resolve().then(()=>d()).then(r=>{!N||N.panel!==l||(f=Array.isArray(r)?r:[],w())}).catch(()=>{})}var se=["January","February","March","April","May","June","July","August","September","October","November","December"],$=(t,n,a)=>new Date(t,n,a),ie=t=>t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),le=t=>t.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),W=t=>{if(!t||!B.test(t))return null;let[n,a,e]=t.split("-").map(Number);return $(n,a-1,e)};function de(t,n,a){let e=a.ownerDocument,o=I(t,n)?.node.attrs.due||null,l=S(),s=new Date,i=$(s.getFullYear(),s.getMonth(),s.getDate()),y=W(o)??i,h=y.getFullYear(),g=y.getMonth(),{panel:f,close:A,place:E}=G(t,a,{className:"page-check-date",label:"Due date",check:"date-panel",onKey:(m,D)=>Q(m,D)}),C=m=>{A(),X(t,n,"due",m)},w=c(e,"div","page-check-quick"),d=(m,D)=>{let M=$(i.getFullYear(),i.getMonth(),i.getDate()+D),x=c(e,"button","page-check-quick-row",{type:"button","data-check":"date-quick","data-date":S(M)});return x.append(q(e,L.calendar),c(e,"span","page-check-quick-label",{},m),c(e,"span","page-check-quick-meta",{},ie(M))),x.addEventListener("click",()=>C(S(M))),x};w.append(d("Today",0),d("Tomorrow",1),d("Next week",7));let r=c(e,"div","page-check-cal"),u=c(e,"div","page-check-cal-head"),p=c(e,"span","page-check-cal-month"),k=c(e,"span","page-check-cal-nav"),b=m=>{let D=$(h,g+m,1);h=D.getFullYear(),g=D.getMonth(),H()},U=c(e,"button","page-check-cal-btn",{type:"button","aria-label":"Previous month"}),O=c(e,"button","page-check-cal-btn",{type:"button","aria-label":"Next month"});U.append(q(e,L["chevron-left"])),O.append(q(e,L["chevron-right"])),U.addEventListener("click",()=>b(-1)),O.addEventListener("click",()=>b(1)),k.append(U,O),u.append(p,k);let Y=c(e,"div","page-check-cal-grid");r.append(u,Y);let H=()=>{p.replaceChildren(c(e,"span",null,{},`${se[g]} `),c(e,"span","page-check-cal-year",{},String(h)));let m=$(h,g,1),D=$(h,g+1,0).getDate(),M=Math.ceil((m.getDay()+D)/7)*7,x=["S","M","T","W","T","F","S"].map(v=>c(e,"span","page-check-cal-dow",{},v)),T=[];for(let v=0;v<M;v+=1){let P=$(h,g,1-m.getDay()+v),R=S(P),V=c(e,"button","page-check-cal-day",{type:"button","data-check":"date-day","data-date":R,"data-outside":String(P.getMonth()!==g),"data-today":String(R===l),"aria-pressed":String(R===o),"aria-label":le(P)},String(P.getDate()));V.addEventListener("click",()=>C(R)),T.push(V)}Y.replaceChildren(...x,...T)},Q=(m,D)=>{let M=e.activeElement?.closest?.('[data-check="date-day"]');if(!M)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),M.click();return}let x={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[m.key];if(!x)return;m.preventDefault();let T=W(M.dataset.date),v=$(T.getFullYear(),T.getMonth(),T.getDate()+x);(v.getMonth()!==g||v.getFullYear()!==h)&&(h=v.getFullYear(),g=v.getMonth(),H()),D.querySelector(`[data-check="date-day"][data-date="${S(v)}"]`)?.focus()},K=c(e,"button","page-check-quick-row page-check-danger",{type:"button","data-check":"clear-date"});K.append(q(e,L.clear),c(e,"span","page-check-quick-label",{},"Clear date")),K.disabled=!o,K.addEventListener("click",()=>C(null)),f.append(w,r,c(e,"div","page-check-divider"),K),H(),E(),(Y.querySelector('[data-check="date-day"][aria-pressed="true"]')??Y.querySelector('[data-check="date-day"][data-today="true"]'))?.focus()}function pe(t,n){let a=t.dom.ownerDocument,e=a.createElement("span");e.className="page-check-controls",e.contentEditable="false",e.dataset.empty=String(!n.attrs.owner&&!n.attrs.due);let o=S(),l=n.attrs.owner||"Unassigned",s=j(a,{name:"owner",paths:L.person,label:l,aria:`Assignee: ${l}`,filled:!!n.attrs.owner}),i=oe(n.attrs.due,o),y=!!n.attrs.due&&!n.attrs.checked&&B.test(n.attrs.due)&&n.attrs.due<o,h=j(a,{name:"date",paths:y?L.clock:L.calendar,label:i,aria:`Due date: ${i}`,filled:!!n.attrs.due,overdue:y});return s.addEventListener("click",()=>ce(t,n.attrs.id,s)),h.addEventListener("click",()=>de(t,n.attrs.id,h)),e.append(s,h),e}function ue(t,n){let a=t.state.selection.$head;if(a.depth!==1||a.parent.type!==F.nodes.list_item||a.parent.attrs.kind!=="check")return!1;let e=a.parent.attrs.id,l=[...t.dom.querySelectorAll(".page-check-controls")].find(s=>s.dataset.item===e)?.querySelector(`[data-check="${n}"]`);return l?(l.dataset.fromKeys="true",l.click(),!0):!1}function he(t){let n=[],a=S();return t.doc.forEach((e,o)=>{e.type!==F.nodes.list_item||e.attrs.kind!=="check"||n.push(ee.widget(o+e.nodeSize-1,l=>{let s=pe(l,e);return s.dataset.item=e.attrs.id,s},{key:`${e.attrs.id}:${e.attrs.owner}:${e.attrs.due}:${e.attrs.checked}:${a}`,side:-1,stopEvent:l=>!!l.target.closest?.(".page-check-chip, .page-check-popup"),ignoreSelection:!0}))}),te.create(t.doc,n)}function ge(t){let n=S(),a=()=>{t.isDestroyed||S()===n||(n=S(),t.dispatch(t.state.tr.setMeta("addToHistory",!1)))},e=t.dom.ownerDocument.defaultView,o=e.setInterval(a,6e4);return e.document.addEventListener("visibilitychange",a),()=>{e.clearInterval(o),e.document.removeEventListener("visibilitychange",a)}}function be({view:t=null}={}){let n=t?z(t,{decorations:he,focusControl:ue}):()=>{},a=t?ge(t):()=>{};return t&&!t.isDestroyed&&t.dispatch(t.state.tr.setMeta("addToHistory",!1)),{id:"checklist",dispose(){n(),a()}}}export{be as createFeature,he as decorations,ue as focusControl};
1
+ import{c as z}from"./c-W4JCVLAB.js";import{B as J}from"./c-TMT5TL65.js";import{d as _,m as F}from"./c-QIXT3Q7C.js";import"./c-VHNSBD2M.js";var{Decoration:ee,DecorationSet:te}=_,c=(t,n,a,e={},o=null)=>{let l=t.createElement(n);a&&(l.className=a);for(let[s,i]of Object.entries(e))i!=null&&i!==!1&&l.setAttribute(s,i===!0?"":String(i));return o!==null&&(l.textContent=o),l},ne=(t,n)=>c(t,"span","page-board-face",{"aria-hidden":"true"},([...String(n).trim()][0]??"?").toUpperCase());function I(t,n){let a=null;return t.state.doc.forEach((e,o)=>{e.attrs.id===n&&e.type===F.nodes.list_item&&e.attrs.kind==="check"&&(a={node:e,pos:o})}),a}function X(t,n,a,e){let o=I(t,n);o&&t.dispatch(J(t.state.tr.setNodeMarkup(o.pos,null,{...o.node.attrs,[a]:e||null})))}var L={person:'<circle cx="8" cy="5.4" r="2.3"/><path d="M3.6 13.2c.6-2.1 2.2-3.3 4.4-3.3s3.8 1.2 4.4 3.3"/>',calendar:'<rect x="2.5" y="3.5" width="11" height="10"/><path d="M2.5 6.8h11M5.5 2v2.4M10.5 2v2.4"/>',clock:'<circle cx="8" cy="8" r="5.5"/><path d="M8 4.8v3.4l2.3 1.4"/>',tick:'<path d="M3.5 8.3l3 3 6-6.2"/>',plus:'<path d="M8 3.5v9M3.5 8h9"/>',clear:'<path d="M4.8 4.8l6.4 6.4M11.2 4.8l-6.4 6.4"/>',"chevron-left":'<path d="M9.8 3.6L5.4 8l4.4 4.4"/>',"chevron-right":'<path d="M6.2 3.6L10.6 8l-4.4 4.4"/>'};function q(t,n){let a=t.createElementNS("http://www.w3.org/2000/svg","svg");return a.setAttribute("viewBox","0 0 16 16"),a.setAttribute("width","14"),a.setAttribute("height","14"),a.setAttribute("fill","none"),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("aria-hidden","true"),a.innerHTML=n,a}var Z=t=>String(t).padStart(2,"0"),B=/^\d{4}-\d{2}-\d{2}$/,S=(t=new Date)=>`${t.getFullYear()}-${Z(t.getMonth()+1)}-${Z(t.getDate())}`,ae=t=>{let n=new Date(`${t}T00:00:00Z`);return n.setUTCDate(n.getUTCDate()+1),n.toISOString().slice(0,10)};function oe(t,n){if(!t)return"No date";if(!B.test(t))return t;if(t===n)return"Today";if(t===ae(n))return"Tomorrow";let a=t.slice(0,4)===n.slice(0,4);return new Date(`${t}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",...a?{}:{year:"numeric"},timeZone:"UTC"})}function j(t,{name:n,paths:a,label:e,aria:o,filled:l,overdue:s=!1}){let i=c(t,"button","page-check-chip",{type:"button","data-check":n,"data-filled":String(l),"data-overdue":s?"true":null,"aria-expanded":"false","aria-label":o});return i.append(q(t,a),c(t,"span","page-check-chip-label",{},e)),i}var N=null;function G(t,n,{className:a,label:e,check:o,onKey:l=null}){let s=n.ownerDocument,i=s.defaultView;N&&N.close();for(let d of s.querySelectorAll(".page-check-popup"))d.remove();let y=t.dom.parentNode,h=["relative","absolute","fixed","sticky"].includes(i?.getComputedStyle?.(y)?.position??""),g=y&&h?y:s.body,f=c(s,"div",`page-check-popup ${a}`,{role:"dialog","aria-label":e,"data-check":o}),A=!1,E=()=>{let d=n.getBoundingClientRect(),r=g===s.body?{top:-(i?.scrollY??0),left:-(i?.scrollX??0)}:g.getBoundingClientRect(),u=f.getBoundingClientRect(),p=u.width||Math.min(264,(i?.innerWidth||292)-28),k=(i?.innerHeight??0)-d.bottom-2,b=u.height>0&&k<u.height;f.style.left=`${Math.round(d.right-p-r.left)}px`,f.style.top=`${Math.round((b?d.top-u.height-2:d.bottom+2)-r.top)}px`},C=d=>{if(!f.isConnected)return w();f.contains(d.target)||n.contains(d.target)||w()},w=({focusAnchor:d=!1}={})=>{if(A)return;A=!0,s.removeEventListener("mousedown",C,!0),i?.removeEventListener("resize",E),i?.removeEventListener("scroll",E,!0),N?.panel===f&&(N=null),f.remove(),n.setAttribute("aria-expanded","false");let r=n.dataset.fromKeys==="true";delete n.dataset.fromKeys,d&&r?t.focus():d&&n.focus()};return f.addEventListener("keydown",d=>{if(d.stopPropagation(),d.key==="Escape"){d.preventDefault(),w({focusAnchor:!0});return}l?.(d,f)}),g.append(f),n.setAttribute("aria-expanded","true"),N={panel:f,close:()=>w()},s.addEventListener("mousedown",C,!0),i?.addEventListener("resize",E),i?.addEventListener("scroll",E,!0),{panel:f,close:w,place:E}}function re(t,n){let a=new Map;t.state.doc.forEach(e=>{if(e.type!==F.nodes.list_item||e.attrs.kind!=="check")return;let o=String(e.attrs.owner??"").trim();if(!o)return;let l=o.toLowerCase(),s=a.get(l)??{name:o,count:0};s.count+=1,a.set(l,s)});for(let e of n??[]){let o=String((typeof e=="string"?e:e?.name)??"").trim();o&&!a.has(o.toLowerCase())&&a.set(o.toLowerCase(),{name:o,count:0})}return[...a.values()].sort((e,o)=>e.name.localeCompare(o.name))}function ce(t,n,a){let e=a.ownerDocument,o=I(t,n)?.node.attrs.owner||"",{panel:l,close:s,place:i}=G(t,a,{className:"page-check-owner",label:"Assignee",check:"owner-panel",onKey:(r,u)=>{if(r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;r.preventDefault();let p=[...u.querySelectorAll("input, button:not([disabled])")],k=p.indexOf(e.activeElement),b=r.key==="ArrowDown"?1:-1;(k<0?b>0?p[0]:p[p.length-1]:p[(k+b+p.length)%p.length])?.focus()}}),y=c(e,"input","page-check-search",{type:"text",placeholder:"Find or type a name","aria-label":"Find or type a name"}),h=c(e,"div","page-check-people"),g=c(e,"button","page-check-person page-check-danger",{type:"button","data-check":"clear-owner"});g.append(q(e,L.clear),c(e,"span","page-check-person-name",{},"Remove assignee")),g.disabled=!o,g.addEventListener("click",()=>A(null)),l.append(y,c(e,"div","page-check-subhead",{},"People in this document"),h,c(e,"div","page-check-divider"),g);let f=[],A=r=>{s(),X(t,n,"owner",r)},E=(r,u)=>{let p=r.toLowerCase()===String(o).toLowerCase(),k=c(e,"button","page-check-person",{type:"button","data-check":"owner-option","data-name":r,"aria-pressed":String(p)});return k.append(ne(e,r),c(e,"span","page-check-person-name",{},r),c(e,"span","page-check-person-meta",{},`${u} ${u===1?"item":"items"}`)),p&&k.append(q(e,L.tick)),k.addEventListener("click",()=>A(r)),k},C=r=>{let u=c(e,"button","page-check-person",{type:"button","data-check":"owner-new","data-name":r}),p=c(e,"span","page-check-person-name",{},"Assign to ");return p.append(c(e,"strong",null,{},r)),u.append(q(e,L.plus),p,c(e,"span","page-check-person-meta",{},"New")),u.addEventListener("click",()=>A(r)),u},w=()=>{let r=y.value.trim(),u=r.toLowerCase(),p=re(t,f),k=[];r&&!p.some(b=>b.name.toLowerCase()===u)&&k.push(C(r));for(let b of p)u&&!b.name.toLowerCase().includes(u)||k.push(E(b.name,b.count));h.replaceChildren(...k)};y.addEventListener("keydown",r=>{if(r.stopPropagation(),r.key==="Escape"){r.preventDefault(),s({focusAnchor:!0});return}r.key==="Enter"&&(r.preventDefault(),h.querySelector("button[data-check]")?.click())}),y.addEventListener("input",w),w(),i(),y.focus();let d=globalThis.clay?.people?.available;d&&Promise.resolve().then(()=>d()).then(r=>{!N||N.panel!==l||(f=Array.isArray(r)?r:[],w())}).catch(()=>{})}var se=["January","February","March","April","May","June","July","August","September","October","November","December"],$=(t,n,a)=>new Date(t,n,a),ie=t=>t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),le=t=>t.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),W=t=>{if(!t||!B.test(t))return null;let[n,a,e]=t.split("-").map(Number);return $(n,a-1,e)};function de(t,n,a){let e=a.ownerDocument,o=I(t,n)?.node.attrs.due||null,l=S(),s=new Date,i=$(s.getFullYear(),s.getMonth(),s.getDate()),y=W(o)??i,h=y.getFullYear(),g=y.getMonth(),{panel:f,close:A,place:E}=G(t,a,{className:"page-check-date",label:"Due date",check:"date-panel",onKey:(m,D)=>Q(m,D)}),C=m=>{A(),X(t,n,"due",m)},w=c(e,"div","page-check-quick"),d=(m,D)=>{let M=$(i.getFullYear(),i.getMonth(),i.getDate()+D),x=c(e,"button","page-check-quick-row",{type:"button","data-check":"date-quick","data-date":S(M)});return x.append(q(e,L.calendar),c(e,"span","page-check-quick-label",{},m),c(e,"span","page-check-quick-meta",{},ie(M))),x.addEventListener("click",()=>C(S(M))),x};w.append(d("Today",0),d("Tomorrow",1),d("Next week",7));let r=c(e,"div","page-check-cal"),u=c(e,"div","page-check-cal-head"),p=c(e,"span","page-check-cal-month"),k=c(e,"span","page-check-cal-nav"),b=m=>{let D=$(h,g+m,1);h=D.getFullYear(),g=D.getMonth(),H()},U=c(e,"button","page-check-cal-btn",{type:"button","aria-label":"Previous month"}),O=c(e,"button","page-check-cal-btn",{type:"button","aria-label":"Next month"});U.append(q(e,L["chevron-left"])),O.append(q(e,L["chevron-right"])),U.addEventListener("click",()=>b(-1)),O.addEventListener("click",()=>b(1)),k.append(U,O),u.append(p,k);let Y=c(e,"div","page-check-cal-grid");r.append(u,Y);let H=()=>{p.replaceChildren(c(e,"span",null,{},`${se[g]} `),c(e,"span","page-check-cal-year",{},String(h)));let m=$(h,g,1),D=$(h,g+1,0).getDate(),M=Math.ceil((m.getDay()+D)/7)*7,x=["S","M","T","W","T","F","S"].map(v=>c(e,"span","page-check-cal-dow",{},v)),T=[];for(let v=0;v<M;v+=1){let P=$(h,g,1-m.getDay()+v),R=S(P),V=c(e,"button","page-check-cal-day",{type:"button","data-check":"date-day","data-date":R,"data-outside":String(P.getMonth()!==g),"data-today":String(R===l),"aria-pressed":String(R===o),"aria-label":le(P)},String(P.getDate()));V.addEventListener("click",()=>C(R)),T.push(V)}Y.replaceChildren(...x,...T)},Q=(m,D)=>{let M=e.activeElement?.closest?.('[data-check="date-day"]');if(!M)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),M.click();return}let x={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[m.key];if(!x)return;m.preventDefault();let T=W(M.dataset.date),v=$(T.getFullYear(),T.getMonth(),T.getDate()+x);(v.getMonth()!==g||v.getFullYear()!==h)&&(h=v.getFullYear(),g=v.getMonth(),H()),D.querySelector(`[data-check="date-day"][data-date="${S(v)}"]`)?.focus()},K=c(e,"button","page-check-quick-row page-check-danger",{type:"button","data-check":"clear-date"});K.append(q(e,L.clear),c(e,"span","page-check-quick-label",{},"Clear date")),K.disabled=!o,K.addEventListener("click",()=>C(null)),f.append(w,r,c(e,"div","page-check-divider"),K),H(),E(),(Y.querySelector('[data-check="date-day"][aria-pressed="true"]')??Y.querySelector('[data-check="date-day"][data-today="true"]'))?.focus()}function pe(t,n){let a=t.dom.ownerDocument,e=a.createElement("span");e.className="page-check-controls",e.contentEditable="false",e.dataset.empty=String(!n.attrs.owner&&!n.attrs.due);let o=S(),l=n.attrs.owner||"Unassigned",s=j(a,{name:"owner",paths:L.person,label:l,aria:`Assignee: ${l}`,filled:!!n.attrs.owner}),i=oe(n.attrs.due,o),y=!!n.attrs.due&&!n.attrs.checked&&B.test(n.attrs.due)&&n.attrs.due<o,h=j(a,{name:"date",paths:y?L.clock:L.calendar,label:i,aria:`Due date: ${i}`,filled:!!n.attrs.due,overdue:y});return s.addEventListener("click",()=>ce(t,n.attrs.id,s)),h.addEventListener("click",()=>de(t,n.attrs.id,h)),e.append(s,h),e}function ue(t,n){let a=t.state.selection.$head;if(a.depth!==1||a.parent.type!==F.nodes.list_item||a.parent.attrs.kind!=="check")return!1;let e=a.parent.attrs.id,l=[...t.dom.querySelectorAll(".page-check-controls")].find(s=>s.dataset.item===e)?.querySelector(`[data-check="${n}"]`);return l?(l.dataset.fromKeys="true",l.click(),!0):!1}function he(t){let n=[],a=S();return t.doc.forEach((e,o)=>{e.type!==F.nodes.list_item||e.attrs.kind!=="check"||n.push(ee.widget(o+e.nodeSize-1,l=>{let s=pe(l,e);return s.dataset.item=e.attrs.id,s},{key:`${e.attrs.id}:${e.attrs.owner}:${e.attrs.due}:${e.attrs.checked}:${a}`,side:-1,stopEvent:l=>!!l.target.closest?.(".page-check-chip, .page-check-popup"),ignoreSelection:!0}))}),te.create(t.doc,n)}function ge(t){let n=S(),a=()=>{t.isDestroyed||S()===n||(n=S(),t.dispatch(t.state.tr.setMeta("addToHistory",!1)))},e=t.dom.ownerDocument.defaultView,o=e.setInterval(a,6e4);return e.document.addEventListener("visibilitychange",a),()=>{e.clearInterval(o),e.document.removeEventListener("visibilitychange",a)}}function be({view:t=null}={}){let n=t?z(t,{decorations:he,focusControl:ue}):()=>{},a=t?ge(t):()=>{};return t&&!t.isDestroyed&&t.dispatch(t.state.tr.setMeta("addToHistory",!1)),{id:"checklist",dispose(){n(),a()}}}export{be as createFeature,he as decorations,ue as focusControl};
@@ -1 +1 @@
1
- import{f as d}from"./c-RQRMPZXD.js";import"./c-WN3MXOLT.js";import{b as f,c as m}from"./c-RVMWGXEJ.js";import{b as o,c as r}from"./c-NUHP2XDB.js";import{e as c}from"./c-XGH4GS2T.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=30,b=6,e=null,u=null;function O(){return u??=Promise.all([import("./c-2ZZBC45O.js"),import("./c-ZE46QDIH.js")]).then(([n,t])=>e={pageScheme:n.pageScheme,paintLook:n.paintLook,RUNTIME_ONLY:n.RUNTIME_ONLY,TOKENS:t.TOKENS,SHADOW:t.SHADOW,FONT:`600 11px/1 ${t.FONT_MONO}`,LABEL_FONT:`500 11px/1.4 ${t.FONT_MONO}`}).catch(n=>{throw u=null,n}),u}var N=()=>O().then(()=>!0,()=>!1),a=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],T="#FFFCF6";function l(n){return n.setAttribute("clay",e.RUNTIME_ONLY),n}function E(n){return{people:n.people.map(i=>({id:i.id,name:i.name,you:i.you})),anonymous:n.anonymous}}var h=class{constructor(){this.roster={people:[],anonymous:0},this.root=null,this.stack=null,this.count=null,this.tip=null,this._gate=null}supported(){return this._gate||(this._gate=Promise.all([c("presence"),c("record-awareness-v1"),c("page-awareness-v1")]).then(([t,i,s])=>(d.setCapabilities({supported:t,recordAwareness:i,pageAwareness:s}),t===!0),()=>!1)),this._gate}async update(t){let i=E(d.receive(t)),s=this.root&&JSON.stringify(i)===JSON.stringify(this.roster);if(this.roster=i,!!await this.supported()){if(s){e.paintLook(this.root);return}await this.render()}}clear(){d.clear(),this.roster={people:[],anonymous:0},this.root&&(this.root.remove(),this.root=null,this.stack=null,this.count=null,this.tip=null)}async render(){let{people:t,anonymous:i}=this.roster;if(t.length+i<=1||window.clay?.menu){this.hide();return}if(await N()&&this.build()){this.hideTip(),this.stack.textContent="";for(let s of t)this.stack.appendChild(this.avatar(s));this.stack.firstElementChild&&o(this.stack.firstElementChild,"margin-left","0"),i>0?(this.count.textContent=`+${i} viewing`,o(this.count,"display","inline-block")):(this.count.textContent="",o(this.count,"display","none")),o(this.root,"display","flex"),e.paintLook(this.root)}}hide(){this.root&&(this.hideTip(),this.stack.textContent="",this.count.textContent="",o(this.root,"display","none"))}build(){return this.root?!0:typeof document>"u"||!document.body?!1:(this.root=l(r("div",[...a,`color-scheme:${e.pageScheme()}`,"position:fixed","top:calc(12px + env(safe-area-inset-top,0px))","right:calc(12px + env(safe-area-inset-right,0px))","z-index:2147483000","display:flex","align-items:center","gap:8px","max-width:calc(100vw - 24px)",`font:${e.LABEL_FONT}`,`color:${e.TOKENS.ink}`,"pointer-events:none"])),this.root.setAttribute("data-clay-presence",""),this.count=l(r("span",[...a,"box-sizing:border-box","flex:none","white-space:nowrap","padding:3px 8px","border-radius:0",`background:${e.TOKENS.surface}`,`color:${e.TOKENS.muted}`,`border:1px solid ${e.TOKENS["line-2"]}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none","pointer-events:none"])),this.count.setAttribute("data-clay-presence-count",""),this.stack=l(r("div",[...a,"display:flex","align-items:center","flex:none","pointer-events:none"])),this.tip=l(r("span",[...a,"position:absolute","top:100%","right:0","margin-top:6px","box-sizing:border-box","white-space:nowrap","pointer-events:none","padding:5px 9px","border-radius:0",`background:${e.TOKENS.ink}`,`color:${e.TOKENS.ground}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none"])),this.tip.setAttribute("data-clay-presence-tip",""),this.root.append(this.stack,this.count,this.tip),document.body.appendChild(this.root),!0)}avatar(t){let i=f(t.id),s=[`background-color:${T}`,`color:${i}`,`border-color:${i}`],p=l(r("div",[...a,"box-sizing:border-box","flex:none",`width:${x}px`,`height:${x}px`,"border-radius:0","display:flex","align-items:center","justify-content:center",`font:${e.FONT}`,"letter-spacing:.02em",`margin-left:-${b}px`,"border-width:2px","border-style:solid","background-image:none",`box-shadow:${e.SHADOW}`,"user-select:none","cursor:default","pointer-events:auto",...s],m(t.name)));p.setAttribute("data-clay-presence-avatar","");let g=t.you?`${t.name} (you)`:t.name;return p.addEventListener("mouseenter",()=>this.showTip(g)),p.addEventListener("mouseleave",()=>this.hideTip()),p}showTip(t){this.tip&&(this.tip.textContent=t,o(this.tip,"display","block"))}hideTip(){this.tip&&(this.tip.textContent="",o(this.tip,"display","none"))}},y=new h;typeof document<"u"&&document.addEventListener("clay:menu-ready",()=>y.render());var v=y;export{h as Presence,v as default,y as presence};
1
+ import{f as d}from"./c-RQRMPZXD.js";import"./c-WN3MXOLT.js";import{b as f,c as m}from"./c-RVMWGXEJ.js";import{b as o,c as r}from"./c-NUHP2XDB.js";import{e as c}from"./c-XGH4GS2T.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=30,b=6,e=null,u=null;function O(){return u??=Promise.all([import("./c-Z7RJANGO.js"),import("./c-3TLG3OLG.js")]).then(([n,t])=>e={pageScheme:n.pageScheme,paintLook:n.paintLook,RUNTIME_ONLY:n.RUNTIME_ONLY,TOKENS:t.TOKENS,SHADOW:t.SHADOW,FONT:`600 11px/1 ${t.FONT_MONO}`,LABEL_FONT:`500 11px/1.4 ${t.FONT_MONO}`}).catch(n=>{throw u=null,n}),u}var N=()=>O().then(()=>!0,()=>!1),a=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],T="#FFFCF6";function l(n){return n.setAttribute("clay",e.RUNTIME_ONLY),n}function E(n){return{people:n.people.map(i=>({id:i.id,name:i.name,you:i.you})),anonymous:n.anonymous}}var h=class{constructor(){this.roster={people:[],anonymous:0},this.root=null,this.stack=null,this.count=null,this.tip=null,this._gate=null}supported(){return this._gate||(this._gate=Promise.all([c("presence"),c("record-awareness-v1"),c("page-awareness-v1")]).then(([t,i,s])=>(d.setCapabilities({supported:t,recordAwareness:i,pageAwareness:s}),t===!0),()=>!1)),this._gate}async update(t){let i=E(d.receive(t)),s=this.root&&JSON.stringify(i)===JSON.stringify(this.roster);if(this.roster=i,!!await this.supported()){if(s){e.paintLook(this.root);return}await this.render()}}clear(){d.clear(),this.roster={people:[],anonymous:0},this.root&&(this.root.remove(),this.root=null,this.stack=null,this.count=null,this.tip=null)}async render(){let{people:t,anonymous:i}=this.roster;if(t.length+i<=1||window.clay?.menu){this.hide();return}if(await N()&&this.build()){this.hideTip(),this.stack.textContent="";for(let s of t)this.stack.appendChild(this.avatar(s));this.stack.firstElementChild&&o(this.stack.firstElementChild,"margin-left","0"),i>0?(this.count.textContent=`+${i} viewing`,o(this.count,"display","inline-block")):(this.count.textContent="",o(this.count,"display","none")),o(this.root,"display","flex"),e.paintLook(this.root)}}hide(){this.root&&(this.hideTip(),this.stack.textContent="",this.count.textContent="",o(this.root,"display","none"))}build(){return this.root?!0:typeof document>"u"||!document.body?!1:(this.root=l(r("div",[...a,`color-scheme:${e.pageScheme()}`,"position:fixed","top:calc(12px + env(safe-area-inset-top,0px))","right:calc(12px + env(safe-area-inset-right,0px))","z-index:2147483000","display:flex","align-items:center","gap:8px","max-width:calc(100vw - 24px)",`font:${e.LABEL_FONT}`,`color:${e.TOKENS.ink}`,"pointer-events:none"])),this.root.setAttribute("data-clay-presence",""),this.count=l(r("span",[...a,"box-sizing:border-box","flex:none","white-space:nowrap","padding:3px 8px","border-radius:0",`background:${e.TOKENS.surface}`,`color:${e.TOKENS.muted}`,`border:1px solid ${e.TOKENS["line-2"]}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none","pointer-events:none"])),this.count.setAttribute("data-clay-presence-count",""),this.stack=l(r("div",[...a,"display:flex","align-items:center","flex:none","pointer-events:none"])),this.tip=l(r("span",[...a,"position:absolute","top:100%","right:0","margin-top:6px","box-sizing:border-box","white-space:nowrap","pointer-events:none","padding:5px 9px","border-radius:0",`background:${e.TOKENS.ink}`,`color:${e.TOKENS.ground}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none"])),this.tip.setAttribute("data-clay-presence-tip",""),this.root.append(this.stack,this.count,this.tip),document.body.appendChild(this.root),!0)}avatar(t){let i=f(t.id),s=[`background-color:${T}`,`color:${i}`,`border-color:${i}`],p=l(r("div",[...a,"box-sizing:border-box","flex:none",`width:${x}px`,`height:${x}px`,"border-radius:0","display:flex","align-items:center","justify-content:center",`font:${e.FONT}`,"letter-spacing:.02em",`margin-left:-${b}px`,"border-width:2px","border-style:solid","background-image:none",`box-shadow:${e.SHADOW}`,"user-select:none","cursor:default","pointer-events:auto",...s],m(t.name)));p.setAttribute("data-clay-presence-avatar","");let g=t.you?`${t.name} (you)`:t.name;return p.addEventListener("mouseenter",()=>this.showTip(g)),p.addEventListener("mouseleave",()=>this.hideTip()),p}showTip(t){this.tip&&(this.tip.textContent=t,o(this.tip,"display","block"))}hideTip(){this.tip&&(this.tip.textContent="",o(this.tip,"display","none"))}},y=new h;typeof document<"u"&&document.addEventListener("clay:menu-ready",()=>y.render());var v=y;export{h as Presence,v as default,y as presence};
@@ -1 +1 @@
1
- import{c as h}from"./c-KBS3UV6B.js";import{i as k,j as y}from"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as g}from"./c-44B5ODN7.js";import{b as m,m as d}from"./c-QIXT3Q7C.js";import"./c-E4IBSAQM.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var b=e=>String(e).padStart(2,"0");function A(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let s=new Date(`${e}T12:00:00Z`);return Number.isFinite(s.valueOf())&&s.toISOString().slice(0,10)===e}var $=(e=new Date)=>`${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,E=(e,s)=>{let a=new Date(`${e}T12:00:00Z`);return a.setUTCDate(a.getUTCDate()+s),a.toISOString().slice(0,10)},I=e=>{let s=E(e,1);return[{id:"today",name:`Today (${e})`,date:e},{id:"tomorrow",name:`Tomorrow (${s})`,date:s}]};function L({view:e=null}={}){if(!e)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let s=e.dom.ownerDocument,a=null;function l(t){let o=e.state;if(!o.selection.empty||o.selection.from!==t.from||t.from<0||t.from>o.doc.content.size)return null;let r=o.doc.resolve(t.from);return!r.parent.isTextblock||r.parent.type.spec.code||!r.parent.type.allowsMarkType(d.marks.date)?null:t.from}function D(t){try{let o=e.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=e.coordsAtPos(t.from);return{x:Math.max(8,r.left-o.left),y:r.bottom+6-o.top}}catch{return null}}function u(t){let o=t.picker.activeId();o?e.dom.setAttribute("aria-activedescendant",o):e.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&e.dom.removeAttribute("aria-activedescendant")}function c(){let t=a;if(t){a=null;for(let[o,r,n,i]of t.listen)o.removeEventListener(r,n,i);e.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&e.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function x(t,o){let r=String(o),n=e.state.tr.insertText(r,t,t);return n.addMark(t,t+r.length,d.marks.date.create({date:r})),n.insertText(" ",t+r.length),n.setSelection(m.TextSelection.create(n.doc,t+r.length+1)),e.dispatch(g(n)),e.focus(),{ok:!0,date:r}}async function f(t){let o=a;if(!o)return{ok:!1,code:"not-editing"};let r=o.picker.personAt(t),n=l(o);return n===null||!r||!A(r.date)?(c(),r?n===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-date"}:{ok:!1,code:"no-date"}):(c(),k(e,()=>{let i=l(o);return i===null?{ok:!1,code:"stale-target"}:x(i,r.date)}))}function S(t){let o=a;if(!o||y(t,e))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),o.picker.move(t.key==="ArrowDown"?1:-1),u(o)):t.key==="Enter"?(r(),f(o.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),c())}function T(){c();let t={from:e.state.selection.from,days:I($()),picker:null,listen:[]};t.picker=h({document:s,label:"Insert a date",empty:"No date to insert",onPick:r=>f(r)}),a=t;let o=(r,n,i,p)=>{r.addEventListener(n,i,p),t.listen.push([r,n,i,p])};return o(s,"keydown",r=>S(r),!0),o(e.dom,"input",()=>c()),o(s,"mousedown",r=>{t.picker.el.contains(r.target)||c()},!0),(e.dom.parentElement??s.body).appendChild(t.picker.el),l(t)===null?(c(),{ok:!1,code:"stale-target"}):(t.picker.show(t.days,D(t)),u(t),{ok:!0,picker:!0})}return{async run(){return T()},dispose(){c()}}}export{L as createFeature,I as earlyDays,A as isISODate,$ as localISODate};
1
+ import{c as h}from"./c-KBS3UV6B.js";import{i as k,j as y}from"./c-4RFZROCF.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-4TWARTLS.js";import"./c-Q5KAQJAG.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as g}from"./c-TMT5TL65.js";import{b as m,m as d}from"./c-QIXT3Q7C.js";import"./c-OI2BYWVV.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var b=e=>String(e).padStart(2,"0");function A(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let s=new Date(`${e}T12:00:00Z`);return Number.isFinite(s.valueOf())&&s.toISOString().slice(0,10)===e}var $=(e=new Date)=>`${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,E=(e,s)=>{let a=new Date(`${e}T12:00:00Z`);return a.setUTCDate(a.getUTCDate()+s),a.toISOString().slice(0,10)},I=e=>{let s=E(e,1);return[{id:"today",name:`Today (${e})`,date:e},{id:"tomorrow",name:`Tomorrow (${s})`,date:s}]};function L({view:e=null}={}){if(!e)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let s=e.dom.ownerDocument,a=null;function l(t){let o=e.state;if(!o.selection.empty||o.selection.from!==t.from||t.from<0||t.from>o.doc.content.size)return null;let r=o.doc.resolve(t.from);return!r.parent.isTextblock||r.parent.type.spec.code||!r.parent.type.allowsMarkType(d.marks.date)?null:t.from}function D(t){try{let o=e.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=e.coordsAtPos(t.from);return{x:Math.max(8,r.left-o.left),y:r.bottom+6-o.top}}catch{return null}}function u(t){let o=t.picker.activeId();o?e.dom.setAttribute("aria-activedescendant",o):e.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&e.dom.removeAttribute("aria-activedescendant")}function c(){let t=a;if(t){a=null;for(let[o,r,n,i]of t.listen)o.removeEventListener(r,n,i);e.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&e.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function x(t,o){let r=String(o),n=e.state.tr.insertText(r,t,t);return n.addMark(t,t+r.length,d.marks.date.create({date:r})),n.insertText(" ",t+r.length),n.setSelection(m.TextSelection.create(n.doc,t+r.length+1)),e.dispatch(g(n)),e.focus(),{ok:!0,date:r}}async function f(t){let o=a;if(!o)return{ok:!1,code:"not-editing"};let r=o.picker.personAt(t),n=l(o);return n===null||!r||!A(r.date)?(c(),r?n===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-date"}:{ok:!1,code:"no-date"}):(c(),k(e,()=>{let i=l(o);return i===null?{ok:!1,code:"stale-target"}:x(i,r.date)}))}function S(t){let o=a;if(!o||y(t,e))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),o.picker.move(t.key==="ArrowDown"?1:-1),u(o)):t.key==="Enter"?(r(),f(o.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),c())}function T(){c();let t={from:e.state.selection.from,days:I($()),picker:null,listen:[]};t.picker=h({document:s,label:"Insert a date",empty:"No date to insert",onPick:r=>f(r)}),a=t;let o=(r,n,i,p)=>{r.addEventListener(n,i,p),t.listen.push([r,n,i,p])};return o(s,"keydown",r=>S(r),!0),o(e.dom,"input",()=>c()),o(s,"mousedown",r=>{t.picker.el.contains(r.target)||c()},!0),(e.dom.parentElement??s.body).appendChild(t.picker.el),l(t)===null?(c(),{ok:!1,code:"stale-target"}):(t.picker.show(t.days,D(t)),u(t),{ok:!0,picker:!0})}return{async run(){return T()},dispose(){c()}}}export{L as createFeature,I as earlyDays,A as isISODate,$ as localISODate};
@@ -1 +1 @@
1
- import{B as H,C as X,d as M,g as L,h as O,j as D,l as I,m as R,n as x,o as C,p as A,q as N,s as $}from"./c-44B5ODN7.js";import{m as B}from"./c-QIXT3Q7C.js";var _=new WeakMap;function v(s){let t=_.get(s);return t||_.set(s,t=O(s)),t}var F=B.nodes,w=s=>s.type===F.list_item,S=s=>s.type===F.toggle,y=s=>s.attrs.parent??null;function J(s,t,e){if(e<0)return[null];let n=[],i=s[e].node;S(i)&&i.attrs.open&&!s[e].hidden&&n.unshift(i.attrs.id);for(let r=y(i);r!==null&&!n.includes(r);){let c=s[t.get(r)];if(!c)break;n.unshift(r),r=y(c.node)}let o=[null];for(let r of n){let c=s[t.get(r)];if(!c.node.attrs.open||c.hidden)break;o.push(r)}return o}function Y(s,t,e,n){let i=y(s[t].node),o=w(s[t].node)?n.indent-s[t].node.attrs.indent:0;return r=>r.i<t||r.i>e||y(r.node)!==i?null:w(r.node)?{parent:n.parent,indent:r.node.attrs.indent+o}:{parent:n.parent}}function Q(s,t){let e=null;s.doc.forEach((n,i)=>{n.attrs.id===t&&S(n)&&(e={n,off:i})}),e&&!e.n.attrs.open&&s.setNodeMarkup(e.off,null,{...e.n.attrs,open:!0})}function P(s,t,e,n,i,o=null){let r=Y(t,e,n,i),c=t[e].at,d=t[n].end,h=o??new C(s.doc.resolve(c),s.doc.resolve(d)),a;if(i.at===c||i.at===d){a=s.tr;for(let l=e;l<=n;l++){let p=r(t[l]);p&&a.setNodeMarkup(t[l].at,null,{...t[l].node.attrs,...p})}a.setSelection(h.map(a.doc,a.mapping)),a.setMeta(L,A(t,e,n,i.at,r))}else a=N(s,t,e,n,i.at,r,h);if(i.open){Q(a,i.open);let l=a.getMeta(L);l&&a.setMeta(L,{...l,attrs:{...l.attrs,[i.open]:{open:!0}}})}return a}function K(s,t,e,n,i){if(i.parent!=null&&t.slice(e,n+1).some(a=>a.node.attrs.id===i.parent))return!1;let o=t[n].end-t[e].at,r=Y(t,e,n,i);for(let a=e;a<=n;a++)if(w(t[a].node)&&(r(t[a])?.indent??t[a].node.attrs.indent)>$)return!1;let c=P(s,t,e,n,i),h=i.at===t[e].at||i.at===t[n].end?t[e].at:i.at>t[e].at?i.at-o:i.at;return D(c.doc,s.doc).every(a=>a.at>=h&&a.at<h+o)}function U(s,t,e,n,i){let o=new Map;t.forEach(l=>{S(l.node)&&l.node.attrs.id&&o.set(l.node.attrs.id,l.i)});let r=i<0?s.doc.content.size:t[i].at;if(r>t[e].at&&r<t[n].end)return[];let c=(i<0?t.length:i)-1,d=J(t,o,c),h=d.indexOf(i<0?null:y(t[i].node)),a=[];for(let l of d.slice(Math.max(0,h))){let p=l===null?0:t[o.get(l)].depth+1,E=c>=0&&w(t[c].node)&&y(t[c].node)===l?t[c].node:null,f=w(t[e].node)&&E?E.attrs.indent+1:0;for(let u=0;u<=f;u++){let m={at:r,parent:l,indent:u,depth:p+(w(t[e].node)?u:0)};K(s,t,e,n,m)&&a.push(m)}}return a}function q(s,t,e,n,i){let o=t[i];if(!o||!S(o.node)||o.node.attrs.open||o.hidden||i>=e&&i<=n||o.at>t[e].at&&o.at<t[n].end)return null;let r=o.node.attrs.id,c={at:t[o.subEnd].end,parent:r,indent:0,depth:o.depth+1,open:r};return K(s,t,e,n,c)?c:null}function z(s,t){let e=null;for(let n of s)(!e||Math.abs(n.depth-t)<Math.abs(e.depth-t))&&(e=n);return e}var Z=4,tt=250,V=8,b=56,W=18;function et(s){for(let t=s.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e==="auto"||e==="scroll")&&t.scrollHeight>t.clientHeight)return t}return s.ownerDocument.scrollingElement}var j=new WeakMap;function nt(s,t){let e=j.get(s);if(!e){e=[];for(let n of s){if(n.hidden)continue;let i=t.nodeDOM(n.at);i?.getBoundingClientRect&&e.push({i:n.i,dom:i})}j.set(s,e)}return e}function it(s,t){let e=0,n=s.length;for(;e<n;){let i=e+n>>1,o=s[i].dom.getBoundingClientRect();t<o.top+o.height/2?n=i:e=i+1}return e<s.length?e:-1}var G=class{constructor(t,e,{index:n,onClick:i}){this.view=t,this.grip=e,this.index=n,this.onClick=i,this.shell=t.dom.parentElement,this.line=document.createElement("div"),this.line.className="page-drop",this.line.hidden=!0,this.line.setAttribute("aria-hidden","true"),this.shell.append(this.line),this.state=null,this.onMove=o=>this.move(o),this.onUp=o=>this.end(o),this.onCancel=o=>{o.pointerId===this.state?.pointer&&this.cancel()},this.onKey=o=>{o.key==="Escape"&&this.state?.active&&(o.preventDefault(),o.stopPropagation(),this.cancel())},this.onOther=o=>{this.state&&o.pointerId!==this.state.pointer&&this.cancel()},this.onBlur=()=>this.cancel(),this.onScroll=()=>{this.state&&!this.state.active&&this.stop()},e.addEventListener("pointerdown",o=>this.start(o))}start(t){if(t.button!==0||this.state)return;let e=this.view.state,n=v(e.doc),i=e.selection,o=Math.min(this.index(),n.length-1),r=i instanceof C&&n[o].at>=i.from&&n[o].end<=i.to,{lo:c,hi:d}=r?i.span(e.doc):I(n,o,o);if(this.state={index:o,span:R(n,c,d),touch:t.pointerType==="touch",pointer:t.pointerId,x0:t.clientX,y0:t.clientY,x:t.clientX,y:t.clientY,hold:0,active:!1,raf:0,gap:void 0,targets:[],target:null},this.grip.setPointerCapture?.(t.pointerId),this.grip.addEventListener("pointermove",this.onMove),this.grip.addEventListener("pointerup",this.onUp),this.grip.addEventListener("pointercancel",this.onCancel),this.grip.addEventListener("lostpointercapture",this.onCancel),this.state.touch){let h=this.state;h.hold=setTimeout(()=>this.held(h),tt),window.addEventListener("pointerdown",this.onOther,!0),window.addEventListener("blur",this.onBlur),window.addEventListener("scroll",this.onScroll,!0)}t.preventDefault()}held(t){if(!(this.state!==t||t.active)){if(t.hold=0,Math.hypot(t.x-t.x0,t.y-t.y0)>V||!this.view.editable)return this.stop();this.begin()}}move(t){let e=this.state;if(!(!e||t.pointerId!==e.pointer)){if(e.x=t.clientX,e.y=t.clientY,e.touch&&!this.view.editable)return e.active?this.cancel():this.stop();if(!e.active){let n=Math.hypot(e.x-e.x0,e.y-e.y0);if(e.touch){n>V&&this.stop();return}if(n<=Z)return;this.begin()}this.track()}}begin(){let t=this.state;if(!t||t.active)return;let e=this.view.state,n=v(e.doc),i=x(n,t.span);if(!i)return this.cancel();t.active=!0,this.view.dispatch(e.tr.setSelection(X(e.doc,i.lo,i.hi))),this.shell.classList.add("is-dragging");let o=this.shell.appendChild(document.createElement("div"));o.style.cssText="position:absolute;visibility:hidden;width:var(--page-indent)",this.indentPx=o.getBoundingClientRect().width||27,o.remove(),this.scroller=et(this.view.dom),window.addEventListener("keydown",this.onKey,!0),this.loop(),this.track()}track(){let t=this.state,e=this.view,n=e.state;if(!t)return;let i=v(n.doc),o=x(i,t.span);if(!o)return this.cancel();let{lo:r,hi:c}=o,d=nt(i,e),h=it(d,t.y),a=-1,l=null,p=null,E=h<0?d.length:h+1;for(let k=Math.max(0,E-2);k<E;k++){let g=d[k].dom.getBoundingClientRect();t.y>=g.top+g.height/4&&t.y<=g.bottom-g.height/4&&(p={i:d[k].i,bottom:g.bottom}),l=g.bottom+2}h>=0&&(a=d[h].i,l=d[h].dom.getBoundingClientRect().top-2);let f=r<0?null:p&&q(n,i,r,c,p.i),u=f?`summary:${p.i}`:a;(u!==t.gap||n.doc!==t.doc)&&(t.gap=u,t.doc=n.doc,t.targets=r<0?[]:f?[f]:U(n,i,r,c,a)),f&&(l=p.bottom+2);let m=e.dom.getBoundingClientRect().left;t.target=z(t.targets,(t.x-m)/this.indentPx);let T=this.shell.getBoundingClientRect();if(!t.target||l===null){this.line.hidden=!0,this.shell.dataset.drop="none";return}this.shell.dataset.drop="ok",this.line.hidden=!1,this.line.style.setProperty("--page-drop-y",`${l-T.top}px`),this.line.style.setProperty("--page-drop-x",`${m-T.left+t.target.depth*this.indentPx}px`),this.line.style.setProperty("--page-drop-w",`${e.dom.getBoundingClientRect().right-m-t.target.depth*this.indentPx}px`)}loop(){let t=()=>{let e=this.state;if(!e?.active)return;if(e.touch&&!this.view.editable)return this.cancel();let n=this.scroller,i=n===n.ownerDocument.scrollingElement?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect(),o=0;e.y<i.top+b?o=-W*Math.min(1,(i.top+b-e.y)/b):e.y>i.bottom-b&&(o=W*Math.min(1,(e.y-(i.bottom-b))/b)),o&&(n.scrollTop+=o,this.track()),e.raf=requestAnimationFrame(t)};this.state.raf=requestAnimationFrame(t)}end(t){let e=this.state;if(!e||t.pointerId!==e.pointer)return;if(!e.active){if(this.stop(),t.type==="pointerup"){let l=v(this.view.state.doc),p=x(l,e.span);p&&this.onClick(p.lo)}return}if(this.track(),this.state!==e)return;let n=e.target,i=this.view.state,o=v(i.doc),r=x(o,e.span);if(this.stop(),!n||!r)return;let{lo:c,hi:d}=r;if(!n.open&&(n.at===o[c].at||n.at===o[d].end)&&n.parent===(o[c].node.attrs.parent??null)&&(o[c].node.type.name!=="list_item"||n.indent===o[c].node.attrs.indent))return;if(this.view.dispatch(H(P(i,o,c,d,n)).scrollIntoView()),this.view.state.doc===i.doc)return M(this.view,"Move cancelled");let a=d-c+1;M(this.view,`Moved ${a} ${a===1?"block":"blocks"}`),this.view.focus()}cancel(){this.stop(),M(this.view,"Move cancelled")}stop(){let t=this.state;t&&(this.state=null,clearTimeout(t.hold),cancelAnimationFrame(t.raf),this.grip.removeEventListener("pointermove",this.onMove),this.grip.removeEventListener("pointerup",this.onUp),this.grip.removeEventListener("pointercancel",this.onCancel),this.grip.removeEventListener("lostpointercapture",this.onCancel),this.grip.releasePointerCapture?.(t.pointer),window.removeEventListener("pointerdown",this.onOther,!0),window.removeEventListener("blur",this.onBlur),window.removeEventListener("scroll",this.onScroll,!0),window.removeEventListener("keydown",this.onKey,!0),this.shell.classList.remove("is-dragging"),delete this.shell.dataset.drop,this.line.hidden=!0)}destroy(){this.stop(),this.line.remove()}};export{v as a,et as b,G as c};
1
+ import{B as H,C as X,d as M,g as L,h as O,j as D,l as I,m as R,n as x,o as C,p as A,q as N,s as $}from"./c-TMT5TL65.js";import{m as B}from"./c-QIXT3Q7C.js";var _=new WeakMap;function v(s){let t=_.get(s);return t||_.set(s,t=O(s)),t}var F=B.nodes,w=s=>s.type===F.list_item,S=s=>s.type===F.toggle,y=s=>s.attrs.parent??null;function J(s,t,e){if(e<0)return[null];let n=[],i=s[e].node;S(i)&&i.attrs.open&&!s[e].hidden&&n.unshift(i.attrs.id);for(let r=y(i);r!==null&&!n.includes(r);){let c=s[t.get(r)];if(!c)break;n.unshift(r),r=y(c.node)}let o=[null];for(let r of n){let c=s[t.get(r)];if(!c.node.attrs.open||c.hidden)break;o.push(r)}return o}function Y(s,t,e,n){let i=y(s[t].node),o=w(s[t].node)?n.indent-s[t].node.attrs.indent:0;return r=>r.i<t||r.i>e||y(r.node)!==i?null:w(r.node)?{parent:n.parent,indent:r.node.attrs.indent+o}:{parent:n.parent}}function Q(s,t){let e=null;s.doc.forEach((n,i)=>{n.attrs.id===t&&S(n)&&(e={n,off:i})}),e&&!e.n.attrs.open&&s.setNodeMarkup(e.off,null,{...e.n.attrs,open:!0})}function P(s,t,e,n,i,o=null){let r=Y(t,e,n,i),c=t[e].at,d=t[n].end,h=o??new C(s.doc.resolve(c),s.doc.resolve(d)),a;if(i.at===c||i.at===d){a=s.tr;for(let l=e;l<=n;l++){let p=r(t[l]);p&&a.setNodeMarkup(t[l].at,null,{...t[l].node.attrs,...p})}a.setSelection(h.map(a.doc,a.mapping)),a.setMeta(L,A(t,e,n,i.at,r))}else a=N(s,t,e,n,i.at,r,h);if(i.open){Q(a,i.open);let l=a.getMeta(L);l&&a.setMeta(L,{...l,attrs:{...l.attrs,[i.open]:{open:!0}}})}return a}function K(s,t,e,n,i){if(i.parent!=null&&t.slice(e,n+1).some(a=>a.node.attrs.id===i.parent))return!1;let o=t[n].end-t[e].at,r=Y(t,e,n,i);for(let a=e;a<=n;a++)if(w(t[a].node)&&(r(t[a])?.indent??t[a].node.attrs.indent)>$)return!1;let c=P(s,t,e,n,i),h=i.at===t[e].at||i.at===t[n].end?t[e].at:i.at>t[e].at?i.at-o:i.at;return D(c.doc,s.doc).every(a=>a.at>=h&&a.at<h+o)}function U(s,t,e,n,i){let o=new Map;t.forEach(l=>{S(l.node)&&l.node.attrs.id&&o.set(l.node.attrs.id,l.i)});let r=i<0?s.doc.content.size:t[i].at;if(r>t[e].at&&r<t[n].end)return[];let c=(i<0?t.length:i)-1,d=J(t,o,c),h=d.indexOf(i<0?null:y(t[i].node)),a=[];for(let l of d.slice(Math.max(0,h))){let p=l===null?0:t[o.get(l)].depth+1,E=c>=0&&w(t[c].node)&&y(t[c].node)===l?t[c].node:null,f=w(t[e].node)&&E?E.attrs.indent+1:0;for(let u=0;u<=f;u++){let m={at:r,parent:l,indent:u,depth:p+(w(t[e].node)?u:0)};K(s,t,e,n,m)&&a.push(m)}}return a}function q(s,t,e,n,i){let o=t[i];if(!o||!S(o.node)||o.node.attrs.open||o.hidden||i>=e&&i<=n||o.at>t[e].at&&o.at<t[n].end)return null;let r=o.node.attrs.id,c={at:t[o.subEnd].end,parent:r,indent:0,depth:o.depth+1,open:r};return K(s,t,e,n,c)?c:null}function z(s,t){let e=null;for(let n of s)(!e||Math.abs(n.depth-t)<Math.abs(e.depth-t))&&(e=n);return e}var Z=4,tt=250,V=8,b=56,W=18;function et(s){for(let t=s.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e==="auto"||e==="scroll")&&t.scrollHeight>t.clientHeight)return t}return s.ownerDocument.scrollingElement}var j=new WeakMap;function nt(s,t){let e=j.get(s);if(!e){e=[];for(let n of s){if(n.hidden)continue;let i=t.nodeDOM(n.at);i?.getBoundingClientRect&&e.push({i:n.i,dom:i})}j.set(s,e)}return e}function it(s,t){let e=0,n=s.length;for(;e<n;){let i=e+n>>1,o=s[i].dom.getBoundingClientRect();t<o.top+o.height/2?n=i:e=i+1}return e<s.length?e:-1}var G=class{constructor(t,e,{index:n,onClick:i}){this.view=t,this.grip=e,this.index=n,this.onClick=i,this.shell=t.dom.parentElement,this.line=document.createElement("div"),this.line.className="page-drop",this.line.hidden=!0,this.line.setAttribute("aria-hidden","true"),this.shell.append(this.line),this.state=null,this.onMove=o=>this.move(o),this.onUp=o=>this.end(o),this.onCancel=o=>{o.pointerId===this.state?.pointer&&this.cancel()},this.onKey=o=>{o.key==="Escape"&&this.state?.active&&(o.preventDefault(),o.stopPropagation(),this.cancel())},this.onOther=o=>{this.state&&o.pointerId!==this.state.pointer&&this.cancel()},this.onBlur=()=>this.cancel(),this.onScroll=()=>{this.state&&!this.state.active&&this.stop()},e.addEventListener("pointerdown",o=>this.start(o))}start(t){if(t.button!==0||this.state)return;let e=this.view.state,n=v(e.doc),i=e.selection,o=Math.min(this.index(),n.length-1),r=i instanceof C&&n[o].at>=i.from&&n[o].end<=i.to,{lo:c,hi:d}=r?i.span(e.doc):I(n,o,o);if(this.state={index:o,span:R(n,c,d),touch:t.pointerType==="touch",pointer:t.pointerId,x0:t.clientX,y0:t.clientY,x:t.clientX,y:t.clientY,hold:0,active:!1,raf:0,gap:void 0,targets:[],target:null},this.grip.setPointerCapture?.(t.pointerId),this.grip.addEventListener("pointermove",this.onMove),this.grip.addEventListener("pointerup",this.onUp),this.grip.addEventListener("pointercancel",this.onCancel),this.grip.addEventListener("lostpointercapture",this.onCancel),this.state.touch){let h=this.state;h.hold=setTimeout(()=>this.held(h),tt),window.addEventListener("pointerdown",this.onOther,!0),window.addEventListener("blur",this.onBlur),window.addEventListener("scroll",this.onScroll,!0)}t.preventDefault()}held(t){if(!(this.state!==t||t.active)){if(t.hold=0,Math.hypot(t.x-t.x0,t.y-t.y0)>V||!this.view.editable)return this.stop();this.begin()}}move(t){let e=this.state;if(!(!e||t.pointerId!==e.pointer)){if(e.x=t.clientX,e.y=t.clientY,e.touch&&!this.view.editable)return e.active?this.cancel():this.stop();if(!e.active){let n=Math.hypot(e.x-e.x0,e.y-e.y0);if(e.touch){n>V&&this.stop();return}if(n<=Z)return;this.begin()}this.track()}}begin(){let t=this.state;if(!t||t.active)return;let e=this.view.state,n=v(e.doc),i=x(n,t.span);if(!i)return this.cancel();t.active=!0,this.view.dispatch(e.tr.setSelection(X(e.doc,i.lo,i.hi))),this.shell.classList.add("is-dragging");let o=this.shell.appendChild(document.createElement("div"));o.style.cssText="position:absolute;visibility:hidden;width:var(--page-indent)",this.indentPx=o.getBoundingClientRect().width||27,o.remove(),this.scroller=et(this.view.dom),window.addEventListener("keydown",this.onKey,!0),this.loop(),this.track()}track(){let t=this.state,e=this.view,n=e.state;if(!t)return;let i=v(n.doc),o=x(i,t.span);if(!o)return this.cancel();let{lo:r,hi:c}=o,d=nt(i,e),h=it(d,t.y),a=-1,l=null,p=null,E=h<0?d.length:h+1;for(let k=Math.max(0,E-2);k<E;k++){let g=d[k].dom.getBoundingClientRect();t.y>=g.top+g.height/4&&t.y<=g.bottom-g.height/4&&(p={i:d[k].i,bottom:g.bottom}),l=g.bottom+2}h>=0&&(a=d[h].i,l=d[h].dom.getBoundingClientRect().top-2);let f=r<0?null:p&&q(n,i,r,c,p.i),u=f?`summary:${p.i}`:a;(u!==t.gap||n.doc!==t.doc)&&(t.gap=u,t.doc=n.doc,t.targets=r<0?[]:f?[f]:U(n,i,r,c,a)),f&&(l=p.bottom+2);let m=e.dom.getBoundingClientRect().left;t.target=z(t.targets,(t.x-m)/this.indentPx);let T=this.shell.getBoundingClientRect();if(!t.target||l===null){this.line.hidden=!0,this.shell.dataset.drop="none";return}this.shell.dataset.drop="ok",this.line.hidden=!1,this.line.style.setProperty("--page-drop-y",`${l-T.top}px`),this.line.style.setProperty("--page-drop-x",`${m-T.left+t.target.depth*this.indentPx}px`),this.line.style.setProperty("--page-drop-w",`${e.dom.getBoundingClientRect().right-m-t.target.depth*this.indentPx}px`)}loop(){let t=()=>{let e=this.state;if(!e?.active)return;if(e.touch&&!this.view.editable)return this.cancel();let n=this.scroller,i=n===n.ownerDocument.scrollingElement?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect(),o=0;e.y<i.top+b?o=-W*Math.min(1,(i.top+b-e.y)/b):e.y>i.bottom-b&&(o=W*Math.min(1,(e.y-(i.bottom-b))/b)),o&&(n.scrollTop+=o,this.track()),e.raf=requestAnimationFrame(t)};this.state.raf=requestAnimationFrame(t)}end(t){let e=this.state;if(!e||t.pointerId!==e.pointer)return;if(!e.active){if(this.stop(),t.type==="pointerup"){let l=v(this.view.state.doc),p=x(l,e.span);p&&this.onClick(p.lo)}return}if(this.track(),this.state!==e)return;let n=e.target,i=this.view.state,o=v(i.doc),r=x(o,e.span);if(this.stop(),!n||!r)return;let{lo:c,hi:d}=r;if(!n.open&&(n.at===o[c].at||n.at===o[d].end)&&n.parent===(o[c].node.attrs.parent??null)&&(o[c].node.type.name!=="list_item"||n.indent===o[c].node.attrs.indent))return;if(this.view.dispatch(H(P(i,o,c,d,n)).scrollIntoView()),this.view.state.doc===i.doc)return M(this.view,"Move cancelled");let a=d-c+1;M(this.view,`Moved ${a} ${a===1?"block":"blocks"}`),this.view.focus()}cancel(){this.stop(),M(this.view,"Move cancelled")}stop(){let t=this.state;t&&(this.state=null,clearTimeout(t.hold),cancelAnimationFrame(t.raf),this.grip.removeEventListener("pointermove",this.onMove),this.grip.removeEventListener("pointerup",this.onUp),this.grip.removeEventListener("pointercancel",this.onCancel),this.grip.removeEventListener("lostpointercapture",this.onCancel),this.grip.releasePointerCapture?.(t.pointer),window.removeEventListener("pointerdown",this.onOther,!0),window.removeEventListener("blur",this.onBlur),window.removeEventListener("scroll",this.onScroll,!0),window.removeEventListener("keydown",this.onKey,!0),this.shell.classList.remove("is-dragging"),delete this.shell.dataset.drop,this.line.hidden=!0)}destroy(){this.stop(),this.line.remove()}};export{v as a,et as b,G as c};
@@ -1 +1 @@
1
- import{a}from"./c-S5IEIZCN.js";import"./c-GVPNDIKJ.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as replace};
1
+ import{a}from"./c-5AQYL27I.js";import"./c-ZKELCT4T.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as replace};
@@ -1,4 +1,4 @@
1
- import{c as h}from"./c-GBKB5WDL.js";import{w as d}from"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-44B5ODN7.js";import{m as p}from"./c-QIXT3Q7C.js";import{a as s}from"./c-BYTKL6UX.js";import"./c-E4IBSAQM.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var c=`
1
+ import{c as h}from"./c-GBKB5WDL.js";import{w as d}from"./c-4RFZROCF.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-4TWARTLS.js";import"./c-Q5KAQJAG.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-TMT5TL65.js";import{m as p}from"./c-QIXT3Q7C.js";import{a as s}from"./c-BYTKL6UX.js";import"./c-OI2BYWVV.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var c=`
2
2
  .page-tool-block { position: relative; min-height: 48px; border: 1px solid var(--page-rule); border-radius: 8px; padding: 12px; }
3
3
  .page-tool-settings { position: absolute; top: 4px; inset-inline-end: 4px; border: 0; border-radius: 5px; background: var(--page-pop-bg); color: var(--page-ink-soft); font: 12px var(--page-font); padding: 5px 8px; cursor: pointer; opacity: 0; }
4
4
  .page-tool-block:hover .page-tool-settings, .page-tool-block:focus-within .page-tool-settings { opacity: 1; }
@@ -1 +1 @@
1
- import{d as t,e as o}from"./c-EOCKLMKX.js";import"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import{c as e}from"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-44B5ODN7.js";import"./c-QIXT3Q7C.js";import"./c-E4IBSAQM.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";function c({view:r=null}={}){let a=r?e(r,{update:o}):()=>{};return{id:"chart",nodeViews:{chart:(i,n,d)=>new t(i,n,d)},dispose(){a()}}}export{c as createFeature};
1
+ import{d as t,e as o}from"./c-WWE67K5Y.js";import"./c-4RFZROCF.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-4TWARTLS.js";import"./c-Q5KAQJAG.js";import{c as e}from"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-TMT5TL65.js";import"./c-QIXT3Q7C.js";import"./c-OI2BYWVV.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";function c({view:r=null}={}){let a=r?e(r,{update:o}):()=>{};return{id:"chart",nodeViews:{chart:(i,n,d)=>new t(i,n,d)},dispose(){a()}}}export{c as createFeature};