@lionrapid/core 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/attribute-extractor.d.ts +54 -0
- package/dist/browser/attribute-extractor.d.ts.map +1 -0
- package/dist/browser/attribute-extractor.js +155 -0
- package/dist/browser/attribute-extractor.js.map +1 -0
- package/dist/browser/auto-init.d.ts +9 -0
- package/dist/browser/auto-init.d.ts.map +1 -1
- package/dist/browser/auto-init.js +28 -4
- package/dist/browser/auto-init.js.map +1 -1
- package/dist/browser/auto-translator.d.ts +23 -0
- package/dist/browser/auto-translator.d.ts.map +1 -1
- package/dist/browser/auto-translator.js +90 -5
- package/dist/browser/auto-translator.js.map +1 -1
- package/dist/browser/block-extractor.d.ts +8 -0
- package/dist/browser/block-extractor.d.ts.map +1 -1
- package/dist/browser/block-extractor.js +77 -0
- package/dist/browser/block-extractor.js.map +1 -1
- package/dist/browser/editor/editor-api.d.ts +22 -1
- package/dist/browser/editor/editor-api.d.ts.map +1 -1
- package/dist/browser/editor/editor-api.js +54 -19
- package/dist/browser/editor/editor-api.js.map +1 -1
- package/dist/browser/editor/editor-init.js +72 -3
- package/dist/browser/editor/editor-init.js.map +1 -1
- package/dist/browser/editor/editor-styles.d.ts +1 -1
- package/dist/browser/editor/editor-styles.d.ts.map +1 -1
- package/dist/browser/editor/editor-styles.js +38 -1
- package/dist/browser/editor/editor-styles.js.map +1 -1
- package/dist/browser/editor/inspector.d.ts +8 -0
- package/dist/browser/editor/inspector.d.ts.map +1 -1
- package/dist/browser/editor/inspector.js +14 -0
- package/dist/browser/editor/inspector.js.map +1 -1
- package/dist/browser/editor/live-preview.d.ts +1 -1
- package/dist/browser/editor/live-preview.d.ts.map +1 -1
- package/dist/browser/editor/live-preview.js +27 -16
- package/dist/browser/editor/live-preview.js.map +1 -1
- package/dist/browser/editor/locale-url.d.ts +18 -0
- package/dist/browser/editor/locale-url.d.ts.map +1 -0
- package/dist/browser/editor/locale-url.js +37 -0
- package/dist/browser/editor/locale-url.js.map +1 -0
- package/dist/browser/editor/sidebar.d.ts +6 -0
- package/dist/browser/editor/sidebar.d.ts.map +1 -1
- package/dist/browser/editor/sidebar.js +133 -4
- package/dist/browser/editor/sidebar.js.map +1 -1
- package/dist/browser/editor/toolbar.d.ts +8 -1
- package/dist/browser/editor/toolbar.d.ts.map +1 -1
- package/dist/browser/editor/toolbar.js +49 -4
- package/dist/browser/editor/toolbar.js.map +1 -1
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +1 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/lionrapid.auto.dev.js +494 -109
- package/dist/browser/lionrapid.auto.dev.js.map +4 -4
- package/dist/browser/lionrapid.auto.js +494 -109
- package/dist/browser/lionrapid.auto.js.map +4 -4
- package/dist/browser/lionrapid.auto.min.js +3 -3
- package/dist/browser/lionrapid.auto.min.js.map +4 -4
- package/dist/browser/lionrapid.editor.js +371 -36
- package/dist/browser/lionrapid.editor.js.map +3 -3
- package/dist/browser/lionrapid.editor.min.js +41 -4
- package/dist/browser/lionrapid.editor.min.js.map +4 -4
- package/dist/browser/lionrapid.esm.js +403 -97
- package/dist/browser/lionrapid.esm.js.map +3 -3
- package/dist/browser/lionrapid.esm.min.js +2 -2
- package/dist/browser/lionrapid.esm.min.js.map +4 -4
- package/dist/browser/lionrapid.iife.dev.js +403 -97
- package/dist/browser/lionrapid.iife.dev.js.map +3 -3
- package/dist/browser/lionrapid.iife.js +403 -97
- package/dist/browser/lionrapid.iife.js.map +3 -3
- package/dist/browser/lionrapid.iife.min.js +2 -2
- package/dist/browser/lionrapid.iife.min.js.map +4 -4
- package/dist/browser/lionrapid.umd.js +403 -97
- package/dist/browser/lionrapid.umd.js.map +3 -3
- package/dist/browser/lionrapid.umd.min.js +2 -2
- package/dist/browser/lionrapid.umd.min.js.map +4 -4
- package/dist/browser/md5.d.ts +3 -2
- package/dist/browser/md5.d.ts.map +1 -1
- package/dist/browser/md5.js +41 -6
- package/dist/browser/md5.js.map +1 -1
- package/dist/builder.d.ts +8 -0
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +10 -0
- package/dist/builder.js.map +1 -1
- package/dist/content/parser/MarkupParser.d.ts +0 -10
- package/dist/content/parser/MarkupParser.d.ts.map +1 -1
- package/dist/content/parser/MarkupParser.js +45 -3
- package/dist/content/parser/MarkupParser.js.map +1 -1
- package/dist/content/types.d.ts +30 -0
- package/dist/content/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/repositories/index.d.ts +1 -0
- package/dist/repositories/index.d.ts.map +1 -1
- package/dist/repositories/index.js +1 -0
- package/dist/repositories/index.js.map +1 -1
- package/dist/repositories/static-repository.d.ts +40 -0
- package/dist/repositories/static-repository.d.ts.map +1 -0
- package/dist/repositories/static-repository.js +60 -0
- package/dist/repositories/static-repository.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var LionRapidEditor=(()=>{var
|
|
1
|
+
"use strict";var LionRapidEditor=(()=>{var ye=Object.defineProperty;var Ee=(s,t,e)=>t in s?ye(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var u=(s,t,e)=>Ee(s,typeof t!="symbol"?t+"":t,e);var ie=`
|
|
2
2
|
/* Reset inside shadow DOM */
|
|
3
3
|
:host {
|
|
4
4
|
all: initial;
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
color: #fff;
|
|
58
58
|
padding: 8px 12px;
|
|
59
59
|
border-radius: 8px;
|
|
60
|
-
margin-right: 8px;
|
|
60
|
+
margin-right: 8px; /* gap between panel (left) and the FAB button (right) */
|
|
61
61
|
box-shadow: 0 4px 12px rgba(0,0,0,0.25);
|
|
62
62
|
white-space: nowrap;
|
|
63
63
|
}
|
|
@@ -167,6 +167,43 @@
|
|
|
167
167
|
cursor: not-allowed;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
.lr-fab-browse {
|
|
171
|
+
background: none;
|
|
172
|
+
border: 1px solid rgba(255,255,255,0.3);
|
|
173
|
+
color: #fff;
|
|
174
|
+
padding: 4px 10px;
|
|
175
|
+
border-radius: 4px;
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
font-size: 13px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.lr-fab-browse:hover {
|
|
181
|
+
background: rgba(255,255,255,0.1);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.lr-fab-browse.active {
|
|
185
|
+
background: #f5a623;
|
|
186
|
+
border-color: #f5a623;
|
|
187
|
+
color: #1a1a2e;
|
|
188
|
+
font-weight: 600;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.lr-link-nav {
|
|
192
|
+
background: none;
|
|
193
|
+
border: 1px solid #2d7f7f;
|
|
194
|
+
color: #2d7f7f;
|
|
195
|
+
padding: 6px 12px;
|
|
196
|
+
border-radius: 4px;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
font-size: 13px;
|
|
199
|
+
font-weight: 600;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.lr-link-nav:hover {
|
|
203
|
+
background: #2d7f7f;
|
|
204
|
+
color: #fff;
|
|
205
|
+
}
|
|
206
|
+
|
|
170
207
|
/* Workflow action buttons (Phase 3) */
|
|
171
208
|
.lr-workflow-actions {
|
|
172
209
|
display: flex;
|
|
@@ -547,6 +584,6 @@
|
|
|
547
584
|
white-space: nowrap;
|
|
548
585
|
margin-top: 2px;
|
|
549
586
|
}
|
|
550
|
-
`;var O=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function ye(s){return s.replace(/"/g,""")}function oe(s,t){let n=`<${s.toLowerCase()}`;for(let[r,o]of Object.entries(t))n+=` ${r.toLowerCase()}="${ye(o)}"`;return n+=">",n}function ie(s){let t=s.search(/[\s>]/);return s.slice(1,t===-1?s.length:t).toLowerCase()}function ae(s){for(let t of s)if(t.startsWith("raw:"))return t.slice(4);return null}function E(s){let t={},e=0;function n(o){if(o.nodeType===Node.TEXT_NODE)return o.nodeValue??"";if(o.nodeType!==Node.ELEMENT_NODE)return"";let i=o,l=i.tagName.toLowerCase(),p={};for(let c=0;c<i.attributes.length;c++){let f=i.attributes[c];p[f.name.toLowerCase()]=f.value}e++;let a=e;if(t[String(a)]=[`raw:${oe(l,p)}`],O.has(l))return`<${a}/>`;let d="";for(let c=0;c<o.childNodes.length;c++)d+=n(o.childNodes[c]);return`<${a}>${d}</${a}>`}let r="";for(let o=0;o<s.childNodes.length;o++)r+=n(s.childNodes[o]);return{text:r,styles:t}}function T(s,t){let e=(s&65535)+(t&65535);return(s>>16)+(t>>16)+(e>>16)<<16|e&65535}function we(s,t){return s<<t|s>>>32-t}function U(s,t,e,n,r,o){return T(we(T(T(t,s),T(n,o)),r),e)}function v(s,t,e,n,r,o,i){return U(t&e|~t&n,s,t,r,o,i)}function x(s,t,e,n,r,o,i){return U(t&n|e&~n,s,t,r,o,i)}function y(s,t,e,n,r,o,i){return U(t^e^n,s,t,r,o,i)}function w(s,t,e,n,r,o,i){return U(e^(t|~n),s,t,r,o,i)}function Ee(s,t){s[t>>5]|=128<<t%32,s[(t+64>>>9<<4)+14]=t;let e=1732584193,n=-271733879,r=-1732584194,o=271733878;for(let i=0;i<s.length;i+=16){let l=e,p=n,a=r,d=o;e=v(e,n,r,o,s[i],7,-680876936),o=v(o,e,n,r,s[i+1],12,-389564586),r=v(r,o,e,n,s[i+2],17,606105819),n=v(n,r,o,e,s[i+3],22,-1044525330),e=v(e,n,r,o,s[i+4],7,-176418897),o=v(o,e,n,r,s[i+5],12,1200080426),r=v(r,o,e,n,s[i+6],17,-1473231341),n=v(n,r,o,e,s[i+7],22,-45705983),e=v(e,n,r,o,s[i+8],7,1770035416),o=v(o,e,n,r,s[i+9],12,-1958414417),r=v(r,o,e,n,s[i+10],17,-42063),n=v(n,r,o,e,s[i+11],22,-1990404162),e=v(e,n,r,o,s[i+12],7,1804603682),o=v(o,e,n,r,s[i+13],12,-40341101),r=v(r,o,e,n,s[i+14],17,-1502002290),n=v(n,r,o,e,s[i+15],22,1236535329),e=x(e,n,r,o,s[i+1],5,-165796510),o=x(o,e,n,r,s[i+6],9,-1069501632),r=x(r,o,e,n,s[i+11],14,643717713),n=x(n,r,o,e,s[i],20,-373897302),e=x(e,n,r,o,s[i+5],5,-701558691),o=x(o,e,n,r,s[i+10],9,38016083),r=x(r,o,e,n,s[i+15],14,-660478335),n=x(n,r,o,e,s[i+4],20,-405537848),e=x(e,n,r,o,s[i+9],5,568446438),o=x(o,e,n,r,s[i+14],9,-1019803690),r=x(r,o,e,n,s[i+3],14,-187363961),n=x(n,r,o,e,s[i+8],20,1163531501),e=x(e,n,r,o,s[i+13],5,-1444681467),o=x(o,e,n,r,s[i+2],9,-51403784),r=x(r,o,e,n,s[i+7],14,1735328473),n=x(n,r,o,e,s[i+12],20,-1926607734),e=y(e,n,r,o,s[i+5],4,-378558),o=y(o,e,n,r,s[i+8],11,-2022574463),r=y(r,o,e,n,s[i+11],16,1839030562),n=y(n,r,o,e,s[i+14],23,-35309556),e=y(e,n,r,o,s[i+1],4,-1530992060),o=y(o,e,n,r,s[i+4],11,1272893353),r=y(r,o,e,n,s[i+7],16,-155497632),n=y(n,r,o,e,s[i+10],23,-1094730640),e=y(e,n,r,o,s[i+13],4,681279174),o=y(o,e,n,r,s[i+0],11,-358537222),r=y(r,o,e,n,s[i+3],16,-722521979),n=y(n,r,o,e,s[i+6],23,76029189),e=y(e,n,r,o,s[i+9],4,-640364487),o=y(o,e,n,r,s[i+12],11,-421815835),r=y(r,o,e,n,s[i+15],16,530742520),n=y(n,r,o,e,s[i+2],23,-995338651),e=w(e,n,r,o,s[i],6,-198630844),o=w(o,e,n,r,s[i+7],10,1126891415),r=w(r,o,e,n,s[i+14],15,-1416354905),n=w(n,r,o,e,s[i+5],21,-57434055),e=w(e,n,r,o,s[i+12],6,1700485571),o=w(o,e,n,r,s[i+3],10,-1894986606),r=w(r,o,e,n,s[i+10],15,-1051523),n=w(n,r,o,e,s[i+1],21,-2054922799),e=w(e,n,r,o,s[i+8],6,1873313359),o=w(o,e,n,r,s[i+15],10,-30611744),r=w(r,o,e,n,s[i+6],15,-1560198380),n=w(n,r,o,e,s[i+13],21,1309151649),e=w(e,n,r,o,s[i+4],6,-145523070),o=w(o,e,n,r,s[i+11],10,-1120210379),r=w(r,o,e,n,s[i+2],15,718787259),n=w(n,r,o,e,s[i+9],21,-343485551),e=T(e,l),n=T(n,p),r=T(r,a),o=T(o,d)}return[e,n,r,o]}function ke(s){let t="0123456789abcdef",e="";for(let n=0;n<s.length*4;n++)e+=t.charAt(s[n>>2]>>n%4*8+4&15)+t.charAt(s[n>>2]>>n%4*8&15);return e}function Se(s){let t=[];for(let e=0;e<s.length*8;e+=8)t[e>>5]|=(s.charCodeAt(e/8)&255)<<e%32;return t}function Ce(s){return ke(Ee(Se(s),s.length*8))}function I(s){let t=s.trim();return"auto_"+Ce(t).substring(0,12)}var Te="p,h1,h2,h3,h4,h5,h6,li,td,th,label,button,figcaption,dt,dd,summary,caption";function le(s){let t=s.closest("[data-lr-block]");if(t){let r=t.getAttribute("data-lr-block"),o=t.getAttribute("data-lr-original"),i,l=null;if(o){let p=document.createElement(t.tagName);p.innerHTML=o,i=E(p),l=E(t)}else i=E(t);return{key:r,unit:i,translatedUnit:l,element:t}}let e=s.closest(Te);if(e){let r=E(e);return{key:I(r.text),unit:r,translatedUnit:null,element:e}}let n=s.textContent?.trim();return n&&n.length>=2?{key:I(n),unit:{text:n,styles:{}},translatedUnit:null,element:s}:null}var Le=new Set(["SCRIPT","STYLE","CODE","PRE","TEXTAREA","NOSCRIPT","SVG"]),de="p,h1,h2,h3,h4,h5,h6,li,td,th,label,button,figcaption,dt,dd,summary,caption",z=class{constructor(t,e,n,r){u(this,"overlay");u(this,"currentTarget",null);u(this,"onSelect");u(this,"rafId",null);u(this,"active",!0);u(this,"rootElement");u(this,"snapshotKeyMap");this.onSelect=e,this.rootElement=n||document.body,this.snapshotKeyMap=r||null,this.overlay=document.createElement("div"),this.overlay.className="lr-overlay",t.appendChild(this.overlay),this.handleMouseOver=this.handleMouseOver.bind(this),this.handleClick=this.handleClick.bind(this),this.handleScroll=this.handleScroll.bind(this),document.addEventListener("mouseover",this.handleMouseOver,!0),document.addEventListener("click",this.handleClick,!0),window.addEventListener("scroll",this.handleScroll,!0),window.addEventListener("resize",this.handleScroll)}destroy(){this.active=!1,document.removeEventListener("mouseover",this.handleMouseOver,!0),document.removeEventListener("click",this.handleClick,!0),window.removeEventListener("scroll",this.handleScroll,!0),window.removeEventListener("resize",this.handleScroll),this.rafId!==null&&cancelAnimationFrame(this.rafId),this.overlay.remove()}clearHighlight(){this.currentTarget=null,this.overlay.classList.remove("active")}handleMouseOver(t){if(!this.active)return;let e=t.target;if(!e||!e.closest||e.closest("#__lionrapid-editor")||!this.rootElement.contains(e))return;if(this.shouldSkip(e)){this.clearHighlight();return}let n=e.closest(de)||e.closest("[data-lr-block]");if(!n){this.clearHighlight();return}n!==this.currentTarget&&(this.currentTarget=n,this.positionOverlay(n))}handleClick(t){if(!this.active)return;let e=t.target;if(!e||!e.closest||e.closest("#__lionrapid-editor")||!this.rootElement.contains(e))return;let n=e.closest(de)||e.closest("[data-lr-block]");if(!n||this.shouldSkip(n))return;if(t.preventDefault(),t.stopPropagation(),this.snapshotKeyMap){let o=n.getAttribute("data-lr-snap-idx");if(o!==null){let i=parseInt(o,10),l=this.snapshotKeyMap.get(i);if(l){let p=E(n);this.onSelect({key:l,unit:p,translatedUnit:null,element:n});return}}return}let r=le(n);r&&this.onSelect(r)}handleScroll(){this.currentTarget&&(this.rafId!==null&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(()=>{this.currentTarget&&this.positionOverlay(this.currentTarget)}))}positionOverlay(t){let e=t.getBoundingClientRect();this.overlay.style.top=`${e.top}px`,this.overlay.style.left=`${e.left}px`,this.overlay.style.width=`${e.width}px`,this.overlay.style.height=`${e.height}px`,this.overlay.classList.add("active")}shouldSkip(t){let e=t;for(;e;){if(Le.has(e.tagName)||e.hasAttribute("data-no-translate")||e.getAttribute("translate")==="no")return!0;e=e.parentElement}return!1}};var B=class{constructor(t,e,n,r,o,i=null,l={}){u(this,"el");u(this,"langBtnEl");u(this,"langMenuEl");u(this,"progressEl");u(this,"expanded",!1);u(this,"currentLocale");u(this,"onLanguageChange");u(this,"onExit");u(this,"onCaptureSnapshot");u(this,"dragging",!1);u(this,"dragOffsetX",0);u(this,"dragOffsetY",0);this.onLanguageChange=r,this.onExit=o,this.onCaptureSnapshot=i,this.currentLocale=n;let p=l.mode??"capture";this.el=document.createElement("div"),this.el.className="lr-fab";let a=document.createElement("button");a.className="lr-fab-btn",a.textContent="LR",a.addEventListener("click",h=>{this.dragging||(h.stopPropagation(),this.toggle())}),this.el.appendChild(a);let d=document.createElement("div");d.className="lr-fab-panel";let c=document.createElement("div");c.className="lr-lang-dropdown",this.langBtnEl=document.createElement("button"),this.langBtnEl.className="lr-lang-btn",this.langBtnEl.textContent=n.toUpperCase(),this.langBtnEl.addEventListener("click",h=>{h.stopPropagation(),this.langMenuEl.classList.toggle("open")}),c.appendChild(this.langBtnEl),this.langMenuEl=document.createElement("div"),this.langMenuEl.className="lr-lang-menu";for(let h of e){let m=document.createElement("button");m.className="lr-lang-item",h===n&&m.classList.add("active"),m.textContent=h.toUpperCase(),m.addEventListener("click",b=>{b.stopPropagation(),this.currentLocale=h,this.langBtnEl.textContent=h.toUpperCase(),this.langMenuEl.classList.remove("open"),this.langMenuEl.querySelectorAll(".lr-lang-item").forEach(M=>M.classList.remove("active")),m.classList.add("active"),this.onLanguageChange(h)}),this.langMenuEl.appendChild(m)}if(c.appendChild(this.langMenuEl),d.appendChild(c),this.onCaptureSnapshot){let h=document.createElement("button");h.className="lr-fab-snapshot",p==="recapture"?(h.textContent="Save re-capture",h.title="Save this page as a new version of the existing snapshot"):(h.textContent="Capture",h.title="Capture a redacted snapshot of this page for translators"),h.addEventListener("click",m=>{m.stopPropagation(),this.onCaptureSnapshot&&this.onCaptureSnapshot()}),d.appendChild(h)}this.progressEl=document.createElement("span"),this.progressEl.className="lr-fab-progress",d.appendChild(this.progressEl);let f=document.createElement("button");f.className="lr-fab-exit",f.textContent="Exit",f.addEventListener("click",()=>this.onExit()),d.appendChild(f),this.el.appendChild(d),t.appendChild(this.el),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),a.addEventListener("mousedown",this.handleMouseDown)}toggle(){this.expanded=!this.expanded,this.el.classList.toggle("expanded",this.expanded)}updateProgress(t,e){this.progressEl.textContent=`${t}/${e}`}getCurrentLocale(){return this.currentLocale}destroy(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),this.el.remove()}handleMouseDown(t){this.dragging=!1,this.dragOffsetX=t.clientX-this.el.getBoundingClientRect().left,this.dragOffsetY=t.clientY-this.el.getBoundingClientRect().top,document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}handleMouseMove(t){this.dragging=!0;let e=Math.max(0,Math.min(t.clientX-this.dragOffsetX,window.innerWidth-this.el.offsetWidth)),n=Math.max(0,Math.min(t.clientY-this.dragOffsetY,window.innerHeight-this.el.offsetHeight));this.el.style.left=`${e}px`,this.el.style.top=`${n}px`,this.el.style.right="auto",this.el.style.bottom="auto"}handleMouseUp(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),this.dragging&&setTimeout(()=>{this.dragging=!1},0)}};var R=class{serialize(t){let{text:e,styles:n}=t,r=/<(\/?)?(\d+)(\/)?>/g,o="",i=0,l;for(;(l=r.exec(e))!==null;){o+=e.slice(i,l.index);let[p,a,d]=l,c=n[d]??[],f=ae(c);if(f){let h=ie(f),m=O.has(h);a?m||(o+=`</${h}>`):o+=f}else o+=p;i=l.index+p.length}return o+=e.slice(i),o}};var Me=new R;function Y(s,t,e,n,r,o){s.hasAttribute("data-lr-original")||s.setAttribute("data-lr-original",s.innerHTML);let l=window.LionRapid?.autoTranslator?Ae():null;if(l){let d=`${r}:${o}:${n}`;l.set(d,t,e)}let p=/<\/?[0-9]+\/?>/.test(t),a=e&&Object.keys(e).length>0;if(p){let d={text:t,styles:e};s.innerHTML=Me.serialize(d)}else a||(s.textContent=t);s.setAttribute("data-lr-block",n),s.setAttribute("data-lionrapid-client","1")}function Ae(){try{let s=window.LionRapid;if(!s)return null;let t=s.autoTranslator;if(!t)return null;let e=t.core;if(!e)return null;let n=e.cache;return!n||typeof n.set!="function"?null:n}catch{return null}}var Re={emails:!0,urls:!0,numbers:!0,phones:!0},H={email:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,url:/^(https?:\/\/|www\.)[^\s]+$/i,number:/^[\d\s.,+-]+$/,phone:/^[+\d][\d\s().-]{6,}$/},D=class{constructor(t={},e=2){u(this,"patterns");u(this,"minTextLength");this.patterns={...Re,...t},this.minTextLength=e}shouldExclude(t){let e=t.trim();return!!(e.length<this.minTextLength||this.patterns.emails&&H.email.test(e)||this.patterns.urls&&H.url.test(e)||this.patterns.numbers&&H.number.test(e)||this.patterns.phones&&H.phone.test(e))}};var G="p,h1,h2,h3,h4,h5,h6,li,td,th,label,button,figcaption,dt,dd,summary,caption",Pe=new Set(["SCRIPT","STYLE","CODE","PRE","TEXTAREA","NOSCRIPT","SVG"]),_e=["data-lionrapid-translated","data-lionrapid-client","data-no-translate","data-lr-block"],P=class{constructor(t={},e=[],n=2){u(this,"excludeFilter");u(this,"excludeSelectors");this.excludeFilter=new D(t,n),this.excludeSelectors=e}extract(t,e=!1){let n=[],r=t.querySelectorAll(G),o=[];t instanceof Element&&t.matches(G)&&o.push(t);for(let i=0;i<r.length;i++)o.push(r[i]);for(let i=0;i<o.length;i++){let l=o[i];if(this.isInsideSkipTag(l)||!e&&this.hasSkipAttribute(l)||this.matchesExcludeSelector(l)||l.getAttribute("translate")==="no"||l.querySelector(G))continue;let p=l.getAttribute("data-lr-block"),a=l.getAttribute("data-lr-original"),d;if(a){let h=document.createElement(l.tagName);h.innerHTML=a,d=E(h)}else d=E(l);let c=d.text.replace(/<\/?[0-9]+\/?>/g,"");if(this.excludeFilter.shouldExclude(c))continue;let f;if(p)f=p;else{let h=l.getAttribute("data-i18n");h?f=h.includes(":")?h:`common:${h}`:f=I(d.text)}n.push({element:l,unit:d,key:f})}return n}isInsideSkipTag(t){let e=t.parentElement;for(;e;){if(Pe.has(e.tagName))return!0;e=e.parentElement}return!1}hasSkipAttribute(t){let e=t;for(;e;){for(let n of _e)if(e.hasAttribute(n))return!0;e=e.parentElement}return!1}matchesExcludeSelector(t){for(let e of this.excludeSelectors)try{if(t.matches(e)||t.closest(e))return!0}catch{}return!1}};var Ie=new R,j=class{constructor(t,e,n,r,o,i,l=""){u(this,"el");u(this,"bodyEl");u(this,"statusEl");u(this,"api");u(this,"locale");u(this,"namespace");u(this,"defaultLocale");u(this,"current",null);u(this,"blockExtractor");u(this,"onBlockClick");u(this,"statusMap",new Map);u(this,"unsavedKeys",new Set);u(this,"onProgressUpdate",null);u(this,"lastFetchTime",0);u(this,"lastFlushTime",0);u(this,"userRole");u(this,"workflowInfo",null);u(this,"workflowInfoFetched",!1);this.api=e,this.locale=n,this.namespace=r,this.defaultLocale=o,this.onBlockClick=i,this.userRole=l,this.blockExtractor=new P,this.el=document.createElement("div"),this.el.className="lr-sidebar";let p=document.createElement("div");p.className="lr-sidebar-resize",this.initResize(p),this.el.appendChild(p);let a=document.createElement("div");a.className="lr-sidebar-header";let d=document.createElement("span");d.className="lr-sidebar-title",d.textContent="Edit Translation",a.appendChild(d);let c=document.createElement("button");c.className="lr-sidebar-close",c.innerHTML="×",c.addEventListener("click",()=>this.close()),a.appendChild(c),this.el.appendChild(a),this.bodyEl=document.createElement("div"),this.bodyEl.className="lr-sidebar-body",this.el.appendChild(this.bodyEl),this.statusEl=document.createElement("div"),this.statusEl.className="lr-status",this.api.setStatusCallback((f,h)=>{this.statusEl.textContent=h||f,this.statusEl.className=`lr-status ${f}`}),this.api.setFlushedCallback(async f=>{this.lastFlushTime=Date.now();let h=await this.api.fetchStatus(f,this.locale,this.namespace);for(let[m,b]of Object.entries(h))this.statusMap.set(m,b),this.unsavedKeys.delete(m);this.refreshBlocksList(),this.emitProgress()}),t.appendChild(this.el)}open(t){this.current=t,this.el.classList.add("open"),this.renderContent(t)}close(){this.current=null,this.el.classList.remove("open")}isOpen(){return this.el.classList.contains("open")}updateLocale(t){this.locale=t,this.statusMap.clear(),this.unsavedKeys.clear()}setProgressCallback(t){this.onProgressUpdate=t}async hydrateStatus(){let t=this.blockExtractor.extract(document.body,!0),e=t.map(r=>r.key);if(e.length===0)return;let n=await this.api.fetchStatus(e,this.locale,this.namespace);for(let[r,o]of Object.entries(n))this.statusMap.set(r,o);for(let r of t){let o=this.statusMap.get(r.key);o&&o.text&&!o.isReady&&Y(r.element,o.text,r.unit.styles,r.key,this.locale,this.namespace)}this.emitProgress()}getTranslatedCount(){let t=0;for(let e of this.statusMap.values())e&&e.rowState!=="empty"&&t++;return t}getTotalCount(){return this.blockExtractor.extract(document.body,!0).length}emitProgress(){this.onProgressUpdate&&this.onProgressUpdate(this.getTranslatedCount(),this.getTotalCount())}destroy(){this.el.remove()}async renderContent(t){let{key:e,unit:n,element:r}=t;if(this.bodyEl.innerHTML="",this.lastFlushTime>this.lastFetchTime||this.lastFetchTime===0){let f=this.blockExtractor.extract(document.body,!0).map(m=>m.key);f.includes(e)||f.push(e);let h=await this.api.fetchStatus(f,this.locale,this.namespace);for(let[m,b]of Object.entries(h))this.statusMap.set(m,b);this.lastFetchTime=Date.now()}else{let c=await this.api.fetchStatus([e],this.locale,this.namespace);c[e]!==void 0&&this.statusMap.set(e,c[e])}let i=this.statusMap.get(e)??null;this.addField("Key",()=>{let c=document.createElement("div");return c.className="lr-field-key",c.textContent=e,c}),this.addField("Original",()=>{let c=document.createElement("div");return c.className="lr-field-original",c.innerHTML=this.renderTextWithTags(n.text),c});let l=this.locale===this.defaultLocale,p=l||i?.isLocked||i?.isReady||!1,a=document.createElement("textarea");this.addField("Translation",()=>(a.className="lr-textarea",a.value=i?.text||t.translatedUnit?.text||"",a.placeholder=n.text,p&&(a.readOnly=!0,a.classList.add("lr-textarea-locked"),a.title=l?"Source language \u2014 switch to a target language to edit":i?.isReady?"Approved for delivery \u2014 read only":"Locked \u2014 read only"),a)),this.bodyEl.appendChild(this.statusEl);let d=document.createElement("div");this.addField("Preview",()=>(d.className="lr-preview",a.value&&(d.innerHTML=this.renderPreview(a.value,n.styles)),d)),l||this.renderWorkflowActions(e,i),p||a.addEventListener("input",()=>{let c=a.value;d.innerHTML=this.renderPreview(c,n.styles),c&&Y(r,c,n.styles,e,this.locale,this.namespace),this.unsavedKeys.add(e),this.api.queueSave({key:e,locale:this.locale,namespace:this.namespace,text:c,styles:n.styles})}),this.renderBlocksList(),p||setTimeout(()=>a.focus(),100)}renderWorkflowActions(t,e){let n=this.userRole==="project_manager"||this.userRole==="admin",r=!!e?.isReady,o=!!e?.isLocked,i=!!e?.isConfirmed,l=e?.canEdit!==!1,p=`${this.locale}:${this.namespace}:${t}`,a=document.createElement("div");a.className="lr-workflow-actions";let d=document.createElement("div");d.className="lr-wf-strip-host",a.appendChild(d),this.renderWorkflowStrip(d,e);let c=(f,h,m="secondary")=>{let b=document.createElement("button");b.className=`lr-wf-btn lr-wf-${m}`,b.textContent=f,b.addEventListener("click",async()=>{b.disabled=!0;let M=await this.api.transitionTarget(p,h);b.disabled=!1,M&&await this.refreshStatusForKey(t)}),a.appendChild(b)};if(l&&!o&&!r&&(i?(this.workflowInfo?.workflowMode==="per_file"||c("Advance","advance","primary"),c("Unconfirm","unconfirm")):(c("Confirm","confirm","primary"),c("Reject","reject","danger"))),n&&(r?c("Unmark Ready","unmark-ready","danger"):c("Mark Ready","mark-ready","primary")),!l&&!n&&!r&&!o){let f=document.createElement("span");f.className="lr-wf-note",f.textContent=typeof e?.stageIndex=="number"&&e.stageIndex>0?`Row already advanced (stage ${e.stageIndex+1}) \u2014 out of your scope.`:"You are not assigned to this row at the current stage.",a.appendChild(f)}a.children.length>0&&this.bodyEl.appendChild(a)}renderWorkflowStrip(t,e){if(this.workflowInfo){let n=this.buildWorkflowStripNode(this.workflowInfo,e);t.replaceChildren(...n?[n]:[]);return}this.workflowInfoFetched||(this.workflowInfoFetched=!0,this.api.fetchWorkflowInfo().then(n=>{if(this.workflowInfo=n,!this.current)return;let r=this.statusMap.get(this.current.key)??e??null,o=n?this.buildWorkflowStripNode(n,r):null;t.isConnected&&t.replaceChildren(...o?[o]:[])}))}buildWorkflowStripNode(t,e){if(!t.stages||t.stages.length===0)return null;let n=null;t.isPmAdmin?n=typeof e?.stageIndex=="number"?e.stageIndex:null:t.userAssignedStages.length>0&&(n=t.userAssignedStages[0]);let r=document.createElement("div");r.className="lr-wf-strip";let o=document.createElement("div");o.className="lr-wf-strip-stages",t.stages.forEach((l,p)=>{let a=document.createElement("span");if(a.className="lr-wf-strip-stage",n!==null&&l.index===n?a.classList.add("is-active"):a.classList.add("is-muted"),a.textContent=l.name,o.appendChild(a),p<t.stages.length-1){let d=document.createElement("span");d.className="lr-wf-strip-sep",d.textContent="\u2192",o.appendChild(d)}}),r.appendChild(o);let i=document.createElement("div");if(i.className="lr-wf-strip-caption",n!==null){let p=t.stages.find(d=>d.index===n)?.name??`Stage ${n+1}`,a=t.isPmAdmin?"Row currently at":"You are here";i.textContent=`${a}: stage ${n+1} of ${t.stages.length} \u2014 ${p}`}else!t.isPmAdmin&&t.userAssignedStages.length===0?i.textContent="You have no stage assignment on this project.":i.textContent=`${t.stages.length} stages`;return r.appendChild(i),r}async refreshStatusForKey(t){let e=await this.api.fetchStatus([t],this.locale,this.namespace);for(let[n,r]of Object.entries(e))this.statusMap.set(n,r);this.current&&this.renderContent(this.current),this.emitProgress()}addField(t,e){let n=document.createElement("div");n.className="lr-field";let r=document.createElement("span");r.className="lr-field-label",r.textContent=t,n.appendChild(r),n.appendChild(e()),this.bodyEl.appendChild(n)}getDotClass(t){if(this.unsavedKeys.has(t))return"unsaved";let e=this.statusMap.get(t);return e?e.isLocked?"locked":e.canEdit===!1&&typeof e.stageIndex=="number"&&e.stageIndex>0?"readonly":e.isReady?"ready":e.isConfirmed?"confirmed":e.rowState==="edited"?"edited":e.rowState==="machine_translated"?"mt":"missing":"missing"}renderTextWithTags(t){return t.replace(/<(\/?)?(\d+)(\/)?>/g,e=>`<span class="lr-field-tag">${e}</span>`)}renderPreview(t,e){if(!t)return"";if(Object.keys(e).length>0){let n={text:t,styles:e};return Ie.serialize(n)}return t}initResize(t){let e=0,n=0,r=i=>{let l=n+(e-i.clientX),p=Math.max(280,Math.min(600,l));this.el.style.width=`${p}px`},o=()=>{t.classList.remove("active"),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o)};t.addEventListener("mousedown",i=>{i.preventDefault(),e=i.clientX,n=this.el.offsetWidth,t.classList.add("active"),document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)})}refreshBlocksList(){let t=this.bodyEl.querySelector(".lr-blocks-section");t&&t.remove(),this.renderBlocksList()}renderBlocksList(){let t=document.createElement("div");t.className="lr-blocks-section";let e=this.blockExtractor.extract(document.body,!0),n=this.getTranslatedCount(),r=document.createElement("div");r.className="lr-blocks-title",r.textContent=`Blocks on this page (${n}/${e.length} translated)`,t.appendChild(r);for(let o of e){let i=document.createElement("div");i.className="lr-block-item",this.current&&o.element===this.current.element&&i.classList.add("active");let p=document.createElement("span");p.className="lr-status-dot",p.classList.add(this.getDotClass(o.key)),i.appendChild(p);let a=document.createElement("div");a.className="lr-block-text";let d=o.unit.text.replace(/<\/?[0-9]+\/?>/g,""),c=document.createElement("div");c.className="lr-block-source",c.textContent=d.length>60?d.slice(0,60)+"...":d,c.title=d,a.appendChild(c);let f=this.statusMap.get(o.key);if(f&&f.text){let h=document.createElement("div");h.className="lr-block-preview";let m=f.text.replace(/<\/?[0-9]+\/?>/g,"");h.textContent=m.length>50?m.slice(0,50)+"...":m,a.appendChild(h)}i.appendChild(a),i.addEventListener("click",()=>{o.element.scrollIntoView({behavior:"smooth",block:"center"}),this.onBlockClick({key:o.key,unit:o.unit,translatedUnit:null,element:o.element})}),t.appendChild(i)}this.bodyEl.appendChild(t)}};var F=class{constructor(t,e,n){u(this,"queue",[]);u(this,"apiBase");u(this,"sessionToken");u(this,"projectId");u(this,"flushInterval",null);u(this,"renewalInterval",null);u(this,"onStatus",()=>{});u(this,"onFlushed",()=>{});u(this,"onSessionExpired",null);u(this,"workflowInfoPromise",null);u(this,"statusAbort",null);u(this,"handleVisibility",()=>{document.visibilityState==="hidden"&&this.flush()});this.apiBase=t.replace(/\/$/,""),this.sessionToken=e,this.projectId=n}setStatusCallback(t){this.onStatus=t}setFlushedCallback(t){this.onFlushed=t}setSessionExpiredCallback(t){this.onSessionExpired=t}startAutoFlush(){this.flushInterval=setInterval(()=>this.flush(),3e4),document.addEventListener("visibilitychange",this.handleVisibility),this.renewalInterval=setInterval(()=>this.maybeRenewSession(),6e4)}async stopAndFlush(){this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.renewalInterval&&(clearInterval(this.renewalInterval),this.renewalInterval=null),document.removeEventListener("visibilitychange",this.handleVisibility),await this.flush()}queueSave(t){let e=this.queue.findIndex(n=>n.key===t.key&&n.locale===t.locale&&n.namespace===t.namespace);e>=0?this.queue[e]=t:this.queue.push(t),this.onStatus("unsaved",`${this.queue.length} unsaved`),this.queue.length>50&&this.flush()}async flush(){if(this.queue.length===0)return;let t=[...this.queue];this.onStatus("saving");try{let e=await fetch(`${this.apiBase}/api/integrations/targets/batch`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.sessionToken}`},body:JSON.stringify({translations:t.map(r=>({key:`${r.locale}:${r.namespace}:${r.key}`,value:{text:r.text,styles:r.styles}}))})});if(e.status===401){this.handleSessionExpired();return}if(!e.ok)throw new Error(`HTTP ${e.status}`);let n=t.map(r=>r.key);for(let r of t){let o=this.queue.indexOf(r);o>=0&&this.queue.splice(o,1)}this.onFlushed(n),this.queue.length===0?this.onStatus("saved","All changes saved"):this.onStatus("unsaved",`${this.queue.length} unsaved`)}catch(e){this.onStatus("error",`Save failed: ${e.message}`)}}async fetchStatus(t,e,n){if(t.length===0)return{};this.statusAbort&&this.statusAbort.abort(),this.statusAbort=new AbortController;let r=t.slice(0,200),o=new URLSearchParams({locale:e,namespace:n,keys:r.join(",")});try{let i=await fetch(`${this.apiBase}/api/integrations/targets/status?${o}`,{headers:{Authorization:`Bearer ${this.sessionToken}`},signal:this.statusAbort.signal});return i.status===401?(this.handleSessionExpired(),{}):i.ok?(await i.json()).translations:{}}catch(i){return i.name==="AbortError"?{}:{}}}get pendingCount(){return this.queue.length}async fetchWorkflowInfo(){return this.workflowInfoPromise?this.workflowInfoPromise:(this.workflowInfoPromise=(async()=>{try{let t=await fetch(`${this.apiBase}/api/integrations/editor/workflow`,{headers:{Authorization:`Bearer ${this.sessionToken}`}});if(t.status===401)return this.handleSessionExpired(),null;if(!t.ok)return null;let e=await t.json();return{stages:Array.isArray(e.stages)?e.stages:[],userAssignedStages:Array.isArray(e.user_assigned_stages)?e.user_assigned_stages:[],isPmAdmin:!!e.is_pm_admin,workflowMode:e.workflow_mode==="per_file"?"per_file":"per_row"}}catch{return null}})(),this.workflowInfoPromise)}async maybeRenewSession(){let t=this.getSessionExp();!t||t*1e3-Date.now()>12e4||await this.renewSession()}async renewSession(){try{let t=await fetch(`${this.apiBase}/api/editor/renew`,{method:"POST",headers:{Authorization:`Bearer ${this.sessionToken}`}});if(t.status===401){this.handleSessionExpired();return}if(!t.ok)return;let e=await t.json();this.sessionToken=e.session_token;try{let r=(this.sessionToken.startsWith("es_")?this.sessionToken.slice(3):this.sessionToken).split(".");if(r.length===3){let o=JSON.parse(atob(r[1]));sessionStorage.setItem("__lr_editor_session",JSON.stringify({token:this.sessionToken,exp:o.exp||0})),document.cookie="__lr_editor_active=1; path=/; SameSite=Lax"}}catch{}}catch{}}getSessionExp(){try{let e=(this.sessionToken.startsWith("es_")?this.sessionToken.slice(3):this.sessionToken).split(".");return e.length!==3?null:JSON.parse(atob(e[1])).exp||null}catch{return null}}handleSessionExpired(){document.cookie="__lr_editor_active=; path=/; SameSite=Lax; Max-Age=0",this.onStatus("error","Session expired. Please reopen the editor from the dashboard."),this.onSessionExpired&&this.onSessionExpired()}async createSnapshot(t){try{let e=await fetch(`${this.apiBase}/api/editor/snapshots`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.sessionToken}`},body:JSON.stringify({pageUrl:t.pageUrl,title:t.title,viewport:t.viewport,textEntries:t.textEntries,html:t.html})});if(e.status===401)return this.handleSessionExpired(),null;if(!e.ok)throw new Error(`HTTP ${e.status}`);let n=await e.json();return{snapshotUuid:n.snapshot_uuid||n.snapshotUuid}}catch(e){return this.onStatus("error",`Snapshot failed: ${e.message}`),null}}async recaptureSnapshot(t,e){try{let n=await fetch(`${this.apiBase}/api/editor/snapshots/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.sessionToken}`},body:JSON.stringify({pageUrl:e.pageUrl,title:e.title,viewport:e.viewport,textEntries:e.textEntries,html:e.html})});if(n.status===401)return this.handleSessionExpired(),null;if(!n.ok)throw new Error(`HTTP ${n.status}`);let r=await n.json();return{snapshotUuid:r.snapshot_uuid||r.snapshotUuid,version:r.version||1}}catch(n){return this.onStatus("error",`Re-capture failed: ${n.message}`),null}}async getSnapshot(t){try{let e=await fetch(`${this.apiBase}/api/editor/snapshots/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${this.sessionToken}`}});return e.status===401?(this.handleSessionExpired(),null):e.ok?await e.json():null}catch{return null}}async listSnapshots(){try{let t=await fetch(`${this.apiBase}/api/editor/snapshots`,{headers:{Authorization:`Bearer ${this.sessionToken}`}});return t.status===401?(this.handleSessionExpired(),[]):t.ok?(await t.json()).snapshots||[]:[]}catch{return[]}}async deleteSnapshot(t){try{let e=await fetch(`${this.apiBase}/api/editor/snapshots/${encodeURIComponent(t)}`,{method:"DELETE",headers:{Authorization:`Bearer ${this.sessionToken}`}});return e.status===401?(this.handleSessionExpired(),!1):e.ok}catch{return!1}}async transitionTarget(t,e){try{let n=await fetch(`${this.apiBase}/api/integrations/targets/${encodeURIComponent(t)}/${e}`,{method:"POST",headers:{Authorization:`Bearer ${this.sessionToken}`}});return n.status===401?(this.handleSessionExpired(),null):n.ok?await n.json():(this.onStatus("error",`${e} failed: HTTP ${n.status}`),null)}catch(n){return this.onStatus("error",`${e} failed: ${n.message}`),null}}};var _="[REDACTED]",Ne=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}/gi,$e=/(?:\+\d{1,3}[\s.-]?)?(?:\(\d{3}\)|\d{3})[\s.-]\d{3}[\s.-]\d{4}/g,Oe=/\b\d{3}[\s-]\d{2}[\s-]\d{4}\b/g,Ue=/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g,ze=/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi,Be=/\b\d(?:[ -]?\d){12,18}\b/g;function He(s){if(s.length<13||s.length>19)return!1;let t=0,e=!1;for(let n=s.length-1;n>=0;n--){let r=s.charCodeAt(n)-48;if(r<0||r>9)return!1;e&&(r*=2,r>9&&(r-=9)),t+=r,e=!e}return t%10===0}function De(s){let t=s.split(".");if(t.length!==4)return!1;for(let e of t){let n=Number(e);if(!Number.isInteger(n)||n<0||n>255)return!1}return!0}function je(s){if(!s)return s;let t=s;return t=t.replace(ze,_),t=t.replace(Ne,_),t=t.replace($e,_),t=t.replace(Oe,_),t=t.replace(Ue,e=>De(e)?_:e),t=t.replace(Be,e=>{let n=e.replace(/[\s-]/g,"");return He(n)?_:e}),t}var Fe=new Set(["CODE","PRE","STYLE","TEXTAREA"]);function ce(s){let t=document.createTreeWalker(s,NodeFilter.SHOW_TEXT),e=[],n=t.nextNode();for(;n;){if(!Ke(n)){let r=n.nodeValue||"",o=je(r);o!==r&&e.push({node:n,value:o})}n=t.nextNode()}for(let{node:r,value:o}of e)r.nodeValue=o}function Ke(s){let t=s.parentNode;for(;t&&t.nodeType===Node.ELEMENT_NODE;){let e=t;if(Fe.has(e.tagName)||e.hasAttribute("data-no-redact"))return!0;t=e.parentNode}return!1}var ue="[REDACTED]";function pe(){let s=document.documentElement.cloneNode(!0),t=Je(s);return We(s),qe(s),Ve(s),Xe(s),Ye(s),Ge(s),{html:`<!DOCTYPE html>
|
|
551
|
-
`+s.outerHTML,textEntries:t,pageUrl:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio||1}}}function
|
|
587
|
+
`;var D=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function ke(s){return s.replace(/"/g,""")}function ae(s,t){let n=`<${s.toLowerCase()}`;for(let[r,o]of Object.entries(t))n+=` ${r.toLowerCase()}="${ke(o)}"`;return n+=">",n}function le(s){let t=s.search(/[\s>]/);return s.slice(1,t===-1?s.length:t).toLowerCase()}function ce(s){for(let t of s)if(t.startsWith("raw:"))return t.slice(4);return null}function S(s){let t={},e=0;function n(o){if(o.nodeType===Node.TEXT_NODE)return o.nodeValue??"";if(o.nodeType!==Node.ELEMENT_NODE)return"";let i=o,a=i.tagName.toLowerCase(),p={};for(let c=0;c<i.attributes.length;c++){let h=i.attributes[c];p[h.name.toLowerCase()]=h.value}e++;let l=e;if(t[String(l)]=[`raw:${ae(a,p)}`],D.has(a))return`<${l}/>`;let d="";for(let c=0;c<o.childNodes.length;c++)d+=n(o.childNodes[c]);return`<${l}>${d}</${l}>`}let r="";for(let o=0;o<s.childNodes.length;o++)r+=n(s.childNodes[o]);return{text:r,styles:t}}function A(s,t){let e=(s&65535)+(t&65535);return(s>>16)+(t>>16)+(e>>16)<<16|e&65535}function Se(s,t){return s<<t|s>>>32-t}function F(s,t,e,n,r,o){return A(Se(A(A(t,s),A(n,o)),r),e)}function v(s,t,e,n,r,o,i){return F(t&e|~t&n,s,t,r,o,i)}function x(s,t,e,n,r,o,i){return F(t&n|e&~n,s,t,r,o,i)}function w(s,t,e,n,r,o,i){return F(t^e^n,s,t,r,o,i)}function y(s,t,e,n,r,o,i){return F(e^(t|~n),s,t,r,o,i)}function Te(s,t){s[t>>5]|=128<<t%32,s[(t+64>>>9<<4)+14]=t;let e=1732584193,n=-271733879,r=-1732584194,o=271733878;for(let i=0;i<s.length;i+=16){let a=e,p=n,l=r,d=o;e=v(e,n,r,o,s[i],7,-680876936),o=v(o,e,n,r,s[i+1],12,-389564586),r=v(r,o,e,n,s[i+2],17,606105819),n=v(n,r,o,e,s[i+3],22,-1044525330),e=v(e,n,r,o,s[i+4],7,-176418897),o=v(o,e,n,r,s[i+5],12,1200080426),r=v(r,o,e,n,s[i+6],17,-1473231341),n=v(n,r,o,e,s[i+7],22,-45705983),e=v(e,n,r,o,s[i+8],7,1770035416),o=v(o,e,n,r,s[i+9],12,-1958414417),r=v(r,o,e,n,s[i+10],17,-42063),n=v(n,r,o,e,s[i+11],22,-1990404162),e=v(e,n,r,o,s[i+12],7,1804603682),o=v(o,e,n,r,s[i+13],12,-40341101),r=v(r,o,e,n,s[i+14],17,-1502002290),n=v(n,r,o,e,s[i+15],22,1236535329),e=x(e,n,r,o,s[i+1],5,-165796510),o=x(o,e,n,r,s[i+6],9,-1069501632),r=x(r,o,e,n,s[i+11],14,643717713),n=x(n,r,o,e,s[i],20,-373897302),e=x(e,n,r,o,s[i+5],5,-701558691),o=x(o,e,n,r,s[i+10],9,38016083),r=x(r,o,e,n,s[i+15],14,-660478335),n=x(n,r,o,e,s[i+4],20,-405537848),e=x(e,n,r,o,s[i+9],5,568446438),o=x(o,e,n,r,s[i+14],9,-1019803690),r=x(r,o,e,n,s[i+3],14,-187363961),n=x(n,r,o,e,s[i+8],20,1163531501),e=x(e,n,r,o,s[i+13],5,-1444681467),o=x(o,e,n,r,s[i+2],9,-51403784),r=x(r,o,e,n,s[i+7],14,1735328473),n=x(n,r,o,e,s[i+12],20,-1926607734),e=w(e,n,r,o,s[i+5],4,-378558),o=w(o,e,n,r,s[i+8],11,-2022574463),r=w(r,o,e,n,s[i+11],16,1839030562),n=w(n,r,o,e,s[i+14],23,-35309556),e=w(e,n,r,o,s[i+1],4,-1530992060),o=w(o,e,n,r,s[i+4],11,1272893353),r=w(r,o,e,n,s[i+7],16,-155497632),n=w(n,r,o,e,s[i+10],23,-1094730640),e=w(e,n,r,o,s[i+13],4,681279174),o=w(o,e,n,r,s[i+0],11,-358537222),r=w(r,o,e,n,s[i+3],16,-722521979),n=w(n,r,o,e,s[i+6],23,76029189),e=w(e,n,r,o,s[i+9],4,-640364487),o=w(o,e,n,r,s[i+12],11,-421815835),r=w(r,o,e,n,s[i+15],16,530742520),n=w(n,r,o,e,s[i+2],23,-995338651),e=y(e,n,r,o,s[i],6,-198630844),o=y(o,e,n,r,s[i+7],10,1126891415),r=y(r,o,e,n,s[i+14],15,-1416354905),n=y(n,r,o,e,s[i+5],21,-57434055),e=y(e,n,r,o,s[i+12],6,1700485571),o=y(o,e,n,r,s[i+3],10,-1894986606),r=y(r,o,e,n,s[i+10],15,-1051523),n=y(n,r,o,e,s[i+1],21,-2054922799),e=y(e,n,r,o,s[i+8],6,1873313359),o=y(o,e,n,r,s[i+15],10,-30611744),r=y(r,o,e,n,s[i+6],15,-1560198380),n=y(n,r,o,e,s[i+13],21,1309151649),e=y(e,n,r,o,s[i+4],6,-145523070),o=y(o,e,n,r,s[i+11],10,-1120210379),r=y(r,o,e,n,s[i+2],15,718787259),n=y(n,r,o,e,s[i+9],21,-343485551),e=A(e,a),n=A(n,p),r=A(r,l),o=A(o,d)}return[e,n,r,o]}function Ce(s){let t="0123456789abcdef",e="";for(let n=0;n<s.length*4;n++)e+=t.charAt(s[n>>2]>>n%4*8+4&15)+t.charAt(s[n>>2]>>n%4*8&15);return e}function Le(s){if(typeof TextEncoder<"u")return new TextEncoder().encode(s);let t=[];for(let e=0;e<s.length;e++){let n=s.charCodeAt(e);if(n<128)t.push(n);else if(n<2048)t.push(192|n>>6,128|n&63);else if(n>=55296&&n<56320&&e+1<s.length){let r=s.charCodeAt(++e),o=65536+(n-55296<<10)+(r-56320);t.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63)}else t.push(224|n>>12,128|n>>6&63,128|n&63)}return new Uint8Array(t)}function Ae(s){let t=[];for(let e=0;e<s.length;e++)t[e>>2]|=s[e]<<e%4*8;return t}function Me(s){let t=Le(s);return Ce(Te(Ae(t),t.length*8))}function M(s){let t=s.trim();return"auto_"+Me(t).substring(0,12)}var _e="p,h1,h2,h3,h4,h5,h6,li,td,th,label,button,figcaption,dt,dd,summary,caption";function de(s){let t=s.closest("[data-lr-block]");if(t){let r=t.getAttribute("data-lr-block"),o=t.getAttribute("data-lr-original"),i,a=null;if(o){let p=document.createElement(t.tagName);p.innerHTML=o,i=S(p),a=S(t)}else i=S(t);return{key:r,unit:i,translatedUnit:a,element:t}}let e=s.closest(_e);if(e){let r=S(e);return{key:M(r.text),unit:r,translatedUnit:null,element:e}}let n=s.textContent?.trim();return n&&n.length>=2?{key:M(n),unit:{text:n,styles:{}},translatedUnit:null,element:s}:null}var Re=new Set(["SCRIPT","STYLE","CODE","PRE","TEXTAREA","NOSCRIPT","SVG"]),ue="p,h1,h2,h3,h4,h5,h6,li,td,th,label,button,figcaption,dt,dd,summary,caption",j=class{constructor(t,e,n,r){u(this,"overlay");u(this,"currentTarget",null);u(this,"onSelect");u(this,"rafId",null);u(this,"active",!0);u(this,"rootElement");u(this,"snapshotKeyMap");this.onSelect=e,this.rootElement=n||document.body,this.snapshotKeyMap=r||null,this.overlay=document.createElement("div"),this.overlay.className="lr-overlay",t.appendChild(this.overlay),this.handleMouseOver=this.handleMouseOver.bind(this),this.handleClick=this.handleClick.bind(this),this.handleScroll=this.handleScroll.bind(this),document.addEventListener("mouseover",this.handleMouseOver,!0),document.addEventListener("click",this.handleClick,!0),window.addEventListener("scroll",this.handleScroll,!0),window.addEventListener("resize",this.handleScroll)}destroy(){this.active=!1,document.removeEventListener("mouseover",this.handleMouseOver,!0),document.removeEventListener("click",this.handleClick,!0),window.removeEventListener("scroll",this.handleScroll,!0),window.removeEventListener("resize",this.handleScroll),this.rafId!==null&&cancelAnimationFrame(this.rafId),this.overlay.remove()}clearHighlight(){this.currentTarget=null,this.overlay.classList.remove("active")}setActive(t){this.active=t,t||this.clearHighlight()}isActive(){return this.active}handleMouseOver(t){if(!this.active)return;let e=t.target;if(!e||!e.closest||e.closest("#__lionrapid-editor")||!this.rootElement.contains(e))return;if(this.shouldSkip(e)){this.clearHighlight();return}let n=e.closest(ue)||e.closest("[data-lr-block]");if(!n){this.clearHighlight();return}n!==this.currentTarget&&(this.currentTarget=n,this.positionOverlay(n))}handleClick(t){if(!this.active)return;let e=t.target;if(!e||!e.closest||e.closest("#__lionrapid-editor")||!this.rootElement.contains(e))return;let n=e.closest(ue)||e.closest("[data-lr-block]");if(!n||this.shouldSkip(n))return;if(t.preventDefault(),t.stopPropagation(),this.snapshotKeyMap){let o=n.getAttribute("data-lr-snap-idx");if(o!==null){let i=parseInt(o,10),a=this.snapshotKeyMap.get(i);if(a){let p=S(n);this.onSelect({key:a,unit:p,translatedUnit:null,element:n});return}}return}let r=de(n);r&&this.onSelect(r)}handleScroll(){this.currentTarget&&(this.rafId!==null&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(()=>{this.currentTarget&&this.positionOverlay(this.currentTarget)}))}positionOverlay(t){let e=t.getBoundingClientRect();this.overlay.style.top=`${e.top}px`,this.overlay.style.left=`${e.left}px`,this.overlay.style.width=`${e.width}px`,this.overlay.style.height=`${e.height}px`,this.overlay.classList.add("active")}shouldSkip(t){let e=t;for(;e;){if(Re.has(e.tagName)||e.hasAttribute("data-no-translate")||e.getAttribute("translate")==="no")return!0;e=e.parentElement}return!1}};var K=class{constructor(t,e,n,r,o,i=null,a={},p=null){u(this,"el");u(this,"langBtnEl");u(this,"langMenuEl");u(this,"progressEl");u(this,"expanded",!1);u(this,"currentLocale");u(this,"onLanguageChange");u(this,"onExit");u(this,"onCaptureSnapshot");u(this,"onBrowseToggle");u(this,"browsing",!1);u(this,"browseBtnEl",null);u(this,"dragging",!1);u(this,"dragOffsetX",0);u(this,"dragOffsetY",0);this.onLanguageChange=r,this.onExit=o,this.onCaptureSnapshot=i,this.onBrowseToggle=p,this.currentLocale=n;let l=a.mode??"capture";this.el=document.createElement("div"),this.el.className="lr-fab";let d=document.createElement("button");d.className="lr-fab-btn",d.textContent="LR",d.addEventListener("click",f=>{this.dragging||(f.stopPropagation(),this.toggle())});let c=document.createElement("div");c.className="lr-fab-panel";let h=document.createElement("div");h.className="lr-lang-dropdown",this.langBtnEl=document.createElement("button"),this.langBtnEl.className="lr-lang-btn",this.langBtnEl.textContent=n.toUpperCase(),this.langBtnEl.addEventListener("click",f=>{f.stopPropagation(),this.langMenuEl.classList.toggle("open")}),h.appendChild(this.langBtnEl),this.langMenuEl=document.createElement("div"),this.langMenuEl.className="lr-lang-menu";for(let f of e){let b=document.createElement("button");b.className="lr-lang-item",f===n&&b.classList.add("active"),b.textContent=f.toUpperCase(),b.addEventListener("click",E=>{E.stopPropagation(),this.currentLocale=f,this.langBtnEl.textContent=f.toUpperCase(),this.langMenuEl.classList.remove("open"),this.langMenuEl.querySelectorAll(".lr-lang-item").forEach(B=>B.classList.remove("active")),b.classList.add("active"),this.onLanguageChange(f)}),this.langMenuEl.appendChild(b)}if(h.appendChild(this.langMenuEl),c.appendChild(h),this.onCaptureSnapshot){let f=document.createElement("button");f.className="lr-fab-snapshot",l==="recapture"?(f.textContent="Save re-capture",f.title="Save this page as a new version of the existing snapshot"):(f.textContent="Capture",f.title="Capture a redacted snapshot of this page for translators"),f.addEventListener("click",b=>{b.stopPropagation(),this.onCaptureSnapshot&&this.onCaptureSnapshot()}),c.appendChild(f)}if(this.onBrowseToggle){let f=document.createElement("button");f.className="lr-fab-browse",f.textContent="Browse",f.title="Pause editing so you can click links and navigate to another page",f.addEventListener("click",b=>{b.stopPropagation(),this.setBrowsing(!this.browsing)}),this.browseBtnEl=f,c.appendChild(f)}this.progressEl=document.createElement("span"),this.progressEl.className="lr-fab-progress",c.appendChild(this.progressEl);let m=document.createElement("button");m.className="lr-fab-exit",m.textContent="Exit",m.addEventListener("click",()=>this.onExit()),c.appendChild(m),this.el.appendChild(c),this.el.appendChild(d),t.appendChild(this.el),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),d.addEventListener("mousedown",this.handleMouseDown)}toggle(){this.expanded=!this.expanded,this.el.classList.toggle("expanded",this.expanded)}setBrowsing(t){this.browsing=t,this.browseBtnEl&&(this.browseBtnEl.textContent=t?"Editing":"Browse",this.browseBtnEl.classList.toggle("active",t),this.browseBtnEl.title=t?"Resume editing \u2014 clicks open the edit drawer again":"Pause editing so you can click links and navigate to another page"),this.el.classList.toggle("lr-fab--browsing",t),this.onBrowseToggle&&this.onBrowseToggle(t)}updateProgress(t,e){this.progressEl.textContent=`${t}/${e}`}getCurrentLocale(){return this.currentLocale}destroy(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),this.el.remove()}handleMouseDown(t){this.dragging=!1,this.dragOffsetX=t.clientX-this.el.getBoundingClientRect().left,this.dragOffsetY=t.clientY-this.el.getBoundingClientRect().top,document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}handleMouseMove(t){this.dragging=!0;let e=Math.max(0,Math.min(t.clientX-this.dragOffsetX,window.innerWidth-this.el.offsetWidth)),n=Math.max(0,Math.min(t.clientY-this.dragOffsetY,window.innerHeight-this.el.offsetHeight)),r=window.innerWidth-e-this.el.offsetWidth;this.el.style.right=`${Math.max(0,r)}px`,this.el.style.top=`${n}px`,this.el.style.left="auto",this.el.style.bottom="auto"}handleMouseUp(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),this.dragging&&setTimeout(()=>{this.dragging=!1},0)}};var I=class{serialize(t){let{text:e,styles:n}=t,r=/<(\/?)?(\d+)(\/)?>/g,o="",i=0,a;for(;(a=r.exec(e))!==null;){o+=e.slice(i,a.index);let[p,l,d]=a,c=n[d]??[],h=ce(c);if(h){let m=le(h),f=D.has(m);l?f||(o+=`</${m}>`):o+=h}else o+=p;i=a.index+p.length}return o+=e.slice(i),o}};var pe=new I;function Z(s,t,e,n,r,o,i,a){s.hasAttribute("data-lr-original")||s.setAttribute("data-lr-original",s.innerHTML);let l=window.LionRapid?.autoTranslator?Pe():null;if(l){let m=`${r}:${o}:${n}`;l.set(m,t,e)}let d=/<\/?[0-9]+\/?>/.test(t),c=a==="machine_translated",h=i?i.match(/^<(\d+)>([\s\S]*)<\/\1>$/):null;if(d){let m={text:t,styles:e};s.innerHTML=pe.serialize(m)}else if(c&&h&&e&&Object.keys(e).length>0){let m=h[1],b={text:`<${m}>${t}</${m}>`,styles:e};s.innerHTML=pe.serialize(b)}else s.textContent=t;s.setAttribute("data-lr-block",n),s.setAttribute("data-lionrapid-client","1")}function Pe(){try{let s=window.LionRapid;if(!s)return null;let t=s.autoTranslator;if(!t)return null;let e=t.core;if(!e)return null;let n=e.cache;return!n||typeof n.set!="function"?null:n}catch{return null}}var Ie={emails:!0,urls:!0,numbers:!0,phones:!0},W={email:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,url:/^(https?:\/\/|www\.)[^\s]+$/i,number:/^[\d\s.,+-]+$/,phone:/^[+\d][\d\s().-]{6,}$/},q=class{constructor(t={},e=2){u(this,"patterns");u(this,"minTextLength");this.patterns={...Ie,...t},this.minTextLength=e}shouldExclude(t){let e=t.trim();return!!(e.length<this.minTextLength||this.patterns.emails&&W.email.test(e)||this.patterns.urls&&W.url.test(e)||this.patterns.numbers&&W.number.test(e)||this.patterns.phones&&W.phone.test(e))}};var $="p,h1,h2,h3,h4,h5,h6,li,td,th,label,button,figcaption,dt,dd,summary,caption",ee="a",Ne=new Set(["SCRIPT","STYLE","CODE","PRE","TEXTAREA","NOSCRIPT","SVG"]),Oe=["data-lionrapid-translated","data-lionrapid-client","data-no-translate","data-lr-block"],_=class{constructor(t={},e=[],n=2){u(this,"excludeFilter");u(this,"excludeSelectors");this.excludeFilter=new q(t,n),this.excludeSelectors=e}extract(t,e=!1){let n=[],r=t.querySelectorAll($),o=[];t instanceof Element&&t.matches($)&&o.push(t);for(let i=0;i<r.length;i++)o.push(r[i]);for(let i=0;i<o.length;i++){let a=o[i];if(this.isInsideSkipTag(a)||!e&&this.hasSkipAttribute(a)||this.matchesExcludeSelector(a)||a.getAttribute("translate")==="no"||a.querySelector($))continue;let p=a.getAttribute("data-lr-block"),l=a.getAttribute("data-lr-original"),d;if(l){let m=document.createElement(a.tagName);m.innerHTML=l,d=S(m)}else d=S(a);let c=d.text.replace(/<\/?[0-9]+\/?>/g,"");if(this.excludeFilter.shouldExclude(c))continue;let h;if(p)h=p;else{let m=a.getAttribute("data-i18n");m?h=m.includes(":")?m:`common:${m}`:h=M(d.text)}n.push({element:a,unit:d,key:h})}return this.extractOrphanInline(t,n,e),n}extractOrphanInline(t,e,n){let r=t.querySelectorAll(ee),o=[];t instanceof Element&&t.matches(ee)&&o.push(t);for(let i=0;i<r.length;i++)o.push(r[i]);for(let i=0;i<o.length;i++){let a=o[i];if(this.isInsideSkipTag(a)||!n&&this.hasSkipAttribute(a)||this.matchesExcludeSelector(a)||a.getAttribute("translate")==="no"||a.parentElement?.closest($)||a.parentElement?.closest(ee)||a.querySelector($))continue;let p=a.getAttribute("data-lr-original"),l;if(p){let m=document.createElement(a.tagName);m.innerHTML=p,l=S(m)}else l=S(a);let d=l.text.replace(/<\/?[0-9]+\/?>/g,"");if(this.excludeFilter.shouldExclude(d))continue;let c=a.getAttribute("data-lr-block"),h;if(c)h=c;else{let m=a.getAttribute("data-i18n");m?h=m.includes(":")?m:`common:${m}`:h=M(l.text)}e.push({element:a,unit:l,key:h})}}isInsideSkipTag(t){let e=t.parentElement;for(;e;){if(Ne.has(e.tagName))return!0;e=e.parentElement}return!1}hasSkipAttribute(t){let e=t;for(;e;){for(let n of Oe)if(e.hasAttribute(n))return!0;e=e.parentElement}return!1}matchesExcludeSelector(t){for(let e of this.excludeSelectors)try{if(t.matches(e)||t.closest(e))return!0}catch{}return!1}};function V(s,t){let e;try{e=new URL(s,window.location.href)}catch{return s}if(e.origin!==window.location.origin)return s;let n=window.location.pathname.match(/^\/([a-z]{2})(\/|$)/),r=n?n[1]:t;return r===t||/^\/[a-z]{2}(\/|$)/.test(e.pathname)||(e.pathname="/"+r+e.pathname),e.href}var $e=new I,J=class{constructor(t,e,n,r,o,i,a=""){u(this,"el");u(this,"bodyEl");u(this,"statusEl");u(this,"api");u(this,"locale");u(this,"namespace");u(this,"defaultLocale");u(this,"current",null);u(this,"blockExtractor");u(this,"onBlockClick");u(this,"statusMap",new Map);u(this,"unsavedKeys",new Set);u(this,"onProgressUpdate",null);u(this,"lastFetchTime",0);u(this,"lastFlushTime",0);u(this,"userRole");u(this,"workflowInfo",null);u(this,"workflowInfoFetched",!1);this.api=e,this.locale=n,this.namespace=r,this.defaultLocale=o,this.onBlockClick=i,this.userRole=a,this.blockExtractor=new _,this.el=document.createElement("div"),this.el.className="lr-sidebar";let p=document.createElement("div");p.className="lr-sidebar-resize",this.initResize(p),this.el.appendChild(p);let l=document.createElement("div");l.className="lr-sidebar-header";let d=document.createElement("span");d.className="lr-sidebar-title",d.textContent="Edit Translation",l.appendChild(d);let c=document.createElement("button");c.className="lr-sidebar-close",c.innerHTML="×",c.addEventListener("click",()=>this.close()),l.appendChild(c),this.el.appendChild(l),this.bodyEl=document.createElement("div"),this.bodyEl.className="lr-sidebar-body",this.el.appendChild(this.bodyEl),this.statusEl=document.createElement("div"),this.statusEl.className="lr-status",this.api.setStatusCallback((h,m)=>{this.statusEl.textContent=m||h,this.statusEl.className=`lr-status ${h}`}),this.api.setFlushedCallback(async h=>{this.lastFlushTime=Date.now();let m=await this.api.fetchStatus(h,this.locale,this.namespace);for(let[f,b]of Object.entries(m))this.statusMap.set(f,b),this.unsavedKeys.delete(f);this.refreshBlocksList(),this.emitProgress()}),typeof window<"u"&&(window.__lr_dump_keys=()=>{let m=this.blockExtractor.extract(document.body,!0).map((f,b)=>{let E=this.statusMap.get(f.key);return{i:b,key:f.key,text:f.unit.text,stylesJson:JSON.stringify(f.unit.styles),statusText:E?.text??"",isReady:!!E?.isReady,hasTranslation:!!E?.text}});return console.table(m),m},window.__lr_editor_edit=(h,m)=>{let b=this.blockExtractor.extract(document.body,!0).find(E=>E.key===h);if(!b)throw new Error(`[__lr_editor_edit] no block on page with key ${h}`);this.unsavedKeys.add(h),this.api.queueSave({key:h,locale:this.locale,namespace:this.namespace,text:m,styles:b.unit.styles})},window.__lr_editor_flush=()=>this.api.flush()),t.appendChild(this.el)}open(t){this.current=t,this.el.classList.add("open"),this.renderContent(t)}close(){this.current=null,this.el.classList.remove("open")}isOpen(){return this.el.classList.contains("open")}updateLocale(t){this.locale=t,this.statusMap.clear(),this.unsavedKeys.clear()}setProgressCallback(t){this.onProgressUpdate=t}async hydrateStatus(){let t=this.blockExtractor.extract(document.body,!0),e=t.map(i=>i.key);if(e.length===0)return;let n=await this.api.fetchStatus(e,this.locale,this.namespace);for(let[i,a]of Object.entries(n))this.statusMap.set(i,a);let r=[],o=0;for(let i of t){let a=this.statusMap.get(i.key);if(a&&a.text&&!a.isReady)Z(i.element,a.text,i.unit.styles,i.key,this.locale,this.namespace,i.unit.text,a.rowState);else if(!a||!a.text){o++;let p=i.element.getAttribute("data-lr-block");if(p&&p.startsWith("auto_")){let l=M(i.unit.text);l!==p&&r.push({stamped:p,recomputed:l,text:i.unit.text.slice(0,80)})}}}r.length>0?console.warn(`[LionRapid Editor] ${r.length} block(s) where the client-side auto_ key does NOT match the server's data-lr-block stamp \u2014 JS and server key generation are diverging for these inputs. Sample (first 5):`,r.slice(0,5)):o>0&&console.debug(`[LionRapid Editor] ${o} block(s) untranslated (no server text yet) \u2014 normal for in-progress pages.`),this.emitProgress()}getTranslatedCount(){let t=0;for(let e of this.statusMap.values())e&&e.rowState!=="empty"&&t++;return t}getTotalCount(){return this.blockExtractor.extract(document.body,!0).length}emitProgress(){this.onProgressUpdate&&this.onProgressUpdate(this.getTranslatedCount(),this.getTotalCount())}destroy(){this.el.remove()}async renderContent(t){let{key:e,unit:n,element:r}=t;if(this.bodyEl.innerHTML="",this.lastFlushTime>this.lastFetchTime||this.lastFetchTime===0){let h=this.blockExtractor.extract(document.body,!0).map(f=>f.key);h.includes(e)||h.push(e);let m=await this.api.fetchStatus(h,this.locale,this.namespace);for(let[f,b]of Object.entries(m))this.statusMap.set(f,b);this.lastFetchTime=Date.now()}else{let c=await this.api.fetchStatus([e],this.locale,this.namespace);c[e]!==void 0&&this.statusMap.set(e,c[e])}let i=this.statusMap.get(e)??null;this.addField("Key",()=>{let c=document.createElement("div");return c.className="lr-field-key",c.textContent=e,c}),this.addField("Original",()=>{let c=document.createElement("div");return c.className="lr-field-original",c.innerHTML=this.renderTextWithTags(n.text),c}),this.renderLinkNav(r);let a=this.locale===this.defaultLocale,p=a||i?.isLocked||i?.isReady||!1,l=document.createElement("textarea");this.addField("Translation",()=>(l.className="lr-textarea",l.value=i?.text||t.translatedUnit?.text||"",l.placeholder=n.text,p&&(l.readOnly=!0,l.classList.add("lr-textarea-locked"),l.title=a?"Source language \u2014 switch to a target language to edit":i?.isReady?"Approved for delivery \u2014 read only":"Locked \u2014 read only"),l)),this.bodyEl.appendChild(this.statusEl);let d=document.createElement("div");this.addField("Preview",()=>(d.className="lr-preview",l.value&&(d.innerHTML=this.renderPreview(l.value,n.styles)),d)),a||this.renderWorkflowActions(e,i),p||l.addEventListener("input",()=>{let c=l.value;d.innerHTML=this.renderPreview(c,n.styles),c&&Z(r,c,n.styles,e,this.locale,this.namespace,n.text,"edited"),this.unsavedKeys.add(e),this.api.queueSave({key:e,locale:this.locale,namespace:this.namespace,text:c,styles:n.styles})}),this.renderBlocksList(),p||setTimeout(()=>l.focus(),100)}renderWorkflowActions(t,e){let n=this.userRole==="project_manager"||this.userRole==="admin",r=!!e?.isReady,o=!!e?.isLocked,i=!!e?.isConfirmed,a=e?.canEdit!==!1,p=`${this.locale}:${this.namespace}:${t}`,l=document.createElement("div");l.className="lr-workflow-actions";let d=document.createElement("div");d.className="lr-wf-strip-host",l.appendChild(d),this.renderWorkflowStrip(d,e);let c=(h,m,f="secondary")=>{let b=document.createElement("button");b.className=`lr-wf-btn lr-wf-${f}`,b.textContent=h,b.addEventListener("click",async()=>{b.disabled=!0;let E=await this.api.transitionTarget(p,m);b.disabled=!1,E&&await this.refreshStatusForKey(t)}),l.appendChild(b)};if(a&&!o&&!r&&(i?(this.workflowInfo?.workflowMode==="per_file"||c("Advance","advance","primary"),c("Unconfirm","unconfirm")):(c("Confirm","confirm","primary"),c("Reject","reject","danger"))),n&&(r?c("Unmark Ready","unmark-ready","danger"):c("Mark Ready","mark-ready","primary")),!a&&!n&&!r&&!o){let h=document.createElement("span");h.className="lr-wf-note",h.textContent=typeof e?.stageIndex=="number"&&e.stageIndex>0?`Row already advanced (stage ${e.stageIndex+1}) \u2014 out of your scope.`:"You are not assigned to this row at the current stage.",l.appendChild(h)}l.children.length>0&&this.bodyEl.appendChild(l)}renderWorkflowStrip(t,e){if(this.workflowInfo){let n=this.buildWorkflowStripNode(this.workflowInfo,e);t.replaceChildren(...n?[n]:[]);return}this.workflowInfoFetched||(this.workflowInfoFetched=!0,this.api.fetchWorkflowInfo().then(n=>{if(this.workflowInfo=n,!this.current)return;let r=this.statusMap.get(this.current.key)??e??null,o=n?this.buildWorkflowStripNode(n,r):null;t.isConnected&&t.replaceChildren(...o?[o]:[])}))}buildWorkflowStripNode(t,e){if(!t.stages||t.stages.length===0)return null;let n=null;t.isPmAdmin?n=typeof e?.stageIndex=="number"?e.stageIndex:null:t.userAssignedStages.length>0&&(n=t.userAssignedStages[0]);let r=document.createElement("div");r.className="lr-wf-strip";let o=document.createElement("div");o.className="lr-wf-strip-stages",t.stages.forEach((a,p)=>{let l=document.createElement("span");if(l.className="lr-wf-strip-stage",n!==null&&a.index===n?l.classList.add("is-active"):l.classList.add("is-muted"),l.textContent=a.name,o.appendChild(l),p<t.stages.length-1){let d=document.createElement("span");d.className="lr-wf-strip-sep",d.textContent="\u2192",o.appendChild(d)}}),r.appendChild(o);let i=document.createElement("div");if(i.className="lr-wf-strip-caption",n!==null){let p=t.stages.find(d=>d.index===n)?.name??`Stage ${n+1}`,l=t.isPmAdmin?"Row currently at":"You are here";i.textContent=`${l}: stage ${n+1} of ${t.stages.length} \u2014 ${p}`}else!t.isPmAdmin&&t.userAssignedStages.length===0?i.textContent="You have no stage assignment on this project.":i.textContent=`${t.stages.length} stages`;return r.appendChild(i),r}async refreshStatusForKey(t){let e=await this.api.fetchStatus([t],this.locale,this.namespace);for(let[n,r]of Object.entries(e))this.statusMap.set(n,r);this.current&&this.renderContent(this.current),this.emitProgress()}renderLinkNav(t){let e=t.matches?.("a[href]")?t:t.querySelector?.("a[href]");if(!e)return;let n;try{n=new URL(e.href,window.location.href)}catch{return}n.origin===window.location.origin&&(n.pathname===window.location.pathname&&!n.hash||this.addField("Linked page",()=>{let r=document.createElement("button");return r.className="lr-link-nav",r.textContent="Open linked page \u2192",r.title=n.pathname+n.search,r.addEventListener("click",()=>{window.location.href=V(n.href,this.defaultLocale)}),r}))}addField(t,e){let n=document.createElement("div");n.className="lr-field";let r=document.createElement("span");r.className="lr-field-label",r.textContent=t,n.appendChild(r),n.appendChild(e()),this.bodyEl.appendChild(n)}getDotClass(t){if(this.unsavedKeys.has(t))return"unsaved";let e=this.statusMap.get(t);return e?e.isLocked?"locked":e.canEdit===!1&&typeof e.stageIndex=="number"&&e.stageIndex>0?"readonly":e.isReady?"ready":e.isConfirmed?"confirmed":e.rowState==="edited"?"edited":e.rowState==="machine_translated"?"mt":"missing":"missing"}renderTextWithTags(t){return t.replace(/<(\/?)?(\d+)(\/)?>/g,e=>`<span class="lr-field-tag">${e}</span>`)}renderPreview(t,e){if(!t)return"";if(Object.keys(e).length>0){let n={text:t,styles:e};return $e.serialize(n)}return t}initResize(t){let e=0,n=0,r=i=>{let a=n+(e-i.clientX),p=Math.max(280,Math.min(600,a));this.el.style.width=`${p}px`},o=()=>{t.classList.remove("active"),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o)};t.addEventListener("mousedown",i=>{i.preventDefault(),e=i.clientX,n=this.el.offsetWidth,t.classList.add("active"),document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)})}refreshBlocksList(){let t=this.bodyEl.querySelector(".lr-blocks-section");t&&t.remove(),this.renderBlocksList()}renderBlocksList(){let t=document.createElement("div");t.className="lr-blocks-section";let e=this.blockExtractor.extract(document.body,!0),n=this.getTranslatedCount(),r=document.createElement("div");r.className="lr-blocks-title",r.textContent=`Blocks on this page (${n}/${e.length} translated)`,t.appendChild(r);for(let o of e){let i=document.createElement("div");i.className="lr-block-item",this.current&&o.element===this.current.element&&i.classList.add("active");let p=document.createElement("span");p.className="lr-status-dot",p.classList.add(this.getDotClass(o.key)),i.appendChild(p);let l=document.createElement("div");l.className="lr-block-text";let d=o.unit.text.replace(/<\/?[0-9]+\/?>/g,""),c=document.createElement("div");c.className="lr-block-source",c.textContent=d.length>60?d.slice(0,60)+"...":d,c.title=d,l.appendChild(c);let h=this.statusMap.get(o.key);if(h&&h.text){let m=document.createElement("div");m.className="lr-block-preview";let f=h.text.replace(/<\/?[0-9]+\/?>/g,"");m.textContent=f.length>50?f.slice(0,50)+"...":f,l.appendChild(m)}i.appendChild(l),i.addEventListener("click",()=>{o.element.scrollIntoView({behavior:"smooth",block:"center"}),this.onBlockClick({key:o.key,unit:o.unit,translatedUnit:null,element:o.element})}),t.appendChild(i)}this.bodyEl.appendChild(t)}};var X=class{constructor(t,e,n){u(this,"queue",[]);u(this,"apiBase");u(this,"sessionToken");u(this,"projectId");u(this,"flushInterval",null);u(this,"renewalInterval",null);u(this,"onStatus",()=>{});u(this,"onFlushed",()=>{});u(this,"onSessionExpired",null);u(this,"workflowInfoPromise",null);u(this,"statusAbort",null);u(this,"handleVisibility",()=>{document.visibilityState==="hidden"?this.flush():document.visibilityState==="visible"&&this.maybeRenewSession()});this.apiBase=t.replace(/\/$/,""),this.sessionToken=e,this.projectId=n}setStatusCallback(t){this.onStatus=t}setFlushedCallback(t){this.onFlushed=t}setSessionExpiredCallback(t){this.onSessionExpired=t}startAutoFlush(){this.flushInterval=setInterval(()=>this.flush(),3e4),document.addEventListener("visibilitychange",this.handleVisibility),this.renewalInterval=setInterval(()=>this.maybeRenewSession(),6e4)}async stopAndFlush(){this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.renewalInterval&&(clearInterval(this.renewalInterval),this.renewalInterval=null),document.removeEventListener("visibilitychange",this.handleVisibility),await this.flush()}queueSave(t){let e=this.queue.findIndex(n=>n.key===t.key&&n.locale===t.locale&&n.namespace===t.namespace);e>=0?this.queue[e]=t:this.queue.push(t),this.onStatus("unsaved",`${this.queue.length} unsaved`),this.queue.length>50&&this.flush()}async flush(){if(this.queue.length===0)return;let t=[...this.queue];this.onStatus("saving");try{let e=await this.authFetch(`${this.apiBase}/api/integrations/targets/batch`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({translations:t.map(r=>({key:`${r.locale}:${r.namespace}:${r.key}`,value:{text:r.text,styles:r.styles}}))})});if(e.status===401){this.handleSessionExpired();return}if(!e.ok)throw new Error(`HTTP ${e.status}`);let n=t.map(r=>r.key);for(let r of t){let o=this.queue.indexOf(r);o>=0&&this.queue.splice(o,1)}this.onFlushed(n),this.queue.length===0?this.onStatus("saved","All changes saved"):this.onStatus("unsaved",`${this.queue.length} unsaved`)}catch(e){this.onStatus("error",`Save failed: ${e.message}`)}}async fetchStatus(t,e,n){if(t.length===0)return{};this.statusAbort&&this.statusAbort.abort(),this.statusAbort=new AbortController;let r=t.slice(0,200),o=new URLSearchParams({locale:e,namespace:n,keys:r.join(",")});try{let i=await this.authFetch(`${this.apiBase}/api/integrations/targets/status?${o}`,{signal:this.statusAbort.signal});return i.status===401?(this.handleSessionExpired(),{}):i.ok?(await i.json()).translations:{}}catch(i){return i.name==="AbortError"?{}:{}}}get pendingCount(){return this.queue.length}async fetchWorkflowInfo(){return this.workflowInfoPromise?this.workflowInfoPromise:(this.workflowInfoPromise=(async()=>{try{let t=await this.authFetch(`${this.apiBase}/api/integrations/editor/workflow`);if(t.status===401)return this.handleSessionExpired(),null;if(!t.ok)return null;let e=await t.json();return{stages:Array.isArray(e.stages)?e.stages:[],userAssignedStages:Array.isArray(e.user_assigned_stages)?e.user_assigned_stages:[],isPmAdmin:!!e.is_pm_admin,workflowMode:e.workflow_mode==="per_file"?"per_file":"per_row"}}catch{return null}})(),this.workflowInfoPromise)}async maybeRenewSession(){let t=this.getSessionExp();!t||t*1e3-Date.now()>3e5||await this.renewSession()}async tryRenew(){let t=this.sessionToken;return await this.renewSession(),this.sessionToken!==t}async renewSession(){try{let t=await fetch(`${this.apiBase}/api/editor/renew`,{method:"POST",headers:{Authorization:`Bearer ${this.sessionToken}`}});if(t.status===401){this.handleSessionExpired();return}if(!t.ok)return;let e=await t.json();this.sessionToken=e.session_token;try{let r=(this.sessionToken.startsWith("es_")?this.sessionToken.slice(3):this.sessionToken).split(".");if(r.length===3){let o=JSON.parse(atob(r[1]));sessionStorage.setItem("__lr_editor_session",JSON.stringify({token:this.sessionToken,exp:o.exp||0})),document.cookie="__lr_editor_active=1; path=/; SameSite=Lax"}}catch{}}catch{}}getSessionExp(){try{let e=(this.sessionToken.startsWith("es_")?this.sessionToken.slice(3):this.sessionToken).split(".");return e.length!==3?null:JSON.parse(atob(e[1])).exp||null}catch{return null}}async authFetch(t,e={}){let n=()=>{let o=new Headers(e.headers);return o.set("Authorization",`Bearer ${this.sessionToken}`),o},r=await fetch(t,{...e,headers:n()});return r.status===401&&await this.tryRenew()&&(r=await fetch(t,{...e,headers:n()})),r}handleSessionExpired(){document.cookie="__lr_editor_active=; path=/; SameSite=Lax; Max-Age=0",this.onStatus("error","Session expired. Please reopen the editor from the dashboard."),this.onSessionExpired&&this.onSessionExpired()}async createSnapshot(t){try{let e=await fetch(`${this.apiBase}/api/editor/snapshots`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.sessionToken}`},body:JSON.stringify({pageUrl:t.pageUrl,title:t.title,viewport:t.viewport,textEntries:t.textEntries,html:t.html})});if(e.status===401)return this.handleSessionExpired(),null;if(!e.ok)throw new Error(`HTTP ${e.status}`);let n=await e.json();return{snapshotUuid:n.snapshot_uuid||n.snapshotUuid}}catch(e){return this.onStatus("error",`Snapshot failed: ${e.message}`),null}}async recaptureSnapshot(t,e){try{let n=await fetch(`${this.apiBase}/api/editor/snapshots/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.sessionToken}`},body:JSON.stringify({pageUrl:e.pageUrl,title:e.title,viewport:e.viewport,textEntries:e.textEntries,html:e.html})});if(n.status===401)return this.handleSessionExpired(),null;if(!n.ok)throw new Error(`HTTP ${n.status}`);let r=await n.json();return{snapshotUuid:r.snapshot_uuid||r.snapshotUuid,version:r.version||1}}catch(n){return this.onStatus("error",`Re-capture failed: ${n.message}`),null}}async getSnapshot(t){try{let e=await fetch(`${this.apiBase}/api/editor/snapshots/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${this.sessionToken}`}});return e.status===401?(this.handleSessionExpired(),null):e.ok?await e.json():null}catch{return null}}async listSnapshots(){try{let t=await fetch(`${this.apiBase}/api/editor/snapshots`,{headers:{Authorization:`Bearer ${this.sessionToken}`}});return t.status===401?(this.handleSessionExpired(),[]):t.ok?(await t.json()).snapshots||[]:[]}catch{return[]}}async deleteSnapshot(t){try{let e=await fetch(`${this.apiBase}/api/editor/snapshots/${encodeURIComponent(t)}`,{method:"DELETE",headers:{Authorization:`Bearer ${this.sessionToken}`}});return e.status===401?(this.handleSessionExpired(),!1):e.ok}catch{return!1}}async transitionTarget(t,e){try{let n=await this.authFetch(`${this.apiBase}/api/integrations/targets/${encodeURIComponent(t)}/${e}`,{method:"POST"});return n.status===401?(this.handleSessionExpired(),null):n.ok?await n.json():(this.onStatus("error",`${e} failed: HTTP ${n.status}`),null)}catch(n){return this.onStatus("error",`${e} failed: ${n.message}`),null}}};var N="[REDACTED]",Be=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}/gi,Ue=/(?:\+\d{1,3}[\s.-]?)?(?:\(\d{3}\)|\d{3})[\s.-]\d{3}[\s.-]\d{4}/g,ze=/\b\d{3}[\s-]\d{2}[\s-]\d{4}\b/g,He=/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g,De=/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi,Fe=/\b\d(?:[ -]?\d){12,18}\b/g;function je(s){if(s.length<13||s.length>19)return!1;let t=0,e=!1;for(let n=s.length-1;n>=0;n--){let r=s.charCodeAt(n)-48;if(r<0||r>9)return!1;e&&(r*=2,r>9&&(r-=9)),t+=r,e=!e}return t%10===0}function Ke(s){let t=s.split(".");if(t.length!==4)return!1;for(let e of t){let n=Number(e);if(!Number.isInteger(n)||n<0||n>255)return!1}return!0}function We(s){if(!s)return s;let t=s;return t=t.replace(De,N),t=t.replace(Be,N),t=t.replace(Ue,N),t=t.replace(ze,N),t=t.replace(He,e=>Ke(e)?N:e),t=t.replace(Fe,e=>{let n=e.replace(/[\s-]/g,"");return je(n)?N:e}),t}var qe=new Set(["CODE","PRE","STYLE","TEXTAREA"]);function he(s){let t=document.createTreeWalker(s,NodeFilter.SHOW_TEXT),e=[],n=t.nextNode();for(;n;){if(!Ve(n)){let r=n.nodeValue||"",o=We(r);o!==r&&e.push({node:n,value:o})}n=t.nextNode()}for(let{node:r,value:o}of e)r.nodeValue=o}function Ve(s){let t=s.parentNode;for(;t&&t.nodeType===Node.ELEMENT_NODE;){let e=t;if(qe.has(e.tagName)||e.hasAttribute("data-no-redact"))return!0;t=e.parentNode}return!1}var fe="[REDACTED]";function me(){let s=document.documentElement.cloneNode(!0),t=et(s);return Je(s),Xe(s),Ye(s),Ge(s),Qe(s),Ze(s),{html:`<!DOCTYPE html>
|
|
588
|
+
`+s.outerHTML,textEntries:t,pageUrl:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio||1}}}function Je(s){let t=["script","noscript","iframe","embed","object","#__lionrapid-editor",'link[rel="prefetch"]','link[rel="preload"]','link[rel="modulepreload"]'];for(let e of t){let n=s.querySelectorAll(e);for(let r=0;r<n.length;r++)n[r].remove()}}function Xe(s){let t=s.querySelectorAll("input, textarea, select");for(let e=0;e<t.length;e++){let n=t[e];if("value"in n&&(n.value=""),n.hasAttribute("value")&&n.setAttribute("value",""),n.tagName==="TEXTAREA"&&(n.textContent=""),n.tagName==="SELECT"){let o=n.querySelectorAll("option");for(let i=0;i<o.length;i++)o[i].selected=!1,o[i].removeAttribute("selected")}let r=Array.from(n.attributes);for(let o of r)(o.name.startsWith("data-value")||o.name==="data-initial")&&n.removeAttribute(o.name)}}function Ye(s){let t=s.querySelectorAll("[data-pii], [data-sensitive]");for(let e=0;e<t.length;e++){let n=t[e];n.textContent=fe;let r=Array.from(n.attributes);for(let o of r)o.name!=="class"&&o.name!=="id"&&o.name!=="style"&&n.removeAttribute(o.name)}}function Ge(s){let t=document.createTreeWalker(s,NodeFilter.SHOW_ELEMENT),e=t.nextNode();for(;e;){let n=Array.from(e.attributes);for(let r of n)r.name.toLowerCase().startsWith("on")&&e.removeAttribute(r.name);e=t.nextNode()}}function Qe(s){he(s)}function Ze(s){let t=s.querySelectorAll('meta[name="csrf-token"], meta[name="csp-nonce"], meta[name="csrf-param"], meta[http-equiv="set-cookie"]');for(let r=0;r<t.length;r++)t[r].remove();let e=["token","auth","access_token","session","sid","key","api_key","apikey"],n=s.querySelectorAll("link[href], a[href], img[src]");for(let r=0;r<n.length;r++){let o=n[r],i=o.tagName==="IMG"?"src":"href",a=o.getAttribute(i);if(a)try{let p=new URL(a,window.location.href),l=!1;for(let d of e)p.searchParams.has(d)&&(p.searchParams.set(d,fe),l=!0);l&&o.setAttribute(i,p.toString())}catch{}}}function et(s){return new _({emails:!0,urls:!0,numbers:!0,phones:!0},[],2).extract(s).map((n,r)=>(n.element.setAttribute("data-lr-snap-idx",String(r)),{key:n.key,tagName:n.element.tagName,blockIndex:r}))}async function ge(s,t){let e=await t.getSnapshot(s);if(!e)return null;let r=new DOMParser().parseFromString(e.html,"text/html"),o=r.head.querySelectorAll('link[rel="stylesheet"], style');for(let d=0;d<o.length;d++){let c=o[d].cloneNode(!0);c.setAttribute("data-lr-snapshot-style",""),document.head.appendChild(c)}e.title&&(document.title=`[Snapshot] ${e.title}`);let i=document.getElementById("__lionrapid-editor");for(;document.body.firstChild;)if(document.body.firstChild===i){let d=document.body.firstChild.nextSibling;if(!d)break;document.body.removeChild(d)}else document.body.removeChild(document.body.firstChild);let a=document.createElement("div");a.id="__lr_snapshot_root",a.setAttribute("data-lr-snapshot-uuid",s),a.innerHTML=r.body.innerHTML,i&&i.parentNode===document.body?document.body.insertBefore(a,i):document.body.appendChild(a);let p=new Map,l=e.textEntries||[];for(let d of l)p.set(d.blockIndex,d.key);return{root:a,pageUrl:e.pageUrl,title:e.title,keyMap:p}}typeof window<"u"&&(window.__lr_dump_keys=()=>{let e=new _().extract(document.body,!0).map((n,r)=>({i:r,key:n.key,text:n.unit.text,stylesJson:JSON.stringify(n.unit.styles)}));return console.table(e),e});var Y="__lr_editor_session",be="__lr_editor_active";function ve(){document.cookie=`${be}=1; path=/; SameSite=Lax`}function xe(){document.cookie=`${be}=; path=/; SameSite=Lax; Max-Age=0`}function we(){try{let s=sessionStorage.getItem(Y);if(!s)return null;let t=JSON.parse(s);return t.exp*1e3<Date.now()+3e4?(sessionStorage.removeItem(Y),xe(),null):(ve(),t.token)}catch{return null}}function tt(s){try{let e=(s.startsWith("es_")?s.slice(3):s).split(".");if(e.length!==3)return;let n=JSON.parse(atob(e[1])),r={token:s,exp:n.exp||0};sessionStorage.setItem(Y,JSON.stringify(r)),ve()}catch{}}function nt(){sessionStorage.removeItem(Y),xe()}function rt(s){try{let e=(s.startsWith("es_")?s.slice(3):s).split(".");if(e.length!==3)return"";let n=JSON.parse(atob(e[1]));return typeof n.role=="string"?n.role:""}catch{return""}}function L(s){let t=document.createElement("div");t.setAttribute("data-no-translate",""),Object.assign(t.style,{position:"fixed",bottom:"24px",right:"24px",zIndex:"2147483647",background:"#1a1a2e",color:"#fff",padding:"16px 20px",borderRadius:"8px",fontFamily:"system-ui, sans-serif",fontSize:"14px",maxWidth:"360px",boxShadow:"0 4px 20px rgba(0,0,0,0.3)"}),t.textContent=s;let e=document.createElement("button");Object.assign(e.style,{position:"absolute",top:"4px",right:"8px",background:"none",border:"none",color:"#888",cursor:"pointer",fontSize:"16px"}),e.textContent="\xD7",e.addEventListener("click",()=>t.remove()),t.appendChild(e),document.body.appendChild(t),setTimeout(()=>t.remove(),8e3)}function st(){let s=document.querySelector("script[data-grant]")||document.querySelector("script[data-lr-editor]");if(!s)return;let t=s.dataset.grant||"",e=we()!==null;if(!t&&!e)return;let n=s.dataset.locale||"",r=s.dataset.api||"https://api.lionrapid.com",o=s.dataset.project||"",i=0,a=100,p=setInterval(()=>{i++;let l=window.LionRapid;l?(clearInterval(p),ot(l,t,n,r,o)):i>=a&&(clearInterval(p),console.warn("[LionRapid Editor] Timed out waiting for window.LionRapid"))},100)}async function ot(s,t,e,n,r){let o=window.__lionrapidConfig,i=o?.languages||[e],a=o?.namespace||"default",p=o?.defaultLocale||"en",l=e||s.getCurrentLocale(),d=n.replace(/\/$/,""),c=we();if(!c&&t)try{let g=await fetch(`${d}/api/editor/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant:t,domain:window.location.host})});if(!g.ok){console.error("[LionRapid Editor] Grant exchange failed:",g.status),L("Editor session expired. Please reopen the editor from the dashboard.");return}c=(await g.json()).session_token,c&&tt(c)}catch(g){console.error("[LionRapid Editor] Grant exchange error:",g),L("Could not connect to LionRapid. Please check your connection and try again.");return}if(!c){console.error("[LionRapid Editor] No valid session. Please reopen the editor from the dashboard."),L("Editor session expired. Please reopen the editor from the dashboard.");return}let h=rt(c),m=h==="project_manager"||h==="admin",f=document.createElement("div");f.id="__lionrapid-editor",f.setAttribute("data-no-translate",""),document.body.appendChild(f);let b=f.attachShadow({mode:"closed"}),E=document.createElement("style");E.textContent=ie,b.appendChild(E);let B=document.querySelector("[data-lionrapid-switcher]");B&&(B.style.display="none");let P=new X(d,c,r);P.startAutoFlush();let te=new URL(window.location.href),U=te.searchParams.get("__lr_snapshot"),G=te.searchParams.get("__lr_recapture"),ne,re;if(U){let g=await ge(U,P);if(!g){L("Snapshot not found or expired. Please check the dashboard.");return}ne=g.root,re=g.keyMap}let se=g=>{T.open(g),z.clearHighlight()},T=new J(b,P,l,a,p,se,h),z=new j(b,se,ne,re),Q=new K(b,i,l,async g=>{if(document.querySelector('script[data-mode="dynamic-only"]')!==null){let C=new URL(window.location.href),O=C.pathname.replace(/^\/[a-z]{2}(\/|$)/,"/"),oe=g===p?"":`/${g}`;C.pathname=oe+(O==="/"&&oe?"":O),window.location.href=C.toString();return}T.updateLocale(g),T.close(),z.clearHighlight(),await s.changeLanguage(g),await T.hydrateStatus()},async()=>{await P.stopAndFlush(),z.destroy(),Q.destroy(),T.destroy(),f.remove(),nt()},U||!m?null:async()=>{try{let g=me();if(G){let k=await P.recaptureSnapshot(G,g);L(k?`Re-captured as v${k.version} (${g.textEntries.length} blocks). You can close this tab.`:"Re-capture failed. Please try again.")}else{let k=await P.createSnapshot(g);L(k?`Snapshot captured (${g.textEntries.length} blocks). Open it from the Snapshots tab in the dashboard.`:"Snapshot upload failed. Please try again.")}}catch(g){console.error("[LionRapid Editor] Snapshot capture error:",g),L("Snapshot capture failed. See console for details.")}},G?{mode:"recapture"}:void 0,U?null:g=>{z.setActive(!g),g&&T.close()});T.setProgressCallback((g,k)=>{Q.updateProgress(g,k)}),document.addEventListener("click",g=>{if(g.defaultPrevented||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||g.button!==0)return;let k=g.target;if(!k?.closest||k.closest("#__lionrapid-editor"))return;let C=k.closest("a[href]");if(!C||C.target&&C.target!=="_self"||C.hasAttribute("download"))return;let O=V(C.href,p);O!==C.href&&(g.preventDefault(),window.location.href=O)}),T.hydrateStatus().then(()=>{Q.updateProgress(T.getTranslatedCount(),T.getTotalCount())});let R=new URL(window.location.href),H=!1;R.searchParams.has("__lr_editor")&&(R.searchParams.delete("__lr_editor"),H=!0),R.searchParams.has("__lr_snapshot")&&(R.searchParams.delete("__lr_snapshot"),H=!0),R.searchParams.has("__lr_recapture")&&(R.searchParams.delete("__lr_recapture"),H=!0),H&&history.replaceState(null,"",R.toString())}st();})();
|
|
552
589
|
//# sourceMappingURL=lionrapid.editor.min.js.map
|