"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectToPhpArray=void 0;const simpleTypes=["number","boolean","function","symbol"];function isRegexp(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function isObject(e){const n=typeof e;return null!==e&&("object"===n||"function"===n)}function objectToPhpArray(e,n,r=""){const t=[];return function e(n,r={},i=""){r.indent=r.indent||"\t";const o={newLine:"\n",newLineOrSpace:"\n",pad:i,indent:i+r.indent},a=e=>{if(void 0===r.inlineCharacterLimit)return e;const n=e.replace(new RegExp(o.newLine,"g"),"").replace(new RegExp(o.newLineOrSpace,"g")," ").replace(new RegExp(o.pad+"|"+o.indent,"g"),"");return n.length<=r.inlineCharacterLimit?n:e.replace(new RegExp(o.newLine+"|"+o.newLineOrSpace,"g"),"\n").replace(new RegExp(o.pad,"g"),i).replace(new RegExp(o.indent,"g"),i+r.indent)};if(-1!==t.indexOf(n))return'"Circular"';if(null===n)return"NULL";if(void 0===n||simpleTypes.includes(typeof n)||isRegexp(n))return String(n);if(n instanceof Date)return`date('${n.toISOString()}')`;if(Array.isArray(n)){if(0===n.length)return"array()";t.push(n);const p="array("+o.newLine+n.map(((t,a)=>{const p=n.length-1===a?o.newLine:","+o.newLineOrSpace;let c=e(t,r,i+r.indent);return r.transform&&(c=r.transform(n,a,c)),o.indent+c+p})).join("")+o.pad+")";return t.pop(),a(p)}if(isObject(n)){let p=Object.keys(n);if(r.filter&&(p=p.filter((e=>{var t;return null===(t=r.filter)||void 0===t?void 0:t.call(r,n,e)}))),0===p.length)return Array.isArray(n)?"array()":"(object)[]";t.push(n);const c="array("+o.newLine+p.map(((t,a)=>{const c=p.length-1===a?o.newLine:","+o.newLineOrSpace,l="symbol"==typeof t,s=!l&&/^[a-z$_][a-z$_0-9]*$/i.test(t),u=l||s?t:e(t,r);let g=e(n[t],r,i+r.indent);return r.transform&&(g=r.transform(n,t,g)),`${o.indent}"${String(u)}" => ${g}${c}`})).join("")+o.pad+")";return t.pop(),a(c)}return n=String(n).replace(/[\r\n]/g,(e=>"\n"===e?"\\n":"\\r")),!1===r.singleQuotes?`"${n=n.replace(/"/g,'\\"')}"`:`"${n=n.replace(/\\?'/g,"\\'")}"`}(e,n,r)}exports.objectToPhpArray=objectToPhpArray;
//# sourceMappingURL=utils.js.map