@panphora/clayjs 1.24.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +15016 -13603
- package/dist/m/c-277QP5ET.js +1 -0
- package/dist/m/{c-BULK5J4M.js → c-3UW5EJ77.js} +1 -1
- package/dist/m/{c-GM7OA6EJ.js → c-42ZNV7LI.js} +1 -1
- package/dist/m/{c-RXTPKCMC.js → c-6IJEVE6B.js} +1 -1
- package/dist/m/{c-2R4OBWIP.js → c-6LEYVQJK.js} +1 -1
- package/dist/m/{c-LO4C4J77.js → c-6Q6RGFBF.js} +1 -1
- package/dist/m/{c-PD5AKHY3.js → c-7CM4GMTS.js} +1 -1
- package/dist/m/c-APGHGDZM.js +1 -0
- package/dist/m/{c-Q6VNQDJE.js → c-B7GOFGQR.js} +1 -1
- package/dist/m/{c-RJKKRWHW.js → c-BGN7RCTJ.js} +1 -1
- package/dist/m/{c-A7N5TNSL.js → c-C5AKJVRH.js} +1 -1
- package/dist/m/{c-SNVDWMM3.js → c-CJ7QYEWI.js} +1 -1
- package/dist/m/{c-PVJMJL3P.js → c-CZHTXGJS.js} +1 -1
- package/dist/m/{c-KJHVB2KG.js → c-DDS23EY6.js} +1 -1
- package/dist/m/{c-VSEUFJAO.js → c-DFKBGSN2.js} +1 -1
- package/dist/m/{c-DLBX4JCJ.js → c-EDE45NM7.js} +1 -1
- package/dist/m/c-EILLN2H2.js +1 -0
- package/dist/m/{c-EY5KDUZF.js → c-FEC6LGFF.js} +1 -1
- package/dist/m/{c-PMRRMT72.js → c-HDVH3MVC.js} +1 -1
- package/dist/m/c-HKSLOVU4.js +1 -0
- package/dist/m/{c-GNIVHLEJ.js → c-HL6BLJNA.js} +1 -1
- package/dist/m/c-HTLYXCUH.js +1 -0
- package/dist/m/{c-RTSRGGTP.js → c-JQF2EUCG.js} +1 -1
- package/dist/m/{c-O5ARALMJ.js → c-JWDCQL6J.js} +1 -1
- package/dist/m/{c-WOELSNWS.js → c-LATNQ6Q5.js} +1 -1
- package/dist/m/{c-UM7VZDTW.js → c-LSVN3OLG.js} +1 -1
- package/dist/m/{c-HSNGLIFB.js → c-MFOSMAVM.js} +2 -2
- package/dist/m/{c-FZRZPIFS.js → c-MQYEDF3Q.js} +1 -1
- package/dist/m/{c-2OIKXOY6.js → c-ND3Q2G2I.js} +1 -1
- package/dist/m/{c-PZRWZZRO.js → c-OCYG4NBQ.js} +1 -1
- package/dist/m/{c-54ZZZYUN.js → c-P2HKMJAW.js} +1 -1
- package/dist/m/{c-VI3BJHCM.js → c-PCNJETUA.js} +1 -1
- package/dist/m/{c-7YETSAVY.js → c-PDBNCJCT.js} +1 -1
- package/dist/m/{c-A5ZBFICF.js → c-PYG2NGWU.js} +1 -1
- package/dist/m/{c-RBPZNU2D.js → c-QQFHEODI.js} +1 -1
- package/dist/m/{c-YINHPF4V.js → c-SGH3UTF3.js} +1 -1
- package/dist/m/{c-FV46ZKGX.js → c-SKMIR5HQ.js} +1 -1
- package/dist/m/{c-TWOXQQKV.js → c-STRI73GQ.js} +1 -1
- package/dist/m/{c-75N3KG35.js → c-T3P3AXEW.js} +1 -1
- package/dist/m/c-U4NTUVDZ.js +1 -0
- package/dist/m/{c-P5NKFRL4.js → c-UOOIF2AL.js} +1 -1
- package/dist/m/c-VHSMPITY.js +1 -0
- package/dist/m/{c-6UPEKW6O.js → c-X75G43SZ.js} +1 -1
- package/dist/m/{c-YGGO2G2L.js → c-XW5TIYYB.js} +1 -1
- package/dist/m/{c-DZPO22O3.js → c-YDW4VCHP.js} +1 -1
- package/dist/m/{c-YB3CDTDZ.js → c-YLHTD3KX.js} +1 -1
- package/dist/m/c-Z4G2UK6T.js +4 -0
- package/dist/m/{c-VNAYHV2J.js → c-ZGCO4J3H.js} +1 -1
- package/dist/m/core/{admin-attrs-5UGMYCKW.js → admin-attrs-ONRWVXPK.js} +1 -1
- package/dist/m/core/{autosave-4P66VXX7.js → autosave-TBKAAAFB.js} +1 -1
- package/dist/m/core/{conflict-notice-BAR23OWH.js → conflict-notice-FOEE6I7E.js} +1 -1
- package/dist/m/core/draft-mode-4MCL3LYI.js +1 -0
- package/dist/m/core/{host-permission-3HE4CFD6.js → host-permission-X4BENZEU.js} +1 -1
- package/dist/m/core/{is-edit-mode-GK7IFFMT.js → is-edit-mode-FFHCQ5DR.js} +1 -1
- package/dist/m/core/{persist-AIJGTKKI.js → persist-6ILUR34S.js} +1 -1
- package/dist/m/core/{recovery-LPB6X72P.js → recovery-APWADU4K.js} +1 -1
- package/dist/m/core/{save-FV4ZCKBI.js → save-6HT2LABE.js} +1 -1
- package/dist/m/core/{save-core-K7XFAWQ4.js → save-core-EVMNZQ4V.js} +1 -1
- package/dist/m/core/{site-edits-TEQORBJU.js → site-edits-G4BOZMV4.js} +1 -1
- package/dist/m/core/{unsaved-warning-FF63QGKI.js → unsaved-warning-ITZDIZ2I.js} +1 -1
- package/dist/m/internals/{index-AX4CG7B2.js → index-HS3CQDFW.js} +1 -1
- package/dist/m/loader-GLLVDUZA.js +1 -0
- package/dist/m/manifest-50FF1C45.js +1 -0
- package/dist/m/manifest-edit-BE1A621D.js +1 -0
- package/dist/m/manifest.json +710 -674
- package/dist/m/plugins/{ai-edit-CUKQQWJX.js → ai-edit-LABECCSN.js} +1 -1
- package/dist/m/plugins/{cms-JANMGPHM.js → cms-T2HLI7JG.js} +16 -16
- package/dist/m/plugins/{demo-JIR7DXJA.js → demo-T7B4RIKL.js} +1 -1
- package/dist/m/plugins/{derive-QVI3LI3A.js → derive-6LPJOCAV.js} +1 -1
- package/dist/m/plugins/{indicator-DAKZGAWI.js → indicator-J4ABFARX.js} +1 -1
- package/dist/m/plugins/{live-UAJGWRNP.js → live-PGBIEMGB.js} +1 -1
- package/dist/m/plugins/{menu-BFJ644YX.js → menu-YZL3X2AJ.js} +1 -1
- package/dist/m/plugins/page-WOCNX2IN.js +2 -0
- package/dist/m/plugins/{page-view-OYN7Z5TS.js → page-view-SJODOOGE.js} +1 -1
- package/dist/m/plugins/{people-VBDR5Y22.js → people-C4TCWFOQ.js} +1 -1
- package/dist/m/plugins/{richclay-CBLZRFB4.js → richclay-Y2NV44NA.js} +3 -3
- package/dist/m/plugins/sortable-XCHQG65Z.js +1 -0
- package/dist/m/plugins/{source-ZXDD7F6X.js → source-YK7MO23W.js} +1 -1
- package/dist/m/plugins/{undo-5JI5G7CQ.js → undo-VLRBQNPN.js} +1 -1
- package/dist/m/plugins/{upgrade-6B6QS3NR.js → upgrade-NNTJBSK2.js} +1 -1
- package/dist/m/plugins/{upload-DNJNW6H3.js → upload-ZKKJV76X.js} +1 -1
- package/dist/m/plugins/visitor-drafts-RTZNONHT.js +20 -0
- package/dist/m/plugins/{visitor-drafts-owner-VIAZC3CF.js → visitor-drafts-owner-LHUHFU3L.js} +1 -1
- package/dist/m/plugins/{visitor-menu-ZHKWIKKY.js → visitor-menu-FY4KM2SW.js} +1 -1
- package/dist/m/plugins/wire-M2NR354P.js +1 -0
- package/dist/m/{reader-core-F6RY3V64.js → reader-core-T2S3JC4E.js} +2 -2
- package/dist/m/sync/{live-sync-M2PP2IWY.js → live-sync-Z64YREWQ.js} +1 -1
- package/dist/m/vendor/{sap-core.vendor-OA5SKL7Q.js → sap-core.vendor-QAEPMETX.js} +1 -1
- package/dist/offline-manifest.json +455 -425
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +1 -1
- package/package.json +2 -2
- package/src/core/draft-mode.js +6 -0
- package/src/core/save-core.js +7 -8
- package/src/core/unsaved-warning.js +2 -2
- package/src/lib/idb-error-code.js +20 -0
- package/src/loader.js +2 -0
- package/src/plugins/page.js +19 -5
- package/src/plugins/sortable.js +7 -0
- package/src/plugins/visitor-drafts/commit.js +303 -0
- package/src/plugins/visitor-drafts/idb.js +221 -0
- package/src/plugins/visitor-drafts/prompt.js +23 -3
- package/src/plugins/visitor-drafts/session.js +345 -0
- package/src/plugins/visitor-drafts/store.js +210 -26
- package/src/plugins/visitor-drafts.js +148 -28
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hypercms.vendor.js +16 -16
- package/src/vendor/richclay.vendor.js +1 -1
- package/src/vendor/sap-core.vendor.js +1 -1
- package/dist/m/c-234RSEIW.js +0 -1
- package/dist/m/c-2YIJ6ZA6.js +0 -1
- package/dist/m/c-H2H7TI6O.js +0 -1
- package/dist/m/c-JMDKPBMC.js +0 -4
- package/dist/m/c-N7JPUPGC.js +0 -1
- package/dist/m/c-NEXFVJIT.js +0 -1
- package/dist/m/c-T527QHOB.js +0 -1
- package/dist/m/core/draft-mode-WSQAT67S.js +0 -1
- package/dist/m/loader-5IA5OJ3J.js +0 -1
- package/dist/m/manifest-98258645.js +0 -1
- package/dist/m/manifest-edit-ABF56000.js +0 -1
- package/dist/m/plugins/page-ZBIYHGK4.js +0 -2
- package/dist/m/plugins/sortable-HDOQ6GAC.js +0 -1
- package/dist/m/plugins/visitor-drafts-A5FDQ2G7.js +0 -20
- package/dist/m/plugins/wire-XOT7XKJL.js +0 -1
- /package/dist/m/plugins/{richclay-CBLZRFB4.js.LEGAL.txt → richclay-Y2NV44NA.js.LEGAL.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Le}from"../c-AQYCG7QW.js";import{c as Ae}from"../c-VSEUFJAO.js";import{e as Ke,g as F,h as ze,j as le,l as Te,n as Ce,p as Ge,q as d}from"../c-MR75YPRT.js";import{a as qe}from"../c-4JZDZFF6.js";import{b as G,c as Se,d as se,e as x,f as We}from"../c-5RZNFTWD.js";import{b as O}from"../c-PKCCHJ5X.js";import{b as Ue}from"../c-RTSRGGTP.js";import{a as de,b as Ve}from"../c-QTTJYJMA.js";import{b as h}from"../c-NUHP2XDB.js";import"../c-TWCXBWS3.js";import{a as $e}from"../c-VKEDWYDF.js";import{n as je,o as ce}from"../c-2YIJ6ZA6.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import"../c-5VYOWDTI.js";import"../c-LO4C4J77.js";import"../c-FV46ZKGX.js";import"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import{a as Ee}from"../c-LA2BW7UY.js";import"../c-HSNGLIFB.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-RXTPKCMC.js";import"../c-RBPZNU2D.js";import"../c-IJUK2GPW.js";import{k as Be}from"../c-DLBX4JCJ.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import"../c-PWJSJEJU.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import{h as ee,o as _e}from"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var tt="ai-edit",xt="h1,h2,h3,h4,h5,h6,p,figure",vt="p,h1,h2,h3,h4,h5,h6,li,dt,dd,blockquote,pre,figcaption,td,th",Et="section,article,aside,header,footer,nav,main,div,ul,ol,dl,table,figure,form",nt="script,style,template,textarea,input,select,button,iframe,svg,math",St="This section is too large for AI editing. Select a smaller part.",Oe="The save did not finish; the edit is still on the page.",Tt=0,o=null,a,w,u,T,A,m,b,v,R,_,$,W,D,B={},p=null,C=null,N=null,ue=!1,re=new WeakMap,He=new Set,f=null,Z=null,S=null,z,q,pe=null,k=null,Y=null,L=null,te=null,he=[],V=null,H=null,Re=0;function we(e){re.delete(e),He.delete(e)}function be(e,t){if(!t){we(e);return}re.set(e,t),He.add(e)}var it="clay-ai-edit",Ye="AI editing is turned off. Turn it on from the app\u2019s menu.";async function rt(){let t=(await Ae.helpers()).find(n=>n.name===tt);return t&&(t.state==="ready"||t.state==="unavailable")?t.state:null}var K=()=>window.clay?.blockeditor?.ai||null,Ct=()=>!!window.clay?.editPlugins?.includes("blockeditor")&&!!document.querySelector("article[data-blockeditor]"),ye=()=>Ct()&&!K()?.active();function Lt(){Ee.pause()}function Ie(){Ee.resume()}function fe(e){if(!(e instanceof Element))return null;let t=e.closest("[data-edit-id]");if(!t)return null;let n=e.closest(xt);return n&&t.contains(n)?n:t}function At(e){if(e===document.body)return"document";let t=e.getAttribute("data-edit-id");if(t)return t;let n=e.closest("[data-edit-id]");return n?n.getAttribute("data-edit-id")+" \u203A "+e.tagName.toLowerCase():e.id?"#"+e.id:e.tagName.toLowerCase()}function xe(){let e=window.getSelection();return!e||e.rangeCount===0||e.isCollapsed?null:e.getRangeAt(0)}function ot(e){if(K()||ye())return null;let t=e.commonAncestorContainer;if(t.nodeType!==1&&(t=t.parentElement),!t||!document.body.contains(t))return null;if(t===document.body)return document.body;if(t.closest("[data-clay-ai-edit]")||t.closest(ee)||t.closest(nt))return null;if(t.closest("[data-edit-id]"))return fe(t);let n=t.closest(vt)||t.closest(Et);return n&&n!==document.body?n:null}function at(e,t){if(!e||!t||!t.contains(e.commonAncestorContainer))return;let n=e.toString();if(!n.trim())return;let i=document.createRange();i.selectNodeContents(t),i.setEnd(e.startContainer,e.startOffset);let r=i.toString().length;return{text:n,start:r,end:r+n.length}}function me(e){let t=xe();if(t){if(e===document.body){let n=t.toString();return n.trim()?{text:n,start:void 0,end:void 0}:void 0}return at(t,e)}}function st(){let e=document.body.cloneNode(!0);return e.querySelectorAll(ee).forEach(t=>t.remove()),e.outerHTML}function Mt(e,t,n){let{HyperMorph:i}=de();return i.morph(e,t,{morphStyle:"outerHTML",restoreFocus:!0,scripts:n})}function ge(e,t,{rewind:n=!1}={}){let{HyperMorph:i,mergeTagRecognizers:r}=de(),s=n?{merge:!1,handle:!1}:{mergeBase:e.snapshot,mergeTags:r,handle:!1};e.docMode?(typeof t=="string"&&(t=new DOMParser().parseFromString(t,"text/html").body),i.morph(document.body,t,{morphStyle:"outerHTML",restoreFocus:document.activeElement?.localName!=="clay-editor-ui",scripts:s,callbacks:{beforeNodeRemoved:l=>!(l.nodeType===1&&l.matches(ee))}})):Mt(e.el,t,s),Ue()}function kt(e,t){let n=e.search(new RegExp("<"+t+"(\\s|>)","i"));if(n===-1)return null;let i=e.slice(n).replace(/\s*`{1,3}\s*$/,"");if(t.toLowerCase()==="body")return new DOMParser().parseFromString(i,"text/html").body;let r=document.createElement("template");r.innerHTML=i;let s=r.content.firstElementChild;return!s||s.tagName.toLowerCase()!==t.toLowerCase()?null:s}function Ot(e,t,n,{contextRefsOf:i,wantsPage:r}){let s=e===document.body,l=s?st():e.outerHTML,c={id:"req-"+Date.now().toString(36)+"-"+ ++Tt,editId:At(e),tag:e.tagName.toLowerCase(),elementHTML:l,comment:t,contextRefs:i(t)};return n&&(c.quote=n.text,Number.isInteger(n.start)&&(c.selection={start:n.start,end:n.end})),!s&&r(t)&&(c.page=!0),{id:c.id,el:e,docMode:s,tag:c.tag,reassertId:s?null:e.getAttribute("data-edit-id"),snapshot:l,payload:c,state:"requesting",paused:!1,handle:null,finalCandidate:null}}async function Rt(e,t,n){if(e.aiTarget)return Ht(e,t,n);let{MAX_PAYLOAD_BYTES:i,contextRefsOf:r,wantsPage:s}=await import("../c-TGSHHFO6.js");if(o=Ot(e,t,n,{contextRefsOf:r,wantsPage:s}),new Blob([JSON.stringify(o.payload)]).size>i){o=null,ie(St,"warn");return}if(be(e,t),mt(),o.paused=!0,Lt(),C={},P("working"),y("Sending\u2026"),o.payload.page&&await window.clay.save(),!o)return;let l=Ae.send(o.payload,{helper:tt,onStatus:({text:g})=>{o?.handle===l&&y(g)}});o.handle=l;let c=await l.done;!o||o.handle!==l||(await Ve(),!(!o||o.handle!==l)&&(c.state==="done"?_t(c.result||{}):c.state==="cancelled"?M("HTML Clay stopped this edit."):M(c.error||"the helper reported an error")))}async function Ht(e,t,n){let i={id:null,el:e,target:e,docMode:!1,state:"requesting",paused:!1,held:!1,handle:null,finalCandidate:null};o=i;let r;try{r=await e.start(t,n)}catch(g){M(g?.message||"the helper reported an error");return}if(o!==i)return;if(r.status!=="ok"){o=null,ie(r.message,"warn");return}i.id=r.id,be(e,t),mt(),C={},P("working"),y("Sending\u2026");let s=r.send({onStatus:({text:g})=>{o===i&&y(g)}});i.handle=s;let l=await s.done;if(o!==i)return;if(l.state!=="done"){l.state==="cancelled"?M("HTML Clay stopped this edit."):M(l.error||"the helper reported an error");return}i.state="deciding";let c;try{c=await e.propose(l.result||{})}catch(g){M(g?.message||"the reply could not be applied");return}if(o===i){if(c.status!=="ready"){M(c.message);return}we(e),P("ready"),y(lt(c.warnings||[],(l.result||{}).model),c.warnings?.length?"warn":"")}}var It=/^(on|hx-on|x-|@|:|v-on:|v-bind:|data-on[-:])/,Pt=new Set(["iframe","frame","object","embed","base","link"]);function Dt(e){let t=e.replace(/[\t\n\r]/g,"").replace(/^[\u0000- ]+/,"").toLowerCase();return t.startsWith("javascript:")||t.startsWith("vbscript:")}function Nt(e){let t=(e.getAttribute("type")||"").trim().toLowerCase();return!t||/javascript|ecmascript/.test(t)||["module","importmap","speculationrules"].includes(t)}function Me(e){return[...e.attributes].map(t=>t.name.toLowerCase()+"="+t.value).sort().join(" ")}function Je(e){let t=new Map,n=i=>t.set(i,(t.get(i)||0)+1);for(let i of[e,...e.querySelectorAll("*")]){let r=i.tagName.toLowerCase();r==="script"?Nt(i)&&n("script "+Me(i)+"|"+i.textContent.trim()):(Pt.has(r)||r==="meta"&&i.hasAttribute("http-equiv")||(r==="animate"||r==="set")&&/href/i.test(i.getAttribute("attributeName")||""))&&n(r+" "+Me(i));for(let s of i.attributes){let l=s.name.toLowerCase();It.test(l)?n(r+" "+l+"="+s.value.trim()):l==="srcdoc"?n(r+" srcdoc="+s.value):Dt(s.value)&&n(r+" "+l+"="+s.value)}}return t}function Ft(e,t,n){let i=n?new DOMParser().parseFromString(t,"text/html").body:(()=>{let s=document.createElement("template");return s.innerHTML=t,s.content.firstElementChild})(),r=i?Je(i):new Map;for(let[s,l]of Je(e))if(l>(r.get(s)||0))return!0;return!1}var Bt="The reply adds a script or event handler, so it was not applied. AI editing changes content, not code.";function _t(e){if(!o||o.state!=="requesting")return;o.state="deciding";let t=[],n=kt(e.html||"",o.tag);if(!n){M(`reply is not a single <${o.tag}> element`);return}if(!o.docMode){let i=document.createElement("template");i.innerHTML=e.html||"",i.content.children.length>1&&t.push("reply had extra root elements \u2014 kept the first")}if(o.reassertId&&n.setAttribute("data-edit-id",o.reassertId),Ft(n,o.snapshot,o.docMode)){M(Bt);return}je(),o.held=!0,o.finalCandidate=n;try{ge(o,n)}catch(i){M("the reply could not be applied: "+(i?.message||i));return}E(),we(o.el),P("ready"),y(lt(t,e.model),t.length?"warn":"")}function lt(e,t){let n=["Edit ready.",...e.map(i=>"\u26A0 "+i)];return t&&n.push(`(${t})`),n.join(" ")}function M(e){o&&(oe(),P("error"),y(e,"warn"))}function oe(){let e=o;if(o=null,!!e){if(e.target){e.target.discard(),E();return}try{(e.state==="requesting"||e.state==="deciding")&&de()&&ge(e,e.snapshot,{rewind:!0})}finally{e.paused&&Ie(),e.held&&ce(),E()}}}async function ct(){let e=o;if(!e)return;if(o=null,e.target)return $t(e.target);let t=e.docMode?st():e.el.outerHTML;try{ge(e,e.snapshot,{rewind:!0})}finally{e.paused&&Ie(),e.held&&ce({replay:!1})}ge(e,t),E(),P("saving"),y("Saving\u2026");let n=C,i=await window.clay.save();if(n===C){if(i&&i.ok===!1){P("error"),y(i.msg||Oe,"warn");return}y(i&&i.msg||"Saved",i&&i.msgType==="error"?"warn":""),pt()}}async function $t(e){E(),P("saving"),y("Saving\u2026");let t=C,n;try{n=await e.keep()}catch(i){n={status:"failed",message:i?.message||Oe}}if(t===C){if(!n||n.status!=="kept"){P("error"),y(n&&n.message||Oe,"warn");return}y(n.message||"Saved"),pt()}}function dt(){o?.handle?.cancel(),oe(),Q()}var Xe=["z-index:99999","padding:0","display:inline-grid","place-items:center","line-height:1",`box-shadow:${se}`];function j(e,t,n){return e.setAttribute(t,n),e}function Wt(){let{signal:e}=te;V=document.createElement("style"),V.setAttribute("clay",Ke),V.textContent=`
|
|
1
|
+
import{a as Le}from"../c-AQYCG7QW.js";import{c as Ae}from"../c-DFKBGSN2.js";import{e as Ke,g as F,h as ze,j as le,l as Te,n as Ce,p as Ge,q as d}from"../c-MR75YPRT.js";import{a as qe}from"../c-4JZDZFF6.js";import{b as G,c as Se,d as se,e as x,f as We}from"../c-5RZNFTWD.js";import{b as O}from"../c-PKCCHJ5X.js";import{b as Ue}from"../c-JQF2EUCG.js";import{a as de,b as Ve}from"../c-QTTJYJMA.js";import{b as h}from"../c-NUHP2XDB.js";import"../c-TWCXBWS3.js";import{a as $e}from"../c-VKEDWYDF.js";import{n as je,o as ce}from"../c-HTLYXCUH.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import"../c-5VYOWDTI.js";import"../c-6Q6RGFBF.js";import"../c-SKMIR5HQ.js";import"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import{a as Ee}from"../c-LA2BW7UY.js";import"../c-MFOSMAVM.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import"../c-QQFHEODI.js";import"../c-IJUK2GPW.js";import{k as Be}from"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4NTUVDZ.js";import"../c-PWJSJEJU.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import{h as ee,o as _e}from"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var tt="ai-edit",xt="h1,h2,h3,h4,h5,h6,p,figure",vt="p,h1,h2,h3,h4,h5,h6,li,dt,dd,blockquote,pre,figcaption,td,th",Et="section,article,aside,header,footer,nav,main,div,ul,ol,dl,table,figure,form",nt="script,style,template,textarea,input,select,button,iframe,svg,math",St="This section is too large for AI editing. Select a smaller part.",Oe="The save did not finish; the edit is still on the page.",Tt=0,o=null,a,w,u,T,A,m,b,v,R,_,$,W,D,B={},p=null,C=null,N=null,ue=!1,re=new WeakMap,He=new Set,f=null,Z=null,S=null,z,q,pe=null,k=null,Y=null,L=null,te=null,he=[],V=null,H=null,Re=0;function we(e){re.delete(e),He.delete(e)}function be(e,t){if(!t){we(e);return}re.set(e,t),He.add(e)}var it="clay-ai-edit",Ye="AI editing is turned off. Turn it on from the app\u2019s menu.";async function rt(){let t=(await Ae.helpers()).find(n=>n.name===tt);return t&&(t.state==="ready"||t.state==="unavailable")?t.state:null}var K=()=>window.clay?.blockeditor?.ai||null,Ct=()=>!!window.clay?.editPlugins?.includes("blockeditor")&&!!document.querySelector("article[data-blockeditor]"),ye=()=>Ct()&&!K()?.active();function Lt(){Ee.pause()}function Ie(){Ee.resume()}function fe(e){if(!(e instanceof Element))return null;let t=e.closest("[data-edit-id]");if(!t)return null;let n=e.closest(xt);return n&&t.contains(n)?n:t}function At(e){if(e===document.body)return"document";let t=e.getAttribute("data-edit-id");if(t)return t;let n=e.closest("[data-edit-id]");return n?n.getAttribute("data-edit-id")+" \u203A "+e.tagName.toLowerCase():e.id?"#"+e.id:e.tagName.toLowerCase()}function xe(){let e=window.getSelection();return!e||e.rangeCount===0||e.isCollapsed?null:e.getRangeAt(0)}function ot(e){if(K()||ye())return null;let t=e.commonAncestorContainer;if(t.nodeType!==1&&(t=t.parentElement),!t||!document.body.contains(t))return null;if(t===document.body)return document.body;if(t.closest("[data-clay-ai-edit]")||t.closest(ee)||t.closest(nt))return null;if(t.closest("[data-edit-id]"))return fe(t);let n=t.closest(vt)||t.closest(Et);return n&&n!==document.body?n:null}function at(e,t){if(!e||!t||!t.contains(e.commonAncestorContainer))return;let n=e.toString();if(!n.trim())return;let i=document.createRange();i.selectNodeContents(t),i.setEnd(e.startContainer,e.startOffset);let r=i.toString().length;return{text:n,start:r,end:r+n.length}}function me(e){let t=xe();if(t){if(e===document.body){let n=t.toString();return n.trim()?{text:n,start:void 0,end:void 0}:void 0}return at(t,e)}}function st(){let e=document.body.cloneNode(!0);return e.querySelectorAll(ee).forEach(t=>t.remove()),e.outerHTML}function Mt(e,t,n){let{HyperMorph:i}=de();return i.morph(e,t,{morphStyle:"outerHTML",restoreFocus:!0,scripts:n})}function ge(e,t,{rewind:n=!1}={}){let{HyperMorph:i,mergeTagRecognizers:r}=de(),s=n?{merge:!1,handle:!1}:{mergeBase:e.snapshot,mergeTags:r,handle:!1};e.docMode?(typeof t=="string"&&(t=new DOMParser().parseFromString(t,"text/html").body),i.morph(document.body,t,{morphStyle:"outerHTML",restoreFocus:document.activeElement?.localName!=="clay-editor-ui",scripts:s,callbacks:{beforeNodeRemoved:l=>!(l.nodeType===1&&l.matches(ee))}})):Mt(e.el,t,s),Ue()}function kt(e,t){let n=e.search(new RegExp("<"+t+"(\\s|>)","i"));if(n===-1)return null;let i=e.slice(n).replace(/\s*`{1,3}\s*$/,"");if(t.toLowerCase()==="body")return new DOMParser().parseFromString(i,"text/html").body;let r=document.createElement("template");r.innerHTML=i;let s=r.content.firstElementChild;return!s||s.tagName.toLowerCase()!==t.toLowerCase()?null:s}function Ot(e,t,n,{contextRefsOf:i,wantsPage:r}){let s=e===document.body,l=s?st():e.outerHTML,c={id:"req-"+Date.now().toString(36)+"-"+ ++Tt,editId:At(e),tag:e.tagName.toLowerCase(),elementHTML:l,comment:t,contextRefs:i(t)};return n&&(c.quote=n.text,Number.isInteger(n.start)&&(c.selection={start:n.start,end:n.end})),!s&&r(t)&&(c.page=!0),{id:c.id,el:e,docMode:s,tag:c.tag,reassertId:s?null:e.getAttribute("data-edit-id"),snapshot:l,payload:c,state:"requesting",paused:!1,handle:null,finalCandidate:null}}async function Rt(e,t,n){if(e.aiTarget)return Ht(e,t,n);let{MAX_PAYLOAD_BYTES:i,contextRefsOf:r,wantsPage:s}=await import("../c-TGSHHFO6.js");if(o=Ot(e,t,n,{contextRefsOf:r,wantsPage:s}),new Blob([JSON.stringify(o.payload)]).size>i){o=null,ie(St,"warn");return}if(be(e,t),mt(),o.paused=!0,Lt(),C={},P("working"),y("Sending\u2026"),o.payload.page&&await window.clay.save(),!o)return;let l=Ae.send(o.payload,{helper:tt,onStatus:({text:g})=>{o?.handle===l&&y(g)}});o.handle=l;let c=await l.done;!o||o.handle!==l||(await Ve(),!(!o||o.handle!==l)&&(c.state==="done"?_t(c.result||{}):c.state==="cancelled"?M("HTML Clay stopped this edit."):M(c.error||"the helper reported an error")))}async function Ht(e,t,n){let i={id:null,el:e,target:e,docMode:!1,state:"requesting",paused:!1,held:!1,handle:null,finalCandidate:null};o=i;let r;try{r=await e.start(t,n)}catch(g){M(g?.message||"the helper reported an error");return}if(o!==i)return;if(r.status!=="ok"){o=null,ie(r.message,"warn");return}i.id=r.id,be(e,t),mt(),C={},P("working"),y("Sending\u2026");let s=r.send({onStatus:({text:g})=>{o===i&&y(g)}});i.handle=s;let l=await s.done;if(o!==i)return;if(l.state!=="done"){l.state==="cancelled"?M("HTML Clay stopped this edit."):M(l.error||"the helper reported an error");return}i.state="deciding";let c;try{c=await e.propose(l.result||{})}catch(g){M(g?.message||"the reply could not be applied");return}if(o===i){if(c.status!=="ready"){M(c.message);return}we(e),P("ready"),y(lt(c.warnings||[],(l.result||{}).model),c.warnings?.length?"warn":"")}}var It=/^(on|hx-on|x-|@|:|v-on:|v-bind:|data-on[-:])/,Pt=new Set(["iframe","frame","object","embed","base","link"]);function Dt(e){let t=e.replace(/[\t\n\r]/g,"").replace(/^[\u0000- ]+/,"").toLowerCase();return t.startsWith("javascript:")||t.startsWith("vbscript:")}function Nt(e){let t=(e.getAttribute("type")||"").trim().toLowerCase();return!t||/javascript|ecmascript/.test(t)||["module","importmap","speculationrules"].includes(t)}function Me(e){return[...e.attributes].map(t=>t.name.toLowerCase()+"="+t.value).sort().join(" ")}function Je(e){let t=new Map,n=i=>t.set(i,(t.get(i)||0)+1);for(let i of[e,...e.querySelectorAll("*")]){let r=i.tagName.toLowerCase();r==="script"?Nt(i)&&n("script "+Me(i)+"|"+i.textContent.trim()):(Pt.has(r)||r==="meta"&&i.hasAttribute("http-equiv")||(r==="animate"||r==="set")&&/href/i.test(i.getAttribute("attributeName")||""))&&n(r+" "+Me(i));for(let s of i.attributes){let l=s.name.toLowerCase();It.test(l)?n(r+" "+l+"="+s.value.trim()):l==="srcdoc"?n(r+" srcdoc="+s.value):Dt(s.value)&&n(r+" "+l+"="+s.value)}}return t}function Ft(e,t,n){let i=n?new DOMParser().parseFromString(t,"text/html").body:(()=>{let s=document.createElement("template");return s.innerHTML=t,s.content.firstElementChild})(),r=i?Je(i):new Map;for(let[s,l]of Je(e))if(l>(r.get(s)||0))return!0;return!1}var Bt="The reply adds a script or event handler, so it was not applied. AI editing changes content, not code.";function _t(e){if(!o||o.state!=="requesting")return;o.state="deciding";let t=[],n=kt(e.html||"",o.tag);if(!n){M(`reply is not a single <${o.tag}> element`);return}if(!o.docMode){let i=document.createElement("template");i.innerHTML=e.html||"",i.content.children.length>1&&t.push("reply had extra root elements \u2014 kept the first")}if(o.reassertId&&n.setAttribute("data-edit-id",o.reassertId),Ft(n,o.snapshot,o.docMode)){M(Bt);return}je(),o.held=!0,o.finalCandidate=n;try{ge(o,n)}catch(i){M("the reply could not be applied: "+(i?.message||i));return}E(),we(o.el),P("ready"),y(lt(t,e.model),t.length?"warn":"")}function lt(e,t){let n=["Edit ready.",...e.map(i=>"\u26A0 "+i)];return t&&n.push(`(${t})`),n.join(" ")}function M(e){o&&(oe(),P("error"),y(e,"warn"))}function oe(){let e=o;if(o=null,!!e){if(e.target){e.target.discard(),E();return}try{(e.state==="requesting"||e.state==="deciding")&&de()&&ge(e,e.snapshot,{rewind:!0})}finally{e.paused&&Ie(),e.held&&ce(),E()}}}async function ct(){let e=o;if(!e)return;if(o=null,e.target)return $t(e.target);let t=e.docMode?st():e.el.outerHTML;try{ge(e,e.snapshot,{rewind:!0})}finally{e.paused&&Ie(),e.held&&ce({replay:!1})}ge(e,t),E(),P("saving"),y("Saving\u2026");let n=C,i=await window.clay.save();if(n===C){if(i&&i.ok===!1){P("error"),y(i.msg||Oe,"warn");return}y(i&&i.msg||"Saved",i&&i.msgType==="error"?"warn":""),pt()}}async function $t(e){E(),P("saving"),y("Saving\u2026");let t=C,n;try{n=await e.keep()}catch(i){n={status:"failed",message:i?.message||Oe}}if(t===C){if(!n||n.status!=="kept"){P("error"),y(n&&n.message||Oe,"warn");return}y(n.message||"Saved"),pt()}}function dt(){o?.handle?.cancel(),oe(),Q()}var Xe=["z-index:99999","padding:0","display:inline-grid","place-items:center","line-height:1",`box-shadow:${se}`];function j(e,t,n){return e.setAttribute(t,n),e}function Wt(){let{signal:e}=te;V=document.createElement("style"),V.setAttribute("clay",Ke),V.textContent=`
|
|
2
2
|
[editmode\\:contenteditable][contenteditable]:focus {
|
|
3
3
|
outline: 1px solid #4a4a6a; outline-offset: 4px; border-radius: 2px;
|
|
4
4
|
}
|