"use strict";const constant=require("./shared/dom-open-code.d55232d3.cjs"),u=(e,t)=>{const{origin:n}=window.location;fetch(`${n}${constant.OPEN_CODE_API}?filePathId=${e}&componentFilePathId=${t}`).catch(o=>{console.error("dom-to-code: ",o)})};function i(e){return!e||!e.getAttribute?null:e.getAttribute(constant.DOM_ATTR)?e.getAttribute(constant.DOM_ATTR):i(e.parentNode)}function l(e){if(e.getAttribute(constant.DOM_ATTR))return e.getAttribute(constant.DOM_ATTR);if(e.__vnode){let o=e.__vueParentComponent;for(;o&&!o.attrs[constant.DOM_ATTR];)o=o.parent;if(o)return o.attrs[constant.DOM_ATTR]}let t=null,n=e;for(;!n.__vue__&&n.parentElement;)n=n.parentElement;if(t=n.__vue__,t){for(;t&&!t.$attrs[constant.DOM_ATTR];)t=t.$parent;if(t)return t.$attrs[constant.DOM_ATTR]}return i(e)}function initDomOpenCode(){let e="";document.addEventListener("keydown",t=>{e=t.key}),document.addEventListener("mousedown",t=>{if((t.button===1||t.button===2)&&(e==="Control"||e==="Meta")){t.stopImmediatePropagation(),t.preventDefault(),t.stopPropagation(),console.log("dom-to-code: open editor.");const n=i(t.target),o=l(t.target);n&&u(n,o),e=""}},!0)}exports.initDomOpenCode=initDomOpenCode;