1import{r as D}from"./chunk-BV7QT456-ClmWjlzX.js";import"./root-CrCsgmNn.js";import{j as Xe}from"./index-odidbifR.js";var Ze=Object.create,ke=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,De=Object.getOwnPropertyNames,et=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty,L=(e,t)=>function(){return t||(0,e[De(e)[0]])((t={exports:{}}).exports,t),t.exports},nt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of De(t))!tt.call(e,i)&&i!==n&&ke(e,i,{get:()=>t[i],enumerable:!(r=Qe(t,i))||r.enumerable});return e},rt=(e,t,n)=>(n=e!=null?Ze(et(e)):{},nt(ke(n,"default",{value:e,enumerable:!0}),e)),le=L({"node_modules/penpal/lib/constants.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DATA_CLONE_ERROR=e.MESSAGE=e.REJECTED=e.FULFILLED=e.REPLY=e.CALL=e.HANDSHAKE_REPLY=e.HANDSHAKE=void 0;var t="handshake";e.HANDSHAKE=t;var n="handshake-reply";e.HANDSHAKE_REPLY=n;var r="call";e.CALL=r;var i="reply";e.REPLY=i;var o="fulfilled";e.FULFILLED=o;var s="rejected";e.REJECTED=s;var a="message";e.MESSAGE=a;var l="DataCloneError";e.DATA_CLONE_ERROR=l}}),de=L({"node_modules/penpal/lib/errorCodes.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ERR_NO_IFRAME_SRC=e.ERR_NOT_IN_IFRAME=e.ERR_CONNECTION_TIMEOUT=e.ERR_CONNECTION_DESTROYED=void 0;var t="ConnectionDestroyed";e.ERR_CONNECTION_DESTROYED=t;var n="ConnectionTimeout";e.ERR_CONNECTION_TIMEOUT=n;var r="NotInIframe";e.ERR_NOT_IN_IFRAME=r;var i="NoIframeSrc";e.ERR_NO_IFRAME_SRC=i}}),Le=L({"node_modules/penpal/lib/createDestructor.js"(e,t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=()=>{const r=[];let i=!1;return{destroy(){i=!0,r.forEach(o=>{o()})},onDestroy(o){i?o():r.push(o)}}};e.default=n,t.exports=e.default}}),it=L({"node_modules/penpal/lib/getOriginFromSrc.js"(e,t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n={"http:":"80","https:":"443"},r=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,i=["file:","data:"],o=s=>{if(s&&i.find(c=>s.startsWith(c)))return"null";const a=document.location,l=r.exec(s);let h,b,w;l?(h=l[1]?l[1]:a.protocol,b=l[2],w=l[4]):(h=a.protocol,b=a.hostname,w=a.port);const d=w&&w!==n[h]?`:${w}`:"";return`${h}//${b}${d}`};e.default=o,t.exports=e.default}}),Fe=L({"node_modules/penpal/lib/createLogger.js"(e,t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=r=>function(){if(r){for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];console.log("[Penpal]",...o)}};e.default=n,t.exports=e.default}}),$e=L({"node_modules/penpal/lib/errorSerialization.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.deserializeError=e.serializeError=void 0;var t=r=>{let i=r.name,o=r.message,s=r.stack;return{name:i,message:o,stack:s}};e.serializeError=t;var n=r=>{const i=new Error;return Object.keys(r).forEach(o=>i[o]=r[o]),i};e.deserializeError=n}}),Ue=L({"node_modules/penpal/lib/connectCallReceiver.js"(e,t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=le(),r=$e(),i=(o,s,a)=>{const l=o.localName,h=o.local,b=o.remote,w=o.originForSending,d=o.originForReceiving;let c=!1;a(`${l}: Connecting call receiver`);const m=E=>{if(E.source!==b||E.data.penpal!==n.CALL)return;if(E.origin!==d){a(`${l} received message from origin ${E.origin} which did not match expected origin ${d}`);return}const g=E.data,_=g.methodName,R=g.args,A=g.id;a(`${l}: Received ${_}() call`);const p=y=>C=>{if(a(`${l}: Sending ${_}() reply`),c){a(`${l}: Unable to send ${_}() reply due to destroyed connection`);return}const T={penpal:n.REPLY,id:A,resolution:y,returnValue:C};y===n.REJECTED&&C instanceof Error&&(T.returnValue=(0,r.serializeError)(C),T.returnValueIsError=!0);try{b.postMessage(T,w)}catch(O){throw O.name===n.DATA_CLONE_ERROR&&b.postMessage({penpal:n.REPLY,id:A,resolution:n.REJECTED,returnValue:(0,r.serializeError)(O),returnValueIsError:!0},w),O}};new Promise(y=>y(s[_].apply(s,R))).then(p(n.FULFILLED),p(n.REJECTED))};return h.addEventListener(n.MESSAGE,m),()=>{c=!0,h.removeEventListener(n.MESSAGE,m)}};e.default=i,t.exports=e.default}}),ot=L({"node_modules/penpal/lib/generateId.js"(e,t){Object.defineProperty(e,"__esMo
1dule",{value:!0}),e.default=void 0;var n=0,r=()=>++n;e.default=r,t.exports=e.default}}),We=L({"node_modules/penpal/lib/connectCallSender.js"(e,t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=le(),r=de(),i=s(ot()),o=$e();function s(l){return l&&l.__esModule?l:{default:l}}var a=(l,h,b,w,d)=>{const c=h.localName,m=h.local,E=h.remote,g=h.originForSending,_=h.originForReceiving;let R=!1;d(`${c}: Connecting call sender`);const A=p=>function(){for(var y=arguments.length,C=new Array(y),T=0;T<y;T++)C[T]=arguments[T];d(`${c}: Sending ${p}() call`);let O;try{E.closed&&(O=!0)}catch{O=!0}if(O&&w(),R){const P=new Error(`Unable to send ${p}() call due to destroyed connection`);throw P.code=r.ERR_CONNECTION_DESTROYED,P}return new Promise((P,I)=>{const F=(0,i.default)(),N=u=>{if(u.source!==E||u.data.penpal!==n.REPLY||u.data.id!==F)return;if(u.origin!==_){d(`${c} received message from origin ${u.origin} which did not match expected origin ${_}`);return}d(`${c}: Received ${p}() reply`),m.removeEventListener(n.MESSAGE,N);let v=u.data.returnValue;u.data.returnValueIsError&&(v=(0,o.deserializeError)(v)),(u.data.resolution===n.FULFILLED?P:I)(v)};m.addEventListener(n.MESSAGE,N),E.postMessage({penpal:n.CALL,id:F,methodName:p,args:C},g)})};return b.reduce((p,y)=>(p[y]=A(y),p),l),()=>{R=!0}};e.default=a,t.exports=e.default}}),st=L({"node_modules/penpal/lib/connectToChild.js"(e,t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=le(),r=de(),i=h(Le()),o=h(it()),s=h(Fe()),a=h(Ue()),l=h(We());function h(d){return d&&d.__esModule?d:{default:d}}var b=6e4,w=d=>{let c=d.iframe,m=d.methods,E=m===void 0?{}:m,g=d.childOrigin,_=d.timeout,R=d.debug;const A=(0,s.default)(R),p=window,y=(0,i.default)(),C=y.destroy,T=y.onDestroy;if(!g){if(!c.src&&!c.srcdoc){const I=new Error("Iframe must have src or srcdoc property defined.");throw I.code=r.ERR_NO_IFRAME_SRC,I}g=(0,o.default)(c.src)}const O=g==="null"?"*":g;return{promise:new Promise((I,F)=>{let N;_!==void 0&&(N=setTimeout(()=>{const S=new Error(`Connection to child timed out after ${_}ms`);S.code=r.ERR_CONNECTION_TIMEOUT,F(S),C()},_));const u={};let v,$;const k=S=>{const z=c.contentWindow;if(S.source!==z||S.data.penpal!==n.HANDSHAKE)return;if(S.origin!==g){A(`Parent received handshake from origin ${S.origin} which did not match expected origin ${g}`);return}A("Parent: Received handshake, sending reply"),S.source.postMessage({penpal:n.HANDSHAKE_REPLY,methodNames:Object.keys(E)},O);const j={localName:"Parent",local:p,remote:z,originForSending:O,originForReceiving:g};$&&$(),$=(0,a.default)(j,E,A),T($),v&&v.forEach(Y=>{delete u[Y]}),v=S.data.methodNames;const q=(0,l.default)(u,j,v,C,A);T(q),clearTimeout(N),I(u)};p.addEventListener(n.MESSAGE,k),A("Parent: Awaiting handshake");var f=setInterval(()=>{document.contains(c)||(clearInterval(f),C())},b);T(()=>{p.removeEventListener(n.MESSAGE,k),clearInterval(f);const S=new Error("Connection destroyed");S.code=r.ERR_CONNECTION_DESTROYED,F(S)})}),destroy:C}};e.default=w,t.exports=e.default}}),at=L({"node_modules/penpal/lib/connectToParent.js"(e,t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=le(),r=de(),i=l(Le()),o=l(Ue()),s=l(We()),a=l(Fe());function l(b){return b&&b.__esModule?b:{default:b}}var h=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},d=w.parentOrigin,c=d===void 0?"*":d,m=w.methods,E=m===void 0?{}:m,g=w.timeout,_=w.debug;const R=(0,a.default)(_);if(window===window.top){const P=new Error("connectToParent() must be called within an iframe");throw P.code=r.ERR_NOT_IN_IFRAME,P}const A=(0,i.default)(),p=A.destroy,y=A.onDestroy,C=window,T=C.parent;return{promise:new Promise((P,I)=>{let F;g!==void 0&&(F=setTimeout(()=>{const u=new Error(`Connection to parent timed out after ${g}ms`);u.code=r.ERR_CONNECTION_TIMEOUT,I(u),p()},g));const N=u=>{try{clearTimeout()}catch{return}if(u.source!==T||u.data.penpal!==n.HANDSHAKE_REPLY)return;if(c!=="*"&&c!==u.origin){R(`Child received handshake reply from origin ${u.origin} which did not match expected origin ${c}`);return}R("Child: Received handshake reply"),C.removeEventListener(n.MESSAGE,N);const v={localName:"Child",local:C,remote:T,originForSending:u.origin==="null"?"*":u.origin,originForReceiving:u.origin},$={},k=(0,o.default)(v,E,R);y(k);const f=(0,s.default)($,v,u.data.methodNames,p,R);y(f),clearTimeout(F),P($)};C.addEventListener(n.MESSAGE,N),y(()=>{C.removeEventListener(n.MESSAGE,N);const u=new Error("Connection destroyed");u.code=r.ERR_CONNECTION_DESTROYED,I(u)}),R("Child: Sending handshake"),T.postMessage({penpal:n.HANDSHAKE,methodNames:Object.keys(E)},c)}),destroy:p}};e.default=h,t.exports=e.default}}),lt=L({"node_modules/penpal/lib/index.js"(e,t){Object.defineProperty(e,"__esMo
1dule",{value:!0}),e.default=void 0;var n=o(st()),r=o(at()),i=de();function o(a){return a&&a.__esModule?a:{default:a}}var s={ERR_CONNECTION_DESTROYED:i.ERR_CONNECTION_DESTROYED,ERR_CONNECTION_TIMEOUT:i.ERR_CONNECTION_TIMEOUT,ERR_NOT_IN_IFRAME:i.ERR_NOT_IN_IFRAME,ERR_NO_IFRAME_SRC:i.ERR_NO_IFRAME_SRC,connectToChild:n.default,connectToParent:r.default};e.default=s,t.exports=e.default}}),Ce=e=>typeof e=="object"&&e!=null&&e.nodeType===1,Te=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",oe=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return Te(n.overflowY,t)||Te(n.overflowX,t)||(r=>{const i=(o=>{if(!o.ownerDocument||!o.ownerDocument.defaultView)return null;try{return o.ownerDocument.defaultView.frameElement}catch{return null}})(r);return!!i&&(i.clientHeight<r.scrollHeight||i.clientWidth<r.scrollWidth)})(e)}return!1},se=(e,t,n,r,i,o,s,a)=>o<e&&s>t||o>e&&s<t?0:o<=e&&a<=n||s>=t&&a>=n?o-e-r:s>t&&a<n||o<e&&a>n?s-t+i:0,dt=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},ct=(e,t)=>{var n,r,i,o;if(typeof document>"u")return[];const{scrollMode:s,block:a,inline:l,boundary:h,skipOverflowHiddenElements:b}=t,w=typeof h=="function"?h:k=>k!==h;if(!Ce(e))throw new TypeError("Invalid target");const d=document.scrollingElement||document.documentElement,c=[];let m=e;for(;Ce(m)&&w(m);){if(m=dt(m),m===d){c.push(m);break}m!=null&&m===document.body&&oe(m)&&!oe(document.documentElement)||m!=null&&oe(m,b)&&c.push(m)}const E=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,g=(o=(i=window.visualViewport)==null?void 0:i.height)!=null?o:innerHeight,{scrollX:_,scrollY:R}=window,{height:A,width:p,top:y,right:C,bottom:T,left:O}=e.getBoundingClientRect(),{top:P,right:I,bottom:F,left:N}=(k=>{const f=window.getComputedStyle(k);return{top:parseFloat(f.scrollMarginTop)||0,right:parseFloat(f.scrollMarginRight)||0,bottom:parseFloat(f.scrollMarginBottom)||0,left:parseFloat(f.scrollMarginLeft)||0}})(e);let u=a==="start"||a==="nearest"?y-P:a==="end"?T+F:y+A/2-P+F,v=l==="center"?O+p/2-N+I:l==="end"?C+I:O-N;const $=[];for(let k=0;k<c.length;k++){const f=c[k],{height:S,width:z,top:j,right:q,bottom:Y,left:X}=f.getBoundingClientRect();if(s==="if-needed"&&y>=0&&O>=0&&T<=g&&C<=E&&(f===d&&!oe(f)||y>=j&&T<=Y&&O>=X&&C<=q))return $;const Z=getComputedStyle(f),Q=parseInt(Z.borderLeftWidth,10),ee=parseInt(Z.borderTopWidth,10),te=parseInt(Z.borderRightWidth,10),ne=parseInt(Z.borderBottomWidth,10);let U=0,W=0;const re="offsetWidth"in f?f.offsetWidth-f.clientWidth-Q-te:0,ie="offsetHeight"in f?f.offsetHeight-f.clientHeight-ee-ne:0,he="offsetWidth"in f?f.offsetWidth===0?0:z/f.offsetWidth:0,fe="offsetHeight"in f?f.offsetHeight===0?0:S/f.offsetHeight:0;if(d===f)U=a==="start"?u:a==="end"?u-g:a==="nearest"?se(R,R+g,g,ee,ne,R+u,R+u+A,A):u-g/2,W=l==="start"?v:l==="center"?v-E/2:l==="end"?v-E:se(_,_+E,E,Q,te,_+v,_+v+p,p),U=Math.max(0,U+R),W=Math.max(0,W+_);else{U=a==="start"?u-j-ee:a==="end"?u-Y+ne+ie:a==="nearest"?se(j,Y,S,ee,ne+ie,u,u+A,A):u-(j+S/2)+ie/2,W=l==="start"?v-X-Q:l==="center"?v-(X+z/2)+re/2:l==="end"?v-q+te+re:se(X,q,z,Q,te+re,v,v+p,p);const{scrollLeft:be,scrollTop:we}=f;U=fe===0?0:Math.max(0,Math.min(we+U/fe,f.scrollHeight-S/fe+ie)),W=he===0?0:Math.max(0,Math.min(be+W/he,f.scrollWidth-z/he+re)),u+=we-U,v+=be-W}$.push({el:f,top:U,left:W})}return $};function J(e){const t=typeof Document<"u"?Document:void 0,n=typeof document<"u"?document:void 0;if(t&&e instanceof t)return e;const r=e.ownerDocument??n??null;if(!r)throw new Error("Unable to resolve document");return r}function ut(){return typeof window<"u"&&typeof document<"u"}function ht(){return typeof window<"u"&&window.parent!==window}function _e(e){const t=new URL(e,"http://example.com");return t.pathname+t.search+t.hash}function Ae(e){return typeof PointerEvent<"u"?e instanceof PointerEvent:typeof e.pointerType=="string"&&e.pointerType==="mouse"}function He(e){return typeof MouseEvent<"u"?e instanceof MouseEvent:typeof e.button=="number"}function ge(e){return typeof KeyboardEvent<"u"?e instanceof KeyboardEvent:typeof e.key=="string"}function V(e){return e.defaultView??(typeof window<"u"?window:null)}function Re(e){const t=e.activeElement;if(!t)return!1;const n=t.tagName;return n==="INPUT"||n==="TEXTAREA"||n==="SELECT"?!0:t.isContentEditable}function ft(e){if(typeof e.getBoundingClientRect!="function")return null;const t=e.getBoundingClientRect();
1return t.width===0&&t.height===0||!qe(e)?null:{top:t.top,left:t.left,width:t.width,height:t.height}}function ze(e){return new Promise(t=>setTimeout(t,e))}function B(e,t){return new Promise((n,r)=>{if(e<=0){t.aborted?r(new Error("Animation cancelled")):n();return}const i=()=>{clearTimeout(o),t.removeEventListener("abort",i),r(new Error("Animation cancelled"))},o=setTimeout(()=>{t.removeEventListener("abort",i),n()},e);t.addEventListener("abort",i)})}async function Ee(){return new Promise(e=>requestAnimationFrame(()=>{requestAnimationFrame(e)}))}function mt(e){const t=J(e),n=e.getBoundingClientRect(),r=V(t);if(!r)return!1;const i=r.innerHeight||t.documentElement.clientHeight,o=r.innerWidth||t.documentElement.clientWidth;return n.top<i&&n.bottom>0&&n.left<o&&n.right>0}function je(e,t){const n=ct(e,t);let r=0;for(const i of n){const o=i.el,s=Math.abs(i.top-o.scrollTop),a=Math.abs(i.left-o.scrollLeft);r+=a+s}return r}async function Ve(e,t){if(e.some(mt))return;let r=null,i=Number.POSITIVE_INFINITY;for(const o of e){const s=je(o,{scrollMode:"if-needed",block:"center",inline:"nearest"});s<i&&qe(o)&&(i=s,r=o)}r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),await gt(r,t))}function qe(e){if(!e)return!1;const t=window.getComputedStyle(e);return t.display==="none"||t.visibility==="hidden"||t.opacity==="0"||e.offsetWidth===0&&e.offsetHeight===0?!1:Ye(e.parentElement)}function Ye(e){if(!e)return!0;const t=window.getComputedStyle(e);return t.display==="none"||t.visibility==="hidden"||t.opacity==="0"?!1:Ye(e.parentElement)}async function gt(e,t){const n=J(e);if(!V(n)){await B(500,t);return}await new Promise((i,o)=>
1{if(t.aborted){o(new DOMException("Aborted","AbortError"));return}let s;const a=()=>{if(t.aborted){cancelAnimationFrame(s),o(new DOMException("Aborted","AbortError"));return}const l=je(e,{scrollMode:"if-needed",block:"center",inline:"nearest"});if(Math.abs(l)<1){i();return}s=requestAnimationFrame(a)};s=requestAnimationFrame(a)}),await B(100,t)}var pt=rt(lt());function ve(e,t){const n=e.match(t);return!n||!n.groups?null:{environment:n.groups.environment||"__PRIMARY__",itemTypeId:n.groups.item_type_id,itemId:n.groups.item_id,fieldPath:n.groups.field_path}}function Et(e,t){const n={};for(const i of e){const o=ve(i,t);if(o){const s=o.environment;n[s]||(n[s]=new Set),n[s].add(o.itemId)}}const r={};for(const[i,o]of Object.entries(n))r[i]=Array.from(o);return r}var G=8,vt="2147483646",me="2px",M="6px",Ge=17;function yt(e,t){const n=Math.min(t,1-t),r=i=>{const o=(i+e/30)%12;return t-n*Math.max(-1,Math.min(o-3,Math.min(9-o,1)))};return[Math.round(r(0)*255),Math.round(r(8)*255),Math.round(r(4)*255)]}function bt(e,t,n){const r=i=>i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4);return .2126*r(e/255)+.7152*r(t/255)+.0722*r(n/255)}function wt(e){let t=0,n=.5,r=0;for(;n-t>.001;){const i=(t+n)/2,[o,s,a]=yt(e,i);1.05/(bt(o,s,a)+.05)>=3.5?(r=i,t=i+.001):n=i-.001}return r}function xe(e){const t=Math.round(wt(e)*100);return{borderColor:`hsl(${e}, 100%, ${t}%)`,backgroundColor:`hsla(${e}, 100%, ${t}%, 0.15)`}}function Ke(e){let t=null,n=null;const r=()=>{t=null,n&&(e(...n),n=null)},i=((...o)=>{n=o,t==null&&(t=window.requestAnimationFrame(r))});return i.cancel=()=>{t!=null&&(window.cancelAnimationFrame(t),t=null),n=null},i}var Ct=class{constructor(e){this.doc=e,this.callbacks=new Set,this.running=!1,this.rafHandler=Ke(()=>{const t=Array.from(this.callbacks);for(const n of t)try{n()}catch{}}),this.onEvent=()=>{this.rafHandler()}}startIfNeeded(){if(this.running)return;const e=V(this.doc);e&&(e.addEventListener("scroll",this.onEvent,{passive:!0,capture:!0}),e.addEventListener("resize",this.onEvent,{passive:!0,capture:!0})),this.doc.addEventListener("scroll",this.onEvent,{passive:!0,capture:!0}),this.running=!0}stopIfIdle(){if(!this.running||this.callbacks.size>0)return;const e=V(this.doc);e&&(e.removeEventListener("scroll",this.onEvent),e.removeEventListener("resize",this.onEvent)),this.doc.removeEventListener("scroll",this.onEvent),this.running=!1,this.rafHandler.cancel()}subscribe(e){return this.callbacks.add(e),this.startIfNeeded(),()=>{this.callbacks.delete(e),this.stopIfIdle()}}},Se=new WeakMap;function Tt(e){let t=Se.get(e);return t||(t=new Ct(e),Se.set(e,t)),t}function _t(e){if(e&&"ResizeObserver"in e)return e.ResizeObserver;if(typeof ResizeObserver<"u")return ResizeObserver}var At=class{constructor(e){this.window=e,this.observer=null,this.callbacks=new WeakMap;const t=_t(this.window);t&&(this.observer=new t(n=>{for(const r of n){const i=this.callbacks.get(r.target);if(i)for(const o of i)o()}}))}observe(e,t){if(!this.observer)return()=>{};let n=this.callbacks.get(e);return n||(n=new Set,this.callbacks.set(e,n),this.observer.observe(e)),n.add(t),()=>{const r=this.callbacks.get(e);r&&(r.delete(t),r.size===0&&(this.callbacks.delete(e),this.observer?.unobserve(e)))}}},Oe=new WeakMap;function Rt(e){if(!e)return null;let t=Oe.get(e);return t||(t=new At(e),Oe.set(e,t)),t}var Pe=200,ye=class{constructor(e,t={}){this.targetElement=e,this.resizeUnobserve=null,this.scrollResizeUnsubscribe=null,this.pendingAnimationAbortController=null,this.onDispose=t.onDispose,this.showLabel=t.showLabel??!1,this.overlayColors=t.overlayColors??xe(Ge),this.overlayElement=this.createOverlayElement(this.showLabel),document.body.appendChild(this.overlayElement);const n=Tt(this.document);this.scrollResizeUnsubscribe=n.subscribe(()=>{this.updatePosition()});const r=Rt(this.window);r&&(this.resizeUnobserve=r.observe(e,()=>{this.updatePosition()}))}show(){this.updatePosition()}get document(){return J(this.targetElement)}get window(){return V(this.document)}dispose(){this.onDispose?.(),this.scrollResizeUnsubscribe?.(),this.resizeUnobserve?.(),this.overlayElement.remove()}cancelPendingAnimation(){this.pendingAnimationAbortController?.abort()}async fadeIn(e=0,t){this.cancelPendingAnimation(),this.pendingAnimationAbortController=t||new AbortController;const{signal:n}=this.pendingAnimationAbortController;try{this.overlayElement.style.opacity="0",await Ee(),await B(e,n),this.overlayElement.style.opacity="1"}catch{}}async disposeWithFadeOut(e=0,t){this.cancelPendingAnimation(),this.pendingAnimationAbortController=t||new AbortController;const{signal:n}=this.pendingAnimationAbortController;try{await B(e,n),this.overlayElement.style.opacity="0",await B(Pe+50,n)}catch{}finally{this.dispose()}}createOverlayElement(e){const t=this.document.createElement("div");if(t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="0",t.style.height="0",t.style.border=`${me} solid ${this.overlayColors.borderColor}`,t.style.borderRadius=e?`${M} 0 ${M}
1 ${M}`:M,t.style.background=this.overlayColors.backgroundColor,t.style.boxSizing="border-box",t.style.pointerEvents="none",t.style.zIndex=vt,t.style.display="block",t.style.opacity="1",t.style.transition=`opacity ${Pe}ms ease-in-out`,t.setAttribute("aria-hidden","true"),e){const n=this.document.createElement("div");n.textContent="Open in DatoCMS â",n.style.position="absolute",n.style.bottom="100%",n.style.right=`-${me}`,n.style.backgroundColor=this.overlayColors.borderColor,n.style.color="white",n.style.padding="4px 12px",n.style.borderRadius=`${M} ${M} 0 0`,n.style.fontSize="13px",n.style.fontWeight="600",n.style.fontFamily="system-ui, -apple-system, sans-serif",n.style.whiteSpace="nowrap",n.style.setProperty("-webkit-font-smoothing","antialiased"),n.style.letterSpacing="normal",n.style.lineHeight="normal",n.style.textTransform="none",n.style.fontStyle="normal",n.setAttribute("aria-hidden","true"),t.appendChild(n)}return t}updatePosition(){const e=ft(this.targetElement);if(this.overlayElement.style.zIndex=this.computeOverlayZIndex(this.targetElement),!e){this.overlayElement.style.display="none";return}if(this.overlayElement.style.display="block",this.overlayElement.style.top=`${e.top-G}px`,this.overlayElement.style.left=`${e.left-G}px`,this.overlayElement.style.width=`${e.width+G*2}px`,this.overlayElement.style.height=`${e.height+G*2}px`,this.showLabel){const t=this.overlayElement.firstElementChild;t&&(e.width+G*2<150?(t.style.bottom="calc(100% + 10px)",t.style.right="auto",t.style.left="50%",t.style.transform="translateX(-50%)",t.style.borderRadius=`${M}`,this.overlayElement.style.borderRadius=M):(t.style.bottom="100%",t.style.right=`-${me}`,t.style.left="auto",t.style.transform="none",t.style.borderRadius=`${M} ${M} 0 0`,this.overlayElement.style.borderRadius=`${M} 0 ${M} ${M}`))}}computeOverlayZIndex(e){if(!this.window)return"0";let t=e,n=null;for(;t&&t instanceof this.window.Element;){const i=this.window.getComputedStyle(t).zIndex;if(i!=="auto"){const o=Number(i);Number.isFinite(o)&&(n=o)}t=t.parentElement}return n!==null?String(n):"0"}},H="data-datocms-auto-content-link-url",St="data-datocms-contains-stega",ce="data-datocms-content-link-url",Me="data-datocms-content-link-group",Ot="data-datocms-content-link-boundary",x="data-datocms-content-link-source",ue=`[${ce}], [${H}]`;function K(e){if(!e||!(e instanceof Element))return null;const t=e.closest(ue);if(!t)return null;const n=t.getAttribute(ce)||t.getAttribute(H);return n?{element:t,editUrl:n}:null}var Pt=class{constructor(e,t,n=()=>!1,r){this.document=e,this.onEditClick=t,this.shouldShowLabel=n,this.overlayColors=r,this.highlightOverlay=null,this.listenerAbortController=null,this.throttledOnPointerMove=Ke(i=>this.immediateOnPointerMoveEvent(i))}isActive(){return!!this.listenerAbortController}activate(){if(this.isActive())return;this.listenerAbortController=new AbortController;const e={capture:!0,signal:this.listenerAbortController.signal};this.document.addEventListener("pointerover",this.throttledOnPointerMove,e),this.document.addEventListener("pointermove",this.throttledOnPointerMove,e),this.document.addEventListener("pointerleave",t=>this.onPointerLeave(t),e),this.document.addEventListener("click",t=>this.onClick(t),e),this.document.addEventListener("focusin",t=>this.onFocusIn(t),e),this.document.addEventListener("focusout",()=>this.onFocusOut(),e),this.document.addEventListener("keydown",t=>this.onKeyDown(t),e)}immediateOnPointerMoveEvent(e){if(!Ae(e))return;const t=K(e.target);this.highlightElement(t?.element)}onPointerLeave(e){if(!Ae(e))return;K(e.relatedTarget)||this.highlightElement(null)}onFocusIn(e){const t=K(e.target);this.highlightElement(t?.element)}onKeyDown(e){if(!ge(e)||e.key!=="Enter"&&e.key!==" "&&e.key!=="Spacebar")return;const t=K(this.document.activeElement);t&&(this.highlightElement(t.element),e.preventDefault(),e.stopPropagation(),this.onEditClick(t.editUrl))}onClick(e){if(!He(e)||e.button!==0)return;const t=K(e.target);t&&(this.highlightElement(t.element),e.preventDefault(),e.stopPropagation(),this.onEditClick(t.editUrl))}onFocusOut(){this.highlightElement(null)}highlightElement(e){const t=e&&!e.isConnected?null:e;if(!(this.highlightOverlay&&this.highlightOverlay.targetElement===t)&&(this.highlightOverlay&&(this.highlightOverlay.dispose(),this.highlightOverlay=null),t)){const n=t.style.cursor;t.style.cursor="pointer",this.highlightOverlay=new ye(t,{onDispose:()=>{t.style.cursor=n},showLabel:this.shouldShowLabel(),overlayColors:this.overlayColors}),this.highlightOverlay.show()}}deactivate(){this.isActive()&&(this.listenerAbortController.abort(),this.listenerAbortController=null,this.throttledOnPointerMove.cancel(),this.highlightOverlay?.dispose(),this.highlightOverlay=null)}},Be={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},Je={0:8203,1:8204,2:8205,3:65279}
1,Mt=new Array(4).fill(String.fromCodePoint(Je[0])).join(""),Ie="\0",It=Object.fromEntries(Object.entries(Je).map(e=>e.reverse())),Ne=Object.fromEntries(Object.entries(Be).map(e=>e.reverse())),Nt=`${Object.values(Be).map(e=>`\\u{${e.toString(16)}}`).join("")}`,pe=new RegExp(`[${Nt}]{4,}`,"gu");function kt(e){let t=e.match(pe);if(t)return Dt(t[0],!0)[0]}function Dt(e,t=!1){let n=Array.from(e);if(n.length%2===0){if(n.length%4||!e.startsWith(Mt))return Lt(n,t)}else throw new Error("Encoded data has invalid length");let r=[];for(let i=n.length*.25;i--;){let o=n.slice(i*4,i*4+4).map(s=>It[s.codePointAt(0)]).join("");r.unshift(String.fromCharCode(parseInt(o,4)))}if(t){r.shift();let i=r.indexOf(Ie);return i===-1&&(i=r.length),[JSON.parse(r.slice(0,i).join(""))]}return r.join("").split(Ie).filter(Boolean).map(i=>JSON.parse(i))}function Lt(e,t){var n;let r=[];for(let a=e.length*.5;a--;){let l=`${Ne[e[a*2].codePointAt(0)]}${Ne[e[a*2+1].codePointAt(0)]}`;r.unshift(String.fromCharCode(parseInt(l,16)))}let i=[],o=[r.join("")],s=10;for(;o.length;){let a=o.shift();try{if(i.push(JSON.parse(a)),t)return i}catch(l){if(!s--)throw l;let h=+((n=l.message.match(/\sposition\s(\d+)$/))==null?void 0:n[1]);if(!h)throw l;o.unshift(a.substring(0,h),a.substring(h))}}return i}function Ft(e){var t;return{cleaned:e.replace(pe,""),encoded:((t=e.match(pe))==null?void 0:t[0])||""}}function $t(e){return typeof e=="object"&&e!==null&&"origin"in e&&typeof e.origin=="string"&&"href"in e&&typeof e.href=="string"}function Ut(e){return Ft(e)}function Wt(e){let t=!1;const n=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r);return()=>{t||(t=!0,n(()=>{t=!1,e()}))}}var Ht=class{constructor(e,t,n=!1,r=!1){this.root=e,this.onStamp=t,this.stripStega=n,this.silenceWarnings=r,this.pendingElementsToStamp=new Set,this.scheduleStamping=Wt(()=>this.instantStampPendingElements()),this.observer=new MutationObserver(i=>this.handleMutations(i)),this.observer.observe(this.root,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["alt",x]}),this.instantStampPendingElements(!0)}dispose(){this.observer.disconnect(),this.pendingElementsToStamp.clear();const e=this.root.querySelectorAll(`[${H}]`);for(const t of e)t.removeAttribute(H)}handleMutations(e){let t=!1;for(const n of e)if(n.type==="characterData"){const r=n.target,i=r.parentElement??r.parentNode??this.root;this.pendingElementsToStamp.add(i),t=!0}else if(n.type==="attributes"&&n.attributeName==="alt"){const r=n.target;this.pendingElementsToStamp.add(r.parentElement??this.root),t=!0}else if(n.type==="attributes"&&n.attributeName===x){const r=n.target;this.pendingElementsToStamp.add(r.parentElement??this.root),t=!0}else if(n.type==="childList"){this.pendingElementsToStamp.add(n.target);for(const r of n.addedNodes)(r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.DOCUMENT_FRAGMENT_NODE)&&this.pendingElementsToStamp.add(r);t=!0}t&&this.scheduleStamping()}instantStampPendingElements(e=!1){const t=this.pendingElementsToStamp.size===0?[this.root]:Array.from(this.pendingElementsToStamp);this.pendingElementsToStamp.clear();const n=[];for(const i of t){const o=this.stampElement(i);n.push(o)}const r=n.length===1?n[0]:{appliedStamps:n.reduce((i,o)=>{for(const[s,a]of o.appliedStamps.entries())i.set(s,a);return i},new Map),scope:this.root};!this.silenceWarnings&&e&&r.appliedStamps.size===0&&console.warn("[@datocms/content-link] No editable elements were detected after initialization. Make sure that Content Link headers are enabled in your GraphQL requests! If you're hydrating/streaming, do not replace the server-rendered nodes that carry stega-encoded data: reuse the same DOM element!"),n.length!==0&&this.onStamp(r)}stampElement(e){const t=J(e);if(!t)return{appliedStamps:new Map,scope:e};const n=new Map,r=t.createTreeWalker(e,NodeFilter.SHOW_TEXT);let i=r.nextNode();for(;i;){if(!(i instanceof Text)){i=r.nextNode();continue}const s=i.nodeValue??"",a=i.parentElement;if(a&&this.isInsideExcludedTag(a)){i=r.nextNode();continue}const l=this.addStampingAttributesTargetAndReturnStrippedValue(s,a,n);this.stripStega&&l!==void 0&&(i.nodeValue=l),i=r.nextNode()}for(const s of e.querySelectorAll("img[alt]")){const a=s.getAttribute("alt"),l=this.addStampingAttributesTargetAndReturnStrippedValue(a,s,n);this.stripStega&&l!==void 0&&s.setAttribute("alt",l)}for(const s of e.querySelectorAll(`[${x}]`)){const a=s.getAttribute(x);this.addStampingAttributesTargetAndReturnStrippedValue(a,s,n),this.stripStega&&s.removeAttribute(x)}return{appliedStamps:n,scope:e}}
1addStampingAttributesTargetAndReturnStrippedValue(e,t,n){if(!e||!t)return;let r,i;try{if(r=Ut(e),!r.encoded||(i=kt(r.encoded),!$t(i)))return}catch{return}const o=this.maybeFindGroup(t);if(!o)return;const s=n.get(o);return!this.silenceWarnings&&s&&s!==i.href&&this.warnCollision(o,s,t,i.href),o.getAttribute(H)!==i.href&&(o.setAttribute(H,i.href),n.set(o,i.href)),this.stripStega||t.setAttribute(St,""),r.cleaned}warnCollision(e,t,n,r){const i=`[@datocms/content-link] Multiple stega-encoded payloads resolved to the same DOM element. Previous URL: ${t}. Incoming URL: ${r}. Wrap each encoded block in its own element (for example by adding ${Me}).`;console.warn(i,e,n)}isInsideExcludedTag(e){if(!e)return!1;let t=e;for(;t;){if(t.tagName==="SCRIPT"||t.tagName==="STYLE")return!0;t=t.parentElement}return!1}maybeFindGroup(e){let t=e;for(;t;){if(t.hasAttribute(Me))return t;if(t.hasAttribute(Ot))return e;t=t.parentElement}return e}},zt="datocms:visual-editing:stamped",jt="datocms:click-to-edit:toggle",Vt=class{constructor(e){this.doc=e.doc}emitStamped(e){this.dispatch(zt,e)}emitClickToEditToggle(e){this.dispatch(jt,e)}dispatch(e,t){const n=this.doc.defaultView?.CustomEvent??(typeof CustomEvent<"u"?CustomEvent:void 0);if(n)try{const r=new n(e,{detail:t});this.doc.dispatchEvent(r)}catch{}}},ae=10,qt=class{constructor(e,t){this.wrapperElement=e,this.overlayColors=t,this.overlays=[],this.pendingAnimationAbortController=null,this.disposed=!1}async flash(e){this.disposed||(this.fadeIn(e),await ze(1500),this.fadeOut())}async fadeIn(e){if(this.disposed)return;await Ee();const t=this.wrapperElement.querySelectorAll(ue),n=Array.from(t);if(n.length===0)return;this.instantlyDisposeOverlays();const r=new AbortController,{signal:i}=r;this.pendingAnimationAbortController=r;try{e&&await Ve(n,i);const o=n.length;n.map((s,a)=>{const l=new ye(s,{overlayColors:this.overlayColors});l.fadeIn(o<50?a*ae:0,r),this.overlays.push(l)})}catch{}}fadeOut(){if(this.disposed)return;this.cancelPendingAnimation();const e=new AbortController,t=this.overlays.length;this.overlays.map((n,r)=>{n.disposeWithFadeOut(t<50?r*ae:0,e)}),this.overlays=[]}dispose(){this.disposed||(this.disposed=!0,this.instantlyDisposeOverlays())}cancelPendingAnimation(){this.pendingAnimationAbortController?.abort()}instantlyDisposeOverlays(){this.cancelPendingAnimation(),this.overlays.forEach(e=>{e.cancelPendingAnimation(),e.dispose()}),this.overlays=[]}},Yt=class{constructor(e,t,n,r){this.wrapperElement=e,this.itemId=t,this.editUrlRegExp=n,this.overlayColors=r,this.overlays=[],this.pendingAnimationAbortController=null,this.disposed=!1}async flash(e){this.disposed||(await Ee(),this.fadeIn(e),await ze(1500),await this.fadeOut())}async fadeIn(e){if(this.disposed)return;const t=this.wrapperElement.querySelectorAll(ue),n=new Set;for(const s of t){const a=s.getAttribute(ce)||s.getAttribute(H);if(a){const l=ve(a,this.editUrlRegExp);l&&l.itemId===this.itemId&&n.add(s)}}const r=Array.from(n);if(r.length===0)return;this.instantlyDisposeOverlays();const i=new AbortController,{signal:o}=i;this.pendingAnimationAbortController=i;try{e&&await Ve(r,o),r.map((s,a)=>{const l=new ye(s,{overlayColors:this.overlayColors});l.fadeIn(a*ae,i),this.overlays.push(l)})}catch{}}async fadeOut(){if(this.disposed)return;this.cancelPendingAnimation();const e=new AbortController,t=Promise.all(this.overlays.map((n,r)=>n.disposeWithFadeOut(r*ae,e)));return this.overlays=[],await t}dispose(){this.disposed||(this.disposed=!0,this.instantlyDisposeOverlays())}cancelPendingAnimation(){this.pendingAnimationAbortController?.abort()}instantlyDisposeOverlays(){this.cancelPendingAnimation(),this.overlays.forEach(e=>{e.cancelPendingAnimation(),e.dispose()}),this.overlays=[]}},Gt=class{constructor(e){this.flashItemManager=null,this.webPreviewsPluginConnection=null,this.disposed=!1,this.currentPath=_e(document.location.toString()),this.wrapperElement=e.root??document,this.onNavigateTo=e.onNavigateTo,this.overlayColors=xe(e.hue??Ge),this.eventsManager=new Vt({doc:this.document}),this.clickToEditManager=new Pt(this.document,t=>this.handleEditClick(t),()=>this.webPreviewsPluginConnection===null,this.overlayColors),this.initializeWebPreviewsPluginConnection(),this.stampingManager=new Ht(this.wrapperElement,t=>this.handleStampResult(t),e.stripStega??!1,e.silenceWarnings??!1),this.flashAllManager=new qt(this.wrapperElement,this.overlayColors),this.listenerAbortController=new AbortController,this.document.addEventListener("keydown",t=>this.onKeyDown(t),{capture:!0,signal:this.listenerAbortController.signal}),this.document.addEventListener("keyup",t=>this.onKeyUp(t),{capture:!0,signal:this.listenerAbortController.signal}),this.document.addEventListener("click",t=>this.onClick(t),{capture:!0,signal:this.listenerAbortController.signal}),this.document.addEventListener("visibilitychange",()=>{document.hidden&&this.disableTemporaryClickToEditState()},{signal:this.listenerAbortController.signal}),V(this.document)?.addEventListener("blur",()=>{this.disableTemporaryClickToEditState()},{signal:this.listenerAbortController.signal})}get document(){return J(this.wrapperElement)}dispose(){this.disposed||(this.disposed=!0,this.clickToEditManager.deactivate(),this.stampingManager.dispose(),this.flashAllManager.dispose(),this.flashItemManager?.dispose(),this.webPreviewsPluginConnection?.destroy(),this.listenerAbortController.abort())}isDisposed(){return this.disposed}setCurrentPath(e){this.currentPath=_e(e)}enableClickToEdit(e){this.disposed||(this.clickToEditManager.isActive()||(this.clickToEditManager.activate(),this.eventsManager.emitClickToEditToggle(!0),this.notifyStateChangeToWebPreviewsPlugin()),e&&this.flashAllManager.flash(e.scrollToNearestTarget))}disableClickToEdit(){!this.clickToEditManager.isActive()||this.disposed||(this.clickToEditManager.deactivate(),this.eventsManager.emitClickToEditToggle(!1),this.notifyStateChangeToWebPreviewsPlugin())}isClickToEditEnabled(){return this.clickToEditManager.isActive()&&!this.disposed}flashAll(e=!1){this.disposed||this.flashAllManager.flash(e)}async flashItem(e,t=!1){if(this.disposed||!this.webPreviewsPluginConnection)return;this.flashItemManager?.dispose();const n=new Yt(this.wrapperElement,e,this.webPreviewsPluginConnection.editUrlRegExp,this.overlayColors),r=n.flash(t);this.flashItemManager=n,await r,n.dispose()}handleStampResult(e){this.eventsManager.emitStamped(e),this.notifyStateChangeToWebPreviewsPlugin()}async notifyStateChangeToWebPreviewsPlugin(){if(!this.webPreviewsPluginConnection)return;const e=this.wrapperElement.querySelectorAll(ue),t=new Set;for(const n of e){const r=n.getAttribute(ce)||n.getAttribute(H);r&&t.add(r)}await this.webPreviewsPluginConnection.parent.onStateChange({clickToEditEnabled:this.clickToEditManager.isActive(),path:this.currentPath,itemIdsPerEnvironment:Et(Array.from(t),this.webPreviewsPluginConnection.editUrlRegExp)})}handleEditClick(e){if(this.webPreviewsPluginConnection){const t=ve(e,this.webPreviewsPluginConnection.editUrlRegExp);t&&this.webPreviewsPluginConnection.parent.openItem(t)}else(this.document.defaultView??(typeof window<"u"?window:null))?.open(e,"_blank","noopener,noreferrer")}async initializeWebPreviewsPluginConnection(){if(!ht())return;const e=pt.default.connectToParent({timeout:2e4,methods:{navigateTo:i=>{this.onNavigateTo?.(i.path)},flashAll:i=>{this.flashAll(i.scrollToNearestTarget)},flashItem:i=>{this.flashItem(i.itemId,i.scrollToNearestTarget)},setClickToEditEnabled:i=>{i.enabled?this.enableClickToEdit(i.flash):this.disableClickToEdit()}}}),t=await e.promise;if(this.disposed){e.destroy();return}let n;const{editUrlRegExp:r}=await t.onInit();n=setInterval(()=>
1t.onPing(),1e3),this.webPreviewsPluginConnection={parent:t,destroy:()=>{clearInterval(n),e.destroy()},editUrlRegExp:new RegExp(r.source,r.flags)},await this.notifyStateChangeToWebPreviewsPlugin()}onKeyDown(e){!ge(e)||e.key!=="Alt"||this.isTopLevelWindowOrInWebPreviewsIframe&&(Re(this.document)||this.enableTemporaryClickToEditState())}onKeyUp(e){!ge(e)||e.key!=="Alt"||this.isTopLevelWindowOrInWebPreviewsIframe&&(Re(this.document)||this.disableTemporaryClickToEditState())}onClick(e){if(!(!He(e)||e.button!==0)&&this.temporaryState&&!this.temporaryState.enabled&&e.altKey){e.preventDefault();const t=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});e.target.dispatchEvent(t)}}enableTemporaryClickToEditState(){this.clickToEditManager.isActive()?(this.temporaryState={enabled:!1},this.disableClickToEdit(),this.flashAllManager.fadeOut()):(this.temporaryState={enabled:!0},this.enableClickToEdit(),this.flashAllManager.fadeIn(!0))}disableTemporaryClickToEditState(){this.temporaryState&&(this.temporaryState.enabled?(this.disableClickToEdit(),this.flashAllManager.fadeOut()):(this.enableClickToEdit(),this.flashAllManager.flash(!0)),this.temporaryState=void 0)}get isTopLevelWindowOrInWebPreviewsIframe(){const e=this.document.defaultView??(typeof window<"u"?window:null);return this.webPreviewsPluginConnection||e&&e.parent===e}},xt=class{constructor(){this.disposed=!1}dispose(){this.disposed=!0}isDisposed(){return this.disposed}setCurrentPath(){}enableClickToEdit(){}disableClickToEdit(){}isClickToEditEnabled(){return!1}flashAll(){}};function Kt(e={}){return ut()?new Gt(e):new xt}function Bt(e={}){const{enabled:t=!0,onNavigateTo:n,root:r,hue:i}=e,o=D.useRef(null),s=D.useRef(n);D.useEffect(()=>{s.current=n},[n]),D.useEffect(()=>{if(!(t===!0||typeof t=="object"&&t!==null)){o.current&&(o.current.dispose(),o.current=null);return}const c=typeof t=="object"?t.stripStega:!1,m=Kt({onNavigateTo:E=>{var g;return(g=s.current)===null||g===void 0?void 0:g.call(s,E)},root:r?.current||void 0,stripStega:c,hue:i});return o.current=m,()=>{m.dispose(),o.current=null}},[t,r,i]);const a=D.useCallback(d=>{var c;d?.hoverOnly&&(typeof window>"u"||!window.matchMedia("(hover: hover)").matches)||(c=o.current)===null||c===void 0||c.enableClickToEdit(d?.scrollToNearestTarget?{scrollToNearestTarget:d.scrollToNearestTarget}:void 0)},[]),l=D.useCallback(()=>{var d;(d=o.current)===null||d===void 0||d.disableClickToEdit()},[]),h=D.useCallback(()=>{var d,c;return(c=(d=o.current)===null||d===void 0?void 0:d.isClickToEditEnabled())!==null&&c!==void 0?c:!1},[]),b=D.useCallback(d=>{var c;(c=o.current)===null||c===void 0||c.flashAll(d)},[]),w=D.useCallback(d=>{var c;(c=o.current)===null||c===void 0||c.setCurrentPath(d)},[]);return{controller:o.current,enableClickToEdit:a,disableClickToEdit:l,isClickToEditEnabled:h,flashAll:b,setCurrentPath:w}}var Jt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function Xt(e){const{currentPath:t,enableClickToEdit:n,stripStega:r,hue:i}=e,o=Jt(e,["currentPath","enableClickToEdit","stripStega","hue"]),{enableClickToEdit:s,setCurrentPath:a}=Bt(Object.assign(Object.assign({},o),{enabled:r!==void 0?{stripStega:r}:!0,hue:i}));return D.useEffect(()=>{t!==void 0&&a(t)},[t,a]),D.useEffect(()=>{n&&(typeof window>"u"||window.parent!==window||s(n===!0?void 0:n))},[n,s]),null}const Zt=e=>{const t=new URL(e,window.location.href),n=new URL(t.searchParams.get("redirectTo")??"/",window.location.href);return n.searchParams.set("visualEditing","true"),t.searchParams.set("redirectTo",n.pathname+n.search),t.toString()},nn=({enabled:e,isActive:t,isPreview:n,previewApiEndpoint:r})=>(D.useEffect(()=>{if(!e)return;const i=o=>{if((o.metaKey||o.ctrlKey)&&o.shiftKey&&o.key.toLowerCase()==="k"){o.preventDefault();const s=new URL(window.location.href),a=s.searchParams.get("visualEditing")==="true";if(!n&&!a&&r){window.location.href=Zt(r);return}a?s.searchParams.delete("visualEditing"):s.searchParams.set("visualEditing","true"),window.location.href=s.toString()}};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[e,n,r]),t?Xe.jsx(Xt,{enableClickToEdit:!0}):null);export{nn as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.