browser_development-8.x-1.x-dev/assets/dist/assets/index-DAE8KTve.js
assets/dist/assets/index-DAE8KTve.js
import{j as e,r as _,R as L}from"./vendor_react-B5CIjaDA.js";import{R as E}from"./vendor_react-dom-Cg6Xop6J.js";import{S as C}from"./vendor_rc-slider-mP6mgGEM.js";import{$ as u}from"./vendor_jquery-D7INfxrl.js";import{e as I,s as k}from"./vendor_state-pool-imnDRRKN.js";import{a as j}from"./vendor_axios-upsvKRUO.js";import"./vendor_classnames-ELZfJkp_.js";import"./vendor_scheduler-BF-YhwgH.js";import"./vendor_@babel-Dxhdoqxo.js";import"./vendor_rc-util-DiG1V1Yx.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))l(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const c of s.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&l(c)}).observe(document,{childList:!0,subtree:!0});function i(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function l(o){if(o.ep)return;o.ep=!0;const s=i(o);fetch(o.href,s)}})();const p=I.createStore();function T(n,t){let i;return(...l)=>{clearTimeout(i),i=setTimeout(()=>{n.apply(this,l)},t)}}p.persist({saveState:function(n,t,i){const l=()=>{try{const o=JSON.stringify(t);window.localStorage.setItem(n,o)}catch{}};i?l():T(l,1e3)()},loadState:function(n,t){try{const i=window.localStorage.getItem(n);return i===null?t:JSON.parse(i)}catch{return}},removeState:function(n){window.localStorage.removeItem(n)},clear:function(){window.localStorage.clear()}});const A=()=>{const n=()=>{const t=document.querySelector("#pnc-second-frame-id");t.classList.contains("display-none")?t.classList.remove("display-none"):t.classList.add("display-none")};return e.jsx("button",{onClick:n,className:"split-screen-btn",children:"Split Screen"})},O=()=>{const n=()=>{const t=document.querySelector("#pnc-pop-up-wrapper-id");t.classList.contains("display-none")?t.classList.remove("display-none"):t.classList.add("display-none")};return e.jsx("button",{onClick:n,className:"help-btn",children:"Help"})},V=()=>{const n=()=>{u(".editor").slideToggle("fast")};return e.jsx("button",{onClick:n,className:"editors-displays-btn",children:"Editors"})},S=async(n,t,i)=>{const l=n.map((o,s)=>{const c=`ace-editor-${s}`,d=window.ace.edit(c);if(d){const m=d.getValue();return{...o,code:m}}else return console.error(`Editor with ID ${c} not found.`),o});t(l);try{const o=await j.post(i,{compiled:l});console.log("compileScss ==>",o.data)}catch(o){console.error("Error compiling SCSS:",o)}},D=()=>{const n=p.useState("global_vars"),[t,i]=p.useState("global_editor_array"),l=()=>{var s;const o=(s=n[0])==null?void 0:s.compile_api_url;o?S(t,i,o):console.error("Compile API URL is not defined.")};return e.jsx("button",{onClick:l,className:"compile-btn",children:"Save"})},b=(n,t)=>{console.log(n);const i=o=>{let s=(o.match(/\{/g)||[]).length,c=(o.match(/\}/g)||[]).length;return s===c};(async()=>{let s=n.map((c,d)=>{const m=`ace-editor-${d}`,v=window.ace&&window.ace.edit(m);if(v){const g=v.getValue();return{...c,code:g}}else return console.error(`Editor with ID ${m} not found.`),{...c,code:""}}).map(c=>c.code||"").join("");if(i(s))try{console.log(s);const c=await j.post(t,{live:s});console.log("buildScss compiling ==>",c.data),c.data.live_response!==void 0&&u(document).ready(function(){u("iframe#pnc-iframe").contents().find("#live-purencool-editor").empty().append(c.data.live_response)})}catch(c){console.error("Error compiling SCSS:",c)}})()},P=()=>{const n=p.useState("global_vars"),[t,i]=p.useState("global_editor_array"),l=()=>{var s;const o=(s=n[0])==null?void 0:s.scss_api_url;o?b(t,o):console.error("Compile API URL is not defined.")};return e.jsx("button",{onClick:l,className:"live-btn",children:"Preview"})},B=()=>{const n=()=>{const t=document.querySelector("#editor-settings-wrapper-id");t.classList.contains("display-none")?t.classList.remove("display-none"):t.classList.add("display-none")};return e.jsx("button",{onClick:n,className:"editor-settings-btn",children:"Settings"})},U=()=>e.jsxs("div",{className:"pnc-navigation",children:[e.jsx(D,{}),e.jsx(P,{}),e.jsx(V,{}),e.jsx(A,{}),e.jsx(B,{}),e.jsx(O,{})]}),R=n=>{var d,m,v;let t=n.ideNumber;const[i,l]=p.useState("global_editor_array"),o=p.useState("global_vars");_.useEffect(()=>{i[t]&&i[t].configuration&&i[t].configuration.css_files===void 0&&s("default",t)},[t,i]);const s=(g,a)=>{if(a<0||a>=i.length)return;const r=[...i],f={...r[a].configuration,css_files:{index:a,value:g}};r[a]={...r[a],configuration:f},l(r)},c=o[0]&&o[0].css_files?Object.entries(o[0].css_files).map(([g,a])=>e.jsx("option",{value:g,children:a.name},g)):[];return e.jsx("select",{name:`code-editor-css-file-${t}`,onChange:g=>s(g.target.value,t),value:((v=(m=(d=i[t])==null?void 0:d.configuration)==null?void 0:m.css_files)==null?void 0:v.value)||"",children:c})},$=()=>{const n=p.useState("global_vars"),[t,i]=p.useState("global_editor_array"),l=_.useRef({}),[o,s]=_.useState(!1);_.useEffect(()=>{const a=()=>{window.ace?(console.log("Ace Editor is loaded."),s(!0)):setTimeout(a,300)};a()},[]),_.useEffect(()=>{o&&t.forEach((a,r)=>{const f=`ace-editor-${r}`,w=document.getElementById(f);if(w&&!l.current[f]){const h=window.ace.edit(f);h.session.setMode("ace/mode/css"),h.setOptions({enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,minLines:9,maxLines:30,wrap:!0}),h.setValue(a.code||"",-1),l.current[f]=h,h.commands.addCommand({name:"saveOnCtrlEnter",bindKey:{win:"Ctrl-S",mac:"Cmd-S"},exec:function(x){var y;S(t,i,(y=n[0])==null?void 0:y.compile_api_url)}}),h.commands.addCommand({name:"updateLiveView",bindKey:{win:"Ctrl-L",mac:"Cmd-L"},exec:function(x){var y;b(t,(y=n[0])==null?void 0:y.scss_api_url)}})}else w&&l.current[f]&&l.current[f].setValue(a.code||"",-1)})},[o,t]);const c=async a=>{if(!n||!n[0]||typeof n[0].open_api_url>"u"){console.error("The open_api_url is not defined in globalVars.");return}try{const r=await j.post(n[0].open_api_url,{open:a});r.data.compiled!==void 0&&typeof i=="function"&&i(r.data.compiled)}catch(r){console.error("Error",r)}};_.useEffect(()=>{(async()=>{try{await c("default")}catch(r){console.error("An error occurred while opening storage:",r)}})()},[]);const d=(a,r)=>{const f=a.target.value,w=t.map((h,x)=>x===r?{...h,title:f}:h);i(w)},m=a=>{const r=[...t];r.splice(a,1),i(r)},v=()=>{i([...t,{title:"",code:"",configuration:{}}])},g=a=>{u(".editor-"+a).slideToggle("fast")};return e.jsx("div",{className:"pnc-editors",children:t.map((a,r)=>{const f=`ace-editor-${r}`;return e.jsxs("div",{className:"pnc-editor-component",children:[e.jsx("input",{type:"text",name:"code-editor-title-"+r,className:"pnc-title",placeholder:"SCSS File Title",value:a.title,onChange:w=>d(w,r)}),e.jsx("button",{onClick:()=>g(r),className:"display-editor-btn",children:"+/-"}),e.jsxs("div",{className:"editor editor-"+r,children:[e.jsx("div",{id:f}),n[0].css_files==null?"":e.jsx(R,{ideNumber:r}),t.length!==1&&e.jsx("button",{onClick:()=>m(r),className:"delete-editor float-right",children:"Del"})]}),t.length-1===r&&e.jsx("button",{onClick:v,className:"add-editor clear-both float-right",children:"Add"})]},r)})})},F=()=>{const n=t=>{let i=/^((http|https):\/\/)/;t.target.value.startsWith("/")||i.test(t.target.value)||(t.target.value="https://"+t.target.value),document.getElementById("pnc-second-iframe").src=t.target.value};return _.useEffect(()=>{u("#pnc-second-iframe").on("load",function(){u(this).contents().find("body").on("click","a",function(t){console.log(this.href),u(".pnc-second-url").val(this.href)})})},[]),e.jsx("div",{id:"pnc-second-frame-id",className:"pnc-second-frame display-none",children:e.jsxs("div",{className:"pnc-editor-iframe-container",children:[e.jsx("div",{className:"pnc-url-form",children:e.jsx("input",{type:"text",name:"second-url",className:"pnc-second-url",placeholder:"Add url and press enter",onKeyPress:t=>t.key==="Enter"&&n(t)})}),e.jsx("div",{id:"pnc-iframe-container",children:e.jsx("iframe",{id:"pnc-second-iframe",className:"pnc-second-iframe",title:"website view"},"lllll")})]})})},M=n=>{const t=p.useState("global_vars");return e.jsx("div",{children:e.jsx("div",{id:"pnc-pop-up-wrapper-id",className:"pnc-pop-up-wrapper display-none",children:e.jsxs("div",{className:"pnc-",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Help"}),e.jsx("p",{}),e.jsx("h3",{children:"Version"}),e.jsx("p",{children:"Purencool editor version is 1.6.0"}),e.jsx("h3",{children:"Compile"}),e.jsx("p",{}),e.jsx("h3",{children:"Live View"}),e.jsx("p",{})]}),e.jsxs("div",{children:[e.jsx("h3",{children:"Global Array"}),e.jsx("pre",{children:JSON.stringify(t,void 0,2)})]}),e.jsxs("div",{children:[e.jsx("h3",{children:"Live Data"}),e.jsx("pre",{children:JSON.stringify(n.inputList,void 0,2)})]})]})})})},H=n=>{const t=p.useState("global_vars"),i=()=>{u(".pnc-feedback-wrapper").slideToggle("slow")};return _.useEffect(()=>{t[0].message.hash!==n.message.hash&&(i(),setTimeout(function(){i()},5e3)),n.message.title==="Update check"&&(n.message.title="Welcome",n.message.message="The version number is displayed under help",setTimeout(function(){i()},4e3))}),e.jsx("div",{id:"pnc-feedback-id",className:"pnc-feedback-wrapper",children:e.jsxs("div",{children:[e.jsx("div",{id:"pnc-feedback-title",children:e.jsx("p",{children:n.message.title})}),e.jsx("p",{children:n.message.message})]})})},K=n=>(k.useState("global_vars"),e.jsx("div",{children:e.jsx("div",{id:"editor-settings-wrapper-id",className:"pnc-pop-up-wrapper display-none",children:e.jsx("div",{className:"pnc-",children:e.jsxs("div",{children:[e.jsx("h2",{children:"Settings"}),e.jsxs("form",{children:[e.jsx("label",{children:"Override API URLs to be HTTP or HTTPS"}),e.jsx("input",{type:"checkbox",id:"https-override",name:"https-override",value:"https-override"})]})]})})})}));p.setState("global_vars",window.purencool_editor_config);p.setState("global_editor_array",[{title:"",code:"",configuration:{}}]);const q=()=>{const n=p.useState("global_vars"),t=p.useState("global_editor_array"),[i,l]=_.useState(50),o=d=>{let m=/^((http|https):\/\/)/;d.target.value.startsWith("/")||m.test(d.target.value)||(d.target.value="https://"+d.target.value),document.getElementById("pnc-iframe").src=d.target.value,u("#pnc-iframe").on("load",function(){const v=u("#pnc-iframe").contents().find("head");u(v).append('<style id="live-purencool-editor"></style>')})},s=d=>{l(d)},c=()=>n[0].default_iframe_url=="undefined"?"":n[0].default_iframe_url;return _.useEffect(()=>{u("#pnc-iframe").on("load",function(){u(this).contents().find("body").on("click","a",function(d){console.log(this.href),u(".pnc-url").val(this.href)})})},[]),e.jsxs("div",{className:"pnc-editor-wrapper main-content",children:[e.jsx(C,{className:"slider",onChange:s,defaultValue:50}),e.jsxs("div",{className:"pnc-editor-container",children:[e.jsx("div",{className:"pnc-left-panel pnc-editor-panel pnc-box",style:{width:`${i}%`},children:e.jsxs("div",{className:"pnc-left-systems",children:[e.jsx("div",{className:"pnc-left-menu position-relative float-left",children:e.jsx(U,{})}),e.jsxs("div",{className:"pnc-left-inputs position-relative float-right",children:[e.jsx($,{}),e.jsx(F,{})]})]})}),e.jsx("div",{className:"pnc-right-panel pnc-editor-website-frame pnc-box",style:{width:`${100-i}%`},children:e.jsxs("div",{className:"pnc-editor-iframe-container",children:[e.jsx("div",{className:"pnc-url-form",children:e.jsx("input",{type:"text",name:"url",className:"pnc-url",placeholder:"Add url and press enter",defaultValue:c(),onKeyUp:d=>d.key==="Enter"&&o(d)})}),e.jsx("div",{id:"pnc-iframe-container",children:e.jsx("iframe",{id:"pnc-iframe",className:"pnc-iframe",title:"website view"},"lllll")})]})})]}),e.jsx(H,{message:n[0].message}),e.jsx(M,{inputList:t}),e.jsx(K,{})]})};typeof window.purencool_editor_config>"u"&&(window.purencool_editor_config={scss_api_url:"undefined",compile_api_url:"undefined",open_api_url:"undefined",connect_api_url:"undefined",connect_api_key:"undefined",connect_api_domain:"undefined",default_iframe_url:"undefined",css_files:"undefined"});typeof window.purencool_editor_config.global_api_url<"u"&&(window.purencool_editor_config.scss_api_url=window.purencool_editor_config.global_api_url,window.purencool_editor_config.compile_api_url=window.purencool_editor_config.global_api_url,window.purencool_editor_config.open_api_url=window.purencool_editor_config.global_api_url,window.purencool_editor_config.default_iframe_url=window.purencool_editor_config.default_iframe_url,window.purencool_editor_config.css_files=window.purencool_editor_config.css_filles);typeof window.purencool_editor_config.connect_api_url<"u"&&(window.purencool_editor_config.connect_api_url=window.purencool_editor_config.connect_api_url,window.purencool_editor_config.connect_api_key=window.purencool_editor_config.connect_api_key,window.purencool_editor_config.connect_api_domain=window.purencool_editor_config.connect_api_domain);let N=[{element_type:"span",label:""}];typeof window.purencool_editor_config.scripted_array<"u"&&(N=window.purencool_editor_config.scripted_array);window.purencool_editor_config.scripted_elements=N;let J={title:"Update check",message:"Purencool api editor check...",hash:1111};window.purencool_editor_config.message=J;window.purencool_editor_config.globalKeyPress="1";window.purencool_editor_config.editors_container_width=40;E.createRoot(document.getElementById("root")).render(e.jsx(L.StrictMode,{children:e.jsx(q,{})}));
